--- title: EVM description: ZEVM-backed EVM facade used by Tevm VM, TevmNode, and MemoryClient --- # @tevm/evm Tevm's low-level EVM facade. Backed by `@evmts/zevm/evm` and wrapped with Tevm-specific defaults for state, blockchain, precompiles, predeploys, logging, profiling, and unlimited-contract-size testing. Most apps should use `createMemoryClient`, viem actions, or JSON-RPC. Use `@tevm/evm` directly when building Tevm extensions, debuggers, or profilers. Full API: [packages/evm/docs](https://github.com/evmts/tevm/tree/main/packages/evm/docs). ## Installation ```bash npm install @tevm/evm@1.0.0-rc.151 viem ``` ## API Reference - [Evm](https://github.com/evmts/tevm/tree/main/packages/evm/docs/classes/Evm.md) - EVM facade. - [createEvm](https://github.com/evmts/tevm/tree/main/packages/evm/docs/functions/createEvm.md) - creates an EVM for a Tevm VM. - [CreateEvmOptions](https://github.com/evmts/tevm/tree/main/packages/evm/docs/type-aliases/CreateEvmOptions.md) - [CustomPrecompile](https://github.com/evmts/tevm/tree/main/packages/evm/docs/type-aliases/CustomPrecompile.md) - [EVMOpts](https://github.com/evmts/tevm/tree/main/packages/evm/docs/type-aliases/EVMOpts.md) - ZEVM EVM options exposed through Tevm. - Re-exported ZEVM EVM types: `EvmError`, `EVMError`, `EvmResult`, `EvmRunCallOpts`, `ExecResult`, `InterpreterStep`, `Log`, `EthjsMessage`, `PrecompileInput`. ## Usage Examples ```typescript import { createChain } from '@tevm/blockchain' import { mainnet } from '@tevm/common' import { createEvm } from '@tevm/evm' import { createStateManager } from '@tevm/state' import { createAddress } from '@tevm/address' const common = mainnet.copy() const stateManager = createStateManager({}) const blockchain = await createChain({ common }) const evm = await createEvm({ common, stateManager, blockchain, profiler: false, loggingLevel: 'warn', }) const result = await evm.runCall({ to: createAddress('0x1234567890123456789012345678901234567890'), caller: createAddress('0x5678901234567890123456789012345678901234'), data: new Uint8Array(), value: 1000n, gasLimit: 100000n, }) evm.events?.on('step', (step) => { console.log({ pc: step.pc, opcode: step.opcode.name, gasLeft: step.gasLeft, depth: step.depth }) }) ``` ### Custom Precompiles ```typescript import { createContract, createMemoryClient, defineCall, definePrecompile, parseAbi } from 'tevm' const Calculator = createContract({ name: 'Calculator', address: '0x0000000000000000000000000000000000000a11', abi: parseAbi(['function addTwo(uint256 value) returns (uint256)']), }) const calculatorPrecompile = definePrecompile({ contract: Calculator, call: defineCall(Calculator.abi, { addTwo: async ({ args }) => ({ returnValue: args[0] + 2n, executionGasUsed: 0n }), }), }) const client = createMemoryClient({ customPrecompiles: [calculatorPrecompile.precompile()], }) ``` ## See Also - [VM & Submodules](../api/vm-and-submodules) - [EVM Events](../api/evm-events) - [Custom Precompiles](../advanced/custom-precompiles) - [@tevm/state](https://tevm.sh/reference/tevm/state/) - [Full API Reference](https://github.com/evmts/tevm/tree/main/packages/evm/docs/globals.md)