Skip to content

createJsonRpcFetcher

createJsonRpcFetcher(client): JsonRpcClient

Parameters

client

client.request: EIP1193RequestFn<undefined>

Returns

JsonRpcClient

the result field from the JSON-RPC response

See

https://ethereum.org/en/developers/docs/apis/json-rpc/

Example

const url = 'https://mainnet.optimism.io'
const params = {
method: 'eth_getBlockByNumber',
params: ['latest', false],
}
const {result: block} = await fetchJsonRpc(url, params)

Defined in

packages/jsonrpc/src/createJsonRpcFetcher.js:19