Skip to content

TevmJsonRpcRequestHandler

TevmJsonRpcRequestHandler: <TRequest>(request) => Promise<JsonRpcReturnTypeFromMethod<TRequest["method"]>>

Typesafe request handler for JSON-RPC requests. Most users will want to use the higher level and more feature-rich actions api

Type Parameters

TRequest extends TevmJsonRpcRequest | EthJsonRpcRequest | AnvilJsonRpcRequest | DebugJsonRpcRequest

Parameters

request: TRequest

Returns

Promise<JsonRpcReturnTypeFromMethod<TRequest["method"]>>

Example

const blockNumberResponse = await tevm.request({
method: 'eth_blockNumber',
params: []
id: 1
jsonrpc: '2.0'
})
const accountResponse = await tevm.request({
method: 'tevm_getAccount',
params: [{address: '0x123...'}]
id: 1
jsonrpc: '2.0'
})

tevm_* methods

tevm_call

request - CallJsonRpcRequest response - CallJsonRpcResponse

tevm_getAccount

request - GetAccountJsonRpcRequest response - GetAccountJsonRpcResponse

tevm_setAccount

request - SetAccountJsonRpcRequest response - SetAccountJsonRpcResponse

debug_* methods

debug_traceCall

request - DebugTraceCallJsonRpcRequest response - DebugTraceCallJsonRpcResponse

eth_* methods

eth_blockNumber

request - EthBlockNumberJsonRpcRequest response - EthBlockNumberJsonRpcResponse

eth_chainId

request - EthChainIdJsonRpcRequest response - EthChainIdJsonRpcResponse

eth_getCode

request - EthGetCodeJsonRpcRequest response - EthGetCodeJsonRpcResponse

eth_getStorageAt

request - EthGetStorageAtJsonRpcRequest response - EthGetStorageAtJsonRpcResponse

eth_gasPrice

request - EthGasPriceJsonRpcRequest response - EthGasPriceJsonRpcResponse

eth_getBalance

request - EthGetBalanceJsonRpcRequest response - EthGetBalanceJsonRpcResponse

Defined in

packages/actions/src/tevm-request-handler/TevmJsonRpcRequestHandler.ts:82