brane-research
Research EVM SDK patterns from viem (TypeScript) and alloy (Rust) when designing Brane features. Use when implementing new functionality, designing APIs, or solving problems that other SDKs have already addressed.
SKILL.md
| Name | brane-research |
| Description | Research EVM SDK patterns from viem (TypeScript) and alloy (Rust) when designing Brane features. Use when implementing new functionality, designing APIs, or solving problems that other SDKs have already addressed. |
name: brane-research description: Research EVM SDK patterns from viem (TypeScript) and alloy (Rust) when designing Brane features. Use when implementing new functionality, designing APIs, or solving problems that other SDKs have already addressed.
Brane SDK Research
Purpose
When implementing Brane features, reference how mature EVM SDKs solve the same problems:
- viem (TypeScript) - Modern, type-safe, excellent documentation
- alloy (Rust) - Performance-focused, similar design philosophy to Brane
These SDKs have solved many of the same problems. Learn from their API design, naming conventions, and implementation patterns.
Reference Sources
viem (TypeScript)
- Documentation: https://viem.sh
- GitHub: https://github.com/wevm/viem
- Key strengths: Excellent docs, modern API, comprehensive examples
alloy (Rust)
- Documentation: https://alloy.rs
- GitHub: https://github.com/alloy-rs/alloy
- Key strengths: Type safety, performance, similar goals to Brane
When to Research
Use this skill when:
- Designing new APIs - How do viem/alloy name this? What parameters do they use?
- Implementing features - What edge cases did they handle?
- Solving problems - Has this been solved before? How?
- Naming things - What's the conventional name for this concept?
Research Workflow
Step 1: Identify the Feature Area
Map your Brane feature to the equivalent concept:
| Brane Area | viem Equivalent | alloy Equivalent |
|---|---|---|
Brane.Reader | publicClient / PublicActions | Provider |
Brane.Signer | walletClient / WalletActions | Signer + Provider |
BraneContract.bind() | getContract() | ContractInstance |
TransactionRequest | TransactionRequest | TransactionRequest |
Address, Hash, HexData | Branded types | Address, B256, Bytes |
| ABI encoding | encodeFunctionData | SolCall::abi_encode |
| ABI decoding | decodeFunctionResult | SolCall::abi_decode |
| Gas estimation | estimateGas | estimate_gas |
| Transaction receipt | waitForTransactionReceipt | get_transaction_receipt |
Step 2: Fetch Documentation
Use WebFetch to read the relevant documentation:
# viem examples
https://viem.sh/docs/actions/public/getBalance
https://viem.sh/docs/contract/readContract
https://viem.sh/docs/actions/wallet/sendTransaction
# alloy examples
https://alloy.rs/examples/providers/builder.html
https://alloy.rs/examples/contracts/deploy.html
Step 3: Compare and Adapt
When adapting patterns to Java/Brane:
| viem/alloy Pattern | Brane Adaptation |
|---|---|
| Async/await | Blocking calls (Java's virtual threads handle concurrency) |
| Generic type parameters | Java generics or method overloads |
| Builder pattern | Same (Java builders work well) |
| Result/Option types | Exceptions + Optional |
| Branded types | Record types with validation |
Common Research Scenarios
Scenario: Implementing a new RPC method
- Check viem docs for the action:
https://viem.sh/docs/actions/public/{methodName} - Note the parameters, return type, and edge cases
- Check if alloy has additional insights in their examples
Scenario: Designing a new type
- Look at viem's type definitions in their TypeScript source
- Look at alloy's type definitions (usually in
alloy-primitivesoralloy-rpc-types) - Adapt to Java records with validation
Scenario: Handling errors
- Check viem's error types: https://viem.sh/docs/glossary/errors
- See how they categorize and present errors
- Map to Brane's exception hierarchy
Scenario: Gas estimation strategy
- viem: https://viem.sh/docs/actions/public/estimateGas
- alloy: Check their provider examples
- Note buffer strategies, EIP-1559 handling
API Naming Conventions
Learn from viem/alloy naming patterns:
| Concept | viem | alloy | Brane (adopt) |
|---|---|---|---|
| Read contract | readContract | call | call or read |
| Write contract | writeContract | send_transaction | sendTransaction |
| Get balance | getBalance | get_balance | getBalance |
| Get block | getBlock | get_block | getBlock |
| Wait for receipt | waitForTransactionReceipt | watch_pending_transaction | sendTransactionAndWait |
Key Documentation Pages
viem - Bookmark These
- Public Actions: https://viem.sh/docs/actions/public/introduction
- Wallet Actions: https://viem.sh/docs/actions/wallet/introduction
- Contract: https://viem.sh/docs/contract/introduction
- ABI: https://viem.sh/docs/abi/introduction
- Utilities: https://viem.sh/docs/utilities/introduction
- Errors: https://viem.sh/docs/glossary/errors
alloy - Bookmark These
- Book/Guide: https://alloy.rs
- Examples: https://alloy.rs/examples/
- API Docs: https://docs.rs/alloy/latest/alloy/
Example Research Session
Task: Implement eth_getLogs with filter support
Research steps:
-
viem docs: Fetch https://viem.sh/docs/actions/public/getLogs
- Note: filter parameters, block range handling, topics array format
- Note: How they handle "block range too large" errors
-
alloy examples: Check their filtering examples
- Note: Type definitions for LogFilter
-
Adapt to Brane:
- Create
LogFilterrecord with builder - Return
List<LogEntry> - Handle block range errors with
RpcException.isBlockRangeTooLarge()
- Create
Things viem/alloy Do Well (Learn From)
- Type safety - Both have strong typing; Brane should too
- Ergonomic APIs - Easy common cases, flexible advanced cases
- Good defaults - Sensible defaults, explicit overrides
- Error messages - Clear, actionable error messages
- Documentation - Examples for every feature
Things to Adapt (Not Copy Directly)
| Pattern | Why Adapt |
|---|---|
| Async everywhere | Java uses blocking + virtual threads |
| Function overloading via types | Java uses method overloading |
| Optional chaining | Java uses Optional or null checks |
| Destructuring | Java uses record accessors |