RpcRequest
Utility types & functions for working with JSON-RPC 2.0 Requests and Ethereum JSON-RPC methods as defined on the Ethereum API specification
Examples
Instantiating a Request Store
A Request Store can be instantiated using RpcRequest.createStore:
import { RpcRequest } from 'ox'
 
const store = RpcRequest.createStore()
 
const request_1 = store.prepare({
  method: 'eth_blockNumber',
})
{ id: 0, jsonrpc: '2.0', method: 'eth_blockNumber' } const request_2 = store.prepare({
  method: 'eth_call',
  params: [
    {
      to: '0x0000000000000000000000000000000000000000',
      data: '0xdeadbeef',
    },
  ],
})
{ id: 1, jsonrpc: '2.0', method: 'eth_call', params: [{ to: '0x0000000000000000000000000000000000000000', data: '0xdeadbeef' }] }Functions
| Name | Description | 
|---|---|
RpcRequest.createStore | Creates a JSON-RPC request store to build requests with an incrementing id. | 
RpcRequest.from | A type-safe interface to build a JSON-RPC request object as per the JSON-RPC 2.0 specification. | 
Types
| Name | Description | 
|---|---|
RpcRequest.RpcRequest | A JSON-RPC request object as per the JSON-RPC 2.0 specification. | 
RpcRequest.Store | JSON-RPC request store type. | 

