EthActionsApi
EthActionsApi:
object
The actions api is the high level API for interacting with a Tevm client similar to viem actions These actions correspond 1:1 eith the public ethereum JSON-RPC api
See
https://tevm.sh/learn/actions/
Type declaration
eth
eth:
object
Standard JSON-RPC methods for interacting with the VM
See
eth.blockNumber
eth.blockNumber:
EthBlockNumberHandler
Returns the current block number
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const blockNumber = await tevm.eth.blockNumber()console.log(blockNumber) // 0n
eth.call
eth.call:
EthCallHandler
Executes a call without modifying the state
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const res = await tevm.eth.call({to: '0x123...', data: '0x123...'})console.log(res) // "0x..."
eth.chainId
eth.chainId:
EthChainIdHandler
Returns the current chain id
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const chainId = await tevm.eth.chainId()console.log(chainId) // 10n
eth.gasPrice
eth.gasPrice:
EthGasPriceHandler
Returns the current gas price
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const gasPrice = await tevm.eth.gasPrice()console.log(gasPrice) // 0n
eth.getBalance
eth.getBalance:
EthGetBalanceHandler
Returns the balance of a given address
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const balance = await tevm.eth.getBalance({address: '0x123...', tag: 'pending'})console.log(gasPrice) // 0n
eth.getCode
eth.getCode:
EthGetCodeHandler
Returns code at a given address
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const code = await tevm.eth.getCode({address: '0x123...'})
eth.getStorageAt
eth.getStorageAt:
EthGetStorageAtHandler
Returns storage at a given address and slot
Set the tag
to a block number or block hash to get the balance at that block
Block tag defaults to ‘pending’ tag which is the optimistic state of the VM
See
Example
const storageValue = await tevm.eth.getStorageAt({address: '0x123...', position: 0})