Skip to content

Actions

Overview

Tevm has an actions based api similar to viem’s actions api and following similar patterns. This is a higher level of abstraction than the lower level JSON-RPC api

Errors

All actions return errors as values

const {errors} = client.setAccount({})
if (errors?.length) {
console.log(errors[0]).name // AddressRequiredError
console.log(errors[0].message) // AddressRequiredError: `address` is a required property
}

As a best practice you should always check the errors property for errors. In future versions of tevm we may expose the ability to throw instead as a configuration option to the client. Consider joining the telegram if you would like this feature.

Tevm actions

Tevm methods are the main recomended way to interact with Tevm. 🚧 means the procedure is still under construction

  • Tevm.call - Similar to eth call but with additional properties to control the VM execution
  • Tevm.getAccount - gets account information such as balances contract information nonces and state roots.
  • Tevm.setAccount - directly modifies the state of an account
  • Tevm.contract - Similar to eth call but with additional properties to control the VM execution
  • Tevm.script - Runs the provided bytecode against the EVM state
  • 🚧 Tevm.traceContractCall
  • 🚧 Tevm.traceScript
  • Tevm.dumpState - Returns the state of the VM
  • Tevm.loadState - Initializes the state of the VM

Eth methods

Tevm plans on implementing most of the ethereum JSON-RPC spec

Debug methods

Anvil/Hardhat methods

Anvil/hardhat methods are provided for compatability

Tree shakeable actions

Like viem, Tevm provides tree shakable versions of the actions in the tevm/procedures package. But for Tevm it is recomended you use the higher level client apis. If bundle size is a concern a more effective way of reducing bundle size is using a remote http client and running the EVM on a backend server