Source: jsonrpcTests: Rpc.test.ts • anvil.test.ts • hardhat.test.ts
Method API
Request builders create type-safe JSON-RPC requests with branded primitive parameters.Request Builders
Request builders returnRequestArguments objects compatible with EIP-1193 providers:
Request Pattern
All request builders follow this signature:Rpc.Eth.MethodName- Request builder (e.g.,CallRequest,GetBalanceRequest)params- Branded primitive types (Address, Hash, Hex, etc.)- Returns -
{method: string, params?: unknown[]}object
Branded Primitive Parameters
All parameters use Voltaire’s branded primitive types for compile-time safety:Type Safety Benefits
TypeScript catches errors at compile time:Error Handling
Throwing Errors
Requests throw errors on failure:Type Inference
Return types are automatically inferred:BlockTag Parameter
Many requests acceptBlockTag to specify block context:
Method Categories
Read Operations
Contract Calls
Transaction Operations
Block Operations
Log Queries
Error Codes
Common JSON-RPC error codes:| Code | Message | Description |
|---|---|---|
-32700 | Parse error | Invalid JSON |
-32600 | Invalid request | Missing required fields |
-32601 | Method not found | Method doesn’t exist |
-32602 | Invalid params | Wrong parameter types |
-32603 | Internal error | Server-side error |
3 | Execution reverted | Contract execution failed |
Best Practices
- Use try/catch for error handling
- Use branded types for all parameters
- Reuse type instances - don’t reconstruct on every call
- Batch independent requests with Promise.all
Method Reference
eth Methods
40 standard Ethereum methods for blocks, transactions, state, and logs.
debug Methods
5 debugging methods for transaction tracing and analysis.
engine Methods
20 consensus layer methods for Engine API integration.
Related
- Getting Started - Installation and first requests
- Events - Event handling with EventEmitter
- Error Handling - Error codes and patterns
- eth Methods - Complete method reference

