Virtual Machine
@tevm/vm coordinates the EVM, state manager, blockchain, block building, and transaction execution. Most applications should use createMemoryClient; direct VM access is intended for runtime integrations.
Access the Configured VM
import { createTevmNode } from 'tevm'
import { createAddress } from 'tevm/address'
import { createImpersonatedTx } from 'tevm/tx'
const node = createTevmNode()
const vm = await node.getVm()
const tx = createImpersonatedTx({
impersonatedAddress: createAddress(
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
),
to: createAddress('0x1111111111111111111111111111111111111111'),
value: 1n,
gasLimit: 21_000n,
maxFeePerGas: 10n,
maxPriorityFeePerGas: 1n,
})
const result = await vm.runTx({ tx })
console.log(result.totalGasSpent, result.execResult.returnValue)The node constructs compatible common, stateManager, blockchain, evm, txpool, and receipt components. Prefer this over assembling a partial VM unless you are implementing a custom runtime.
Important VM Methods
runTxexecutes a typed transaction.runBlockexecutes and validates a block.buildBlockcreates a block builder.deepCopycreates an isolated runtime copy.stateManager,blockchain, andevmexpose the configured subcomponents.
Direct execution follows checkpoint and hardfork rules. For simulations with Tevm error handling, tracing, overrides, and ABI decoding, use client.tevmCall or client.tevmContract.
Related
TevmNode Interface · EVM · State · Blockchain

