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.

TevmClient actions

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

Note the call family of actions including TevmClient.call, TevmClient.contract, and TevmClient.script will execute in a sandbox and not modify the state. This behavior can be disabled via passing in a enableTransaction: true parameter.

Eth methods

TevmClient 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, TevmClient 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