TevmActions
TevmActions:
object
Provides powerful actions for interacting with the EVM using the TEVM API. These actions allow for low-level access to the EVM, managing accounts, deploying contracts, and more.
Type declaration
tevm
tevm:
TevmNode
&Eip1193RequestProvider
Low level access to TEVM can be accessed via tevm
. These APIs are not guaranteed to be stable.
See
TevmNode
Example
tevmCall
tevmCall:
TevmActionsApi
["call"
]
A powerful low level API for executing calls and sending transactions.
See CallParams for options reference.
See CallResult for return values reference.
Remember, you must set createTransaction: true
to send a transaction. Otherwise, it will be a call. You must also mine the transaction
before it updates the canonical head state. This can be avoided by setting mining mode to auto
when using createMemoryClient.
Example
In addition to making basic calls, you can also do advanced things like:
- Impersonate accounts via passing in
from
,caller
, ororigin
- Set the call depth via
depth
- Create a trace or access list using
createTrace: true
orcreateAccessList: true
- Send as a transaction with
createTransaction: true
For all options see CallParams
tevmContract
tevmContract:
TevmActionsApi
["contract"
]
A powerful low level API for calling contracts. Similar to tevmCall
but takes care of encoding and decoding data, revert messages, etc.
See ContractParams for options reference.
See ContractResult for return values reference.
Remember, you must set createTransaction: true
to send a transaction. Otherwise, it will be a call. You must also mine the transaction
before it updates the canonical head state. This can be avoided by setting mining mode to auto
when using createMemoryClient.
Example
In addition to making basic calls, you can also do advanced things like:
- Impersonate accounts via passing in
from
,caller
, ororigin
- Set the call depth via
depth
- Create a trace or access list using
createTrace: true
orcreateAccessList: true
- Send as a transaction with
createTransaction: true
For all options see ContractParams
tevmDeploy
tevmDeploy:
TevmActionsApi
["deploy"
]
Deploys a contract to the EVM with encoded constructor arguments. Extends tevmCall
so it supports all advanced options.
See
- DeployParams for options reference.
- DeployResult for return values reference.
Remember, you must set
createTransaction: true
to send a transaction. Otherwise, it will be a call. You must also mine the transaction before it updates the canonical head state. This can be avoided by setting mining mode toauto
when using createMemoryClient.
Example
tevmDumpState
tevmDumpState:
TevmActionsApi
["dumpState"
]
Dumps a JSON serializable state from the EVM. This can be useful for persisting and restoring state between processes.
Example
tevmGetAccount
tevmGetAccount:
TevmActionsApi
["getAccount"
]
Gets the account state of an account. It does not return the storage state by default but can if returnStorage
is set to true
.
In forked mode, the storage is only the storage TEVM has cached and may not represent all the on-chain storage.
See
- GetAccountParams for options reference.
- GetAccountResult for return values reference.
Example
tevmLoadState
tevmLoadState:
TevmActionsApi
["loadState"
]
Loads a JSON serializable state into the EVM. This can be useful for persisting and restoring state between processes.
Example
tevmMine
tevmMine:
TevmActionsApi
["mine"
]
Mines a new block with all pending transactions. In manual
mode you must call this manually before the canonical head state is updated.
Example
tevmReady()
tevmReady: () =>
Promise
<true
>
Returns a promise that resolves when the TEVM is ready. This is not needed to explicitly be called as all actions will wait for the TEVM to be ready.
Returns
Promise
<true
>
Example
Same as calling client.tevm.ready()
tevmSetAccount
tevmSetAccount:
TevmActionsApi
["setAccount"
]
Sets any property of an account including its balance, nonce, contract deployedBytecode, contract state, and more.
See
- SetAccountParams for options reference.
- SetAccountResult for return values reference.