Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

JSON-RPC Support

Tevm Node provides EIP-1193-compatible JSON-RPC support for integration with Ethereum libraries and tools.

EIP-1193 Provider

import { createTevmNode } from 'tevm'
import { requestEip1193 } from 'tevm/decorators'
 
const node = createTevmNode().extend(requestEip1193())
 
const blockNum = await node.request({ method: 'eth_blockNumber', params: [] })

Supported Methods

For Tevm's runtime model and the mapping to ZEVM's native trusted/light-mode docs, see Runtime Model and ZEVM. Native ZEVM has its own mode-gated JSON-RPC Overview and Verified Light-Mode Reads contract; the index below is the Tevm source of truth.

Engine API methods are only registered when engineApi is enabled. tevm_*, hardhat_*, and ganache_* development-control aliases share implementations with matching anvil_* methods. tevm_contract and eth_sendUnsignedTransaction are registered compatibility stubs returning unsupported-method errors.

Tevm and ZEVM compatibility

Native Tevm methods:

  • tevm_call
  • tevm_contract
  • tevm_dumpState
  • tevm_getAccount
  • tevm_lightSyncStatus
  • tevm_loadState
  • tevm_mine
  • tevm_miner
  • tevm_setAccount
  • zevm_lightSyncStatus

Tevm aliases for development controls:

  • tevm_addBalance
  • tevm_autoImpersonateAccount
  • tevm_deal
  • tevm_dealErc20
  • tevm_dropAllTransactions
  • tevm_dropTransaction
  • tevm_enableTraces
  • tevm_getAutomine
  • tevm_getIntervalMining
  • tevm_impersonateAccount
  • tevm_increaseTime
  • tevm_metadata
  • tevm_mineDetailed
  • tevm_nodeInfo
  • tevm_removeBlockTimestampInterval
  • tevm_removePoolTransactions
  • tevm_reset
  • tevm_revert
  • tevm_setAutomine
  • tevm_setBalance
  • tevm_setBlockGasLimit
  • tevm_setBlockTimestampInterval
  • tevm_setChainId
  • tevm_setCode
  • tevm_setCoinbase
  • tevm_setErc20Allowance
  • tevm_setIntervalMining
  • tevm_setLoggingEnabled
  • tevm_setMinGasPrice
  • tevm_setNextBlockBaseFeePerGas
  • tevm_setNextBlockTimestamp
  • tevm_setNonce
  • tevm_setPrevRandao
  • tevm_setRpcUrl
  • tevm_setStorageAt
  • tevm_setTime
  • tevm_snapshot
  • tevm_stopImpersonatingAccount

Ethereum

  • eth_accounts
  • eth_blobBaseFee
  • eth_blobGasPrice
  • eth_blockNumber
  • eth_call
  • eth_chainId
  • eth_coinbase
  • eth_createAccessList
  • eth_estimateGas
  • eth_feeHistory
  • eth_gasPrice
  • eth_getBalance
  • eth_getBlockAccessList
  • eth_getBlockByHash
  • eth_getBlockByNumber
  • eth_getBlockReceipts
  • eth_getBlockTransactionCountByHash
  • eth_getBlockTransactionCountByNumber
  • eth_getCode
  • eth_getFilterChanges
  • eth_getFilterLogs
  • eth_getLogs
  • eth_getProof
  • eth_getStorageAt
  • eth_getStorageValues
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_getTransactionByHash
  • eth_getTransactionCount
  • eth_getTransactionReceipt
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_getWork
  • eth_hashrate
  • eth_maxPriorityFeePerGas
  • eth_mining
  • eth_newBlockFilter
  • eth_newFilter
  • eth_newPendingTransactionFilter
  • eth_protocolVersion
  • eth_sendRawTransaction
  • eth_sendTransaction
  • eth_sendUnsignedTransaction
  • eth_sign
  • eth_signTransaction
  • eth_simulateV1
  • eth_simulateV2
  • eth_submitHashrate
  • eth_submitWork
  • eth_subscribe
  • eth_syncing
  • eth_uninstallFilter
  • eth_unsubscribe

Anvil

  • anvil_addBalance
  • anvil_autoImpersonateAccount
  • anvil_deal
  • anvil_dealErc20
  • anvil_dropAllTransactions
  • anvil_dropTransaction
  • anvil_dumpState
  • anvil_enableTraces
  • anvil_getAutomine
  • anvil_getIntervalMining
  • anvil_impersonateAccount
  • anvil_increaseTime
  • anvil_loadState
  • anvil_metadata
  • anvil_mine
  • anvil_mineDetailed
  • anvil_nodeInfo
  • anvil_removeBlockTimestampInterval
  • anvil_removePoolTransactions
  • anvil_reset
  • anvil_revert
  • anvil_setAutomine
  • anvil_setBalance
  • anvil_setBlockGasLimit
  • anvil_setBlockTimestampInterval
  • anvil_setChainId
  • anvil_setCode
  • anvil_setCoinbase
  • anvil_setErc20Allowance
  • anvil_setIntervalMining
  • anvil_setLoggingEnabled
  • anvil_setMinGasPrice
  • anvil_setNextBlockBaseFeePerGas
  • anvil_setNextBlockTimestamp
  • anvil_setNonce
  • anvil_setPrevRandao
  • anvil_setRpcUrl
  • anvil_setStorageAt
  • anvil_setTime
  • anvil_snapshot
  • anvil_stopImpersonatingAccount

Hardhat

  • hardhat_addBalance
  • hardhat_autoImpersonateAccount
  • hardhat_deal
  • hardhat_dealErc20
  • hardhat_dropAllTransactions
  • hardhat_dropTransaction
  • hardhat_dumpState
  • hardhat_enableTraces
  • hardhat_getAutomine
  • hardhat_getIntervalMining
  • hardhat_impersonateAccount
  • hardhat_increaseTime
  • hardhat_loadState
  • hardhat_metadata
  • hardhat_mine
  • hardhat_mineDetailed
  • hardhat_nodeInfo
  • hardhat_removeBlockTimestampInterval
  • hardhat_removePoolTransactions
  • hardhat_reset
  • hardhat_revert
  • hardhat_setAutomine
  • hardhat_setBalance
  • hardhat_setBlockGasLimit
  • hardhat_setBlockTimestampInterval
  • hardhat_setChainId
  • hardhat_setCode
  • hardhat_setCoinbase
  • hardhat_setErc20Allowance
  • hardhat_setIntervalMining
  • hardhat_setLoggingEnabled
  • hardhat_setMinGasPrice
  • hardhat_setNextBlockBaseFeePerGas
  • hardhat_setNextBlockTimestamp
  • hardhat_setNonce
  • hardhat_setPrevRandao
  • hardhat_setRpcUrl
  • hardhat_setStorageAt
  • hardhat_setTime
  • hardhat_snapshot
  • hardhat_stopImpersonatingAccount

Ganache

  • ganache_addBalance
  • ganache_autoImpersonateAccount
  • ganache_deal
  • ganache_dealErc20
  • ganache_dropAllTransactions
  • ganache_dropTransaction
  • ganache_dumpState
  • ganache_enableTraces
  • ganache_getAutomine
  • ganache_getIntervalMining
  • ganache_impersonateAccount
  • ganache_increaseTime
  • ganache_loadState
  • ganache_metadata
  • ganache_mine
  • ganache_mineDetailed
  • ganache_nodeInfo
  • ganache_removeBlockTimestampInterval
  • ganache_removePoolTransactions
  • ganache_reset
  • ganache_revert
  • ganache_setAutomine
  • ganache_setBalance
  • ganache_setBlockGasLimit
  • ganache_setBlockTimestampInterval
  • ganache_setChainId
  • ganache_setCode
  • ganache_setCoinbase
  • ganache_setErc20Allowance
  • ganache_setIntervalMining
  • ganache_setLoggingEnabled
  • ganache_setMinGasPrice
  • ganache_setNextBlockBaseFeePerGas
  • ganache_setNextBlockTimestamp
  • ganache_setNonce
  • ganache_setPrevRandao
  • ganache_setRpcUrl
  • ganache_setStorageAt
  • ganache_setTime
  • ganache_snapshot
  • ganache_stopImpersonatingAccount

Debug

  • debug_dumpBlock
  • debug_getBadBlocks
  • debug_getModifiedAccountsByHash
  • debug_getModifiedAccountsByNumber
  • debug_getRawBlock
  • debug_getRawHeader
  • debug_getRawReceipts
  • debug_getRawTransaction
  • debug_intermediateRoots
  • debug_preimage
  • debug_storageRangeAt
  • debug_traceBlock
  • debug_traceBlockByHash
  • debug_traceBlockByNumber
  • debug_traceCall
  • debug_traceChain
  • debug_traceState
  • debug_traceTransaction

EVM test-runner compatibility

  • evm_increaseTime
  • evm_mine
  • evm_revert
  • evm_setBlockGasLimit
  • evm_setIntervalMining
  • evm_setNextBlockTimestamp
  • evm_snapshot

Engine API

  • engine_exchangeCapabilities
  • engine_exchangeTransitionConfigurationV1
  • engine_forkchoiceUpdatedV1
  • engine_forkchoiceUpdatedV2
  • engine_forkchoiceUpdatedV3
  • engine_forkchoiceUpdatedV4
  • engine_getBlobsV1
  • engine_getBlobsV2
  • engine_getBlobsV3
  • engine_getClientVersionV1
  • engine_getPayloadBodiesByHashV1
  • engine_getPayloadBodiesByHashV2
  • engine_getPayloadBodiesByRangeV1
  • engine_getPayloadBodiesByRangeV2
  • engine_getPayloadV1
  • engine_getPayloadV2
  • engine_getPayloadV3
  • engine_getPayloadV4
  • engine_getPayloadV5
  • engine_getPayloadV6
  • engine_newPayloadV1
  • engine_newPayloadV2
  • engine_newPayloadV3
  • engine_newPayloadV4
  • engine_newPayloadV5
  • testing_buildBlockV1

Txpool, web3, net, rpc, and miner compatibility

  • miner_start
  • miner_stop
  • net_listening
  • net_peerCount
  • net_version
  • rpc_modules
  • txpool_content
  • txpool_contentFrom
  • txpool_inspect
  • txpool_status
  • web3_clientVersion
  • web3_sha3

Client Integration

Viem

See Viem Documentation.

import { createTevmTransport } from 'tevm'
import { createPublicClient, custom } from 'viem'
import { requestEip1193 } from 'tevm/decorators'
 
const tevmTransport = createTevmTransport()
const client = createPublicClient({ chain: mainnet, transport: tevmTransport })

Ethers

See Ethers Documentation.

import { createTevmNode } from 'tevm'
import { BrowserProvider } from 'ethers'
import { requestEip1193 } from 'tevm/decorators'
 
const node = createTevmNode().extend(requestEip1193())
const provider = new BrowserProvider(node)

Error Handling

JSON-RPC errors follow the standard format and are fully typed. See JsonRpcError type:

interface JsonRpcError {
  code: number
  message: string
  data?: unknown
}

Common codes (see ErrorCodes):

See Error Handling Guide.

Best Practices

Wrap RPC calls in try-catch. Estimate gas before sending (ErrorCodes):

const gasEstimate = await node.request({ method: 'eth_estimateGas', params: [tx] })

Wait for receipts (ethGetTransactionReceipt):

const txHash = await node.request({ method: 'eth_sendTransaction', params: [tx] })
const receipt = await node.request({ method: 'eth_getTransactionReceipt', params: [txHash] })

Filter efficiently: set block ranges, use specific topics, clean up with eth_uninstallFilter.

See:

Related Topics

Using Tevm Actions

High-level actions from tevm/actions (see actions docs):

import {
  tevmCall,
  tevmMine,
  tevmGetAccount,
  tevmSetAccount,
  tevmDeal
} from 'tevm/actions'
import { createTevmNode } from 'tevm'
 
const node = createTevmNode()
 
const result = await tevmCall(node, {
  to: '0x...',
  data: '0x...',
  value: 0n,
  createTransaction: true
})
 
await tevmMine(node)
 
const account = await tevmGetAccount(node, { address: '0x...', blockTag: 'latest' })
 
await tevmSetAccount(node, {
  address: '0x...',
  balance: 100n,
  nonce: 0n,
  deployedBytecode: '0x...'
})
 
// Native ETH
await tevmDeal(node, {
  account: '0x...',
  amount: 1000000000000000000n // 1 ETH
})
 
// ERC20
await tevmDeal(node, {
  erc20: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC mainnet
  account: '0x...',
  amount: 1000000n // 1 USDC (6 decimals)
})

Type references:

Optimistic Updates with Receipt Manager

See Ethereum Receipts.

import { createTevmNode } from 'tevm'
import { tevmCall, tevmMine } from 'tevm/actions'
 
const node = createTevmNode()
const receiptsManager = await node.getReceiptsManager()
 
// Submit
const { txHash } = await tevmCall(node, {
  method: 'eth_sendTransaction',
  params: [tx],
  createTransaction: true
})
 
const pendingReceipt = await receiptsManager.getReceiptByTxHash(txHash)
updateUI(pendingReceipt)
 
const realReceipt = await node.request({
  method: 'eth_getTransactionReceipt',
  params: [txHash]
})
 
if (receiptsAreDifferent(pendingReceipt, realReceipt)) {
  await receiptsManager.removeReceipt(txHash)
  updateUI(realReceipt)
}
 
// Rebase on new blocks
node.on('block', async (blockNumber) => {
  const block = await node.request({
    method: 'eth_getBlockByNumber',
    params: [blockNumber, true]
  })
 
  const pendingTxs = await receiptsManager.getPendingTransactions()
 
  for (const tx of pendingTxs) {
    const result = await tevmCall(node, { ...tx, blockTag: 'pending' })
    await receiptsManager.putReceipt(tx.hash, result)
  }
 
  await tevmMine(node)
})