Getting started
Install
@tevm/ethers is published to npm as @tevm/ethers.
ethers, tevm, and viem are peer dependencies so your application picks the versions.
Supported ranges
| Peer dependency | Supported range | Notes |
|---|---|---|
ethers | >=6.0.0 <7 | ethers v6 only. v5 is not supported. |
tevm | >=1.0.0 | The current release line is 1.0.0-rc.x. |
viem | >=2.37.9 <=2.46.0 | Pinned upper bound: current Tevm packages reference chain definitions removed after viem 2.46.0. |
Node 24 or newer is recommended; the package is ESM-first and also ships a CommonJS build.
Your first provider
import { } from '@tevm/ethers'
const = await .createMemoryProvider({
: { : 'auto' },
})
const = await .send('eth_chainId', [])
const = await .getBlockNumber()
.({ , }) // { chainId: '0x384', blockNumber: 0 }createMemoryProvider creates a fresh in-memory Tevm node and wraps it in an ethers provider. The
default chain id is 900 (0x384), the Tevm default devnet chain.
Reading a balance and sending a transaction
Tevm ships prefunded accounts, so you can sign and send a real transaction immediately.
import { } from '@tevm/ethers'
import { } from '@tevm/utils'
import { , , } from 'ethers'
const = await .createMemoryProvider({
: { : 'auto' },
})
const = new ([0], )
const = `0x${'42'.(20)}`
.((await .getBalance(.))) // '1000.0'
const = await .({ : , : ('1') })
const = await .()
.(?.) // 1
.((await .getBalance())) // '1.0'With miningConfig: { type: 'auto' } a block is mined for every transaction, so tx.wait()
resolves without any extra step. Without it, mine manually with await provider.tevm.mine() or
await provider.send('tevm_mine', [{ blockCount: 1 }]).
Reusing an existing Tevm node
If you already created a Tevm node, pass it straight to the constructor rather than creating a
second EVM. The node must be extended with tevmActions() and tevmSend() — that is exactly what
createMemoryProvider does internally.
import { } from '@tevm/ethers'
import { , } from '@tevm/decorators'
import { } from '@tevm/node'
const = ().(()).(())
const = new ()
.(await .getBlockNumber()) // 0A viem MemoryClient from tevm exposes its node at client.transport.tevm, so you can share one
EVM between viem and ethers:
import { } from '@tevm/ethers'
import { , } from '@tevm/decorators'
import { } from 'tevm'
const = ()
await .()
const = new (...(()).(()))
.(await .getBlockNumber()) // 0
