Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

@tevm/vm

High-performance EVM implementation for Tevm. Handles bytecode execution, transaction processing, block building, and state transitions across supported hardforks and EIPs.

Installation

npm install @tevm/vm

API Reference

Core Types

  • Vm - core VM type.

Block Building

Transaction Processing

Block Processing

Events

Core Functions

Usage Examples

import { createVm } from '@tevm/vm'
import { Common } from '@tevm/common'
 
const common = new Common({ chain: 'mainnet' })
const vm = createVm({ common })
 
const blockBuilder = await vm.buildBlock({
  parentBlock: block,
  blockOpts: { /* options */ },
})
await blockBuilder.addTransaction(tx)
const built = await blockBuilder.build()
 
const blockResult = await vm.runBlock({ block: built })
 
const txResult = await vm.runTx({ tx })
console.log(txResult.gasUsed.toString(), txResult.execResult.returnValue)

Configuration

const vm = createVm({
  common,
  stateManager,
  blockchain,
  activatePrecompiles: true,
})

Related Packages