# RpcRequest

Utility types & functions for working with [JSON-RPC 2.0 Requests](https://www.jsonrpc.org/specification#request_object) and Ethereum JSON-RPC methods as
defined on the [Ethereum API specification](https://github.com/ethereum/execution-apis)

## Examples

### Instantiating a Request Store

A Request Store can be instantiated using [`RpcRequest.createStore`](/api/RpcRequest/createStore):

```ts twoslash
import { RpcRequest } from 'ox'

const store = RpcRequest.createStore()

const request_1 = store.prepare({
  method: 'eth_blockNumber'
})
// @log: { id: 0, jsonrpc: '2.0', method: 'eth_blockNumber' }

const request_2 = store.prepare({
  method: 'eth_call',
  params: [
    {
      to: '0x0000000000000000000000000000000000000000',
      data: '0xdeadbeef'
    }
  ]
})
// @log: { id: 1, jsonrpc: '2.0', method: 'eth_call', params: [{ to: '0x0000000000000000000000000000000000000000', data: '0xdeadbeef' }] }
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`RpcRequest.createStore`](/api/RpcRequest/createStore) | Creates a JSON-RPC request store to build requests with an incrementing `id`. |
| [`RpcRequest.from`](/api/RpcRequest/from) | A type-safe interface to build a JSON-RPC request object as per the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#request_object). |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`RpcRequest.RpcRequest`](/api/RpcRequest/types#rpcrequestrpcrequest) | A JSON-RPC request object as per the [JSON-RPC 2.0 specification](https://www.jsonrpc.org/specification#request_object). |
| [`RpcRequest.Store`](/api/RpcRequest/types#rpcrequeststore) | JSON-RPC request store type. |
