Skip to main content

Foundry Anvil Testcontainers

Real anvil nodes for Node.js tests: every flag type-safe and validated, with a pre-configured viem test client.

codecov
pnpm add -D @hellaweb3/foundryanvil-testcontainers-nodejs

What do you want to do?

Start a node per test file

useAnvil: start, deploy fixtures once, reset after every test.

Fast-forward time

Jump days ahead, hit exact timestamps, simulate block times.

Act as a whale

Impersonate any address and fund it with Ether and ERC-20s.

Assert custom errors

Decoded reverts from simulations, estimations and receipts.

Fork mainnet

Pin a block, change anything locally, reset back.

Mock a dependency

Etch code and write storage at any address.

Control block building

Several transactions per block, fee ordering, the mempool.

Watch events

WebSocket subscriptions, filters and typed logs.

Configure the chain

Chain id, hardfork, gas, base fee, OP Stack, Celo.

Trace a failed transaction

Call traces, opcode traces and anvil's logs.

Save and load chain state

Build a fixture once, boot other nodes from the file.

Run without Docker

Plug in a local anvil binary for fast local loops.

Every code sample on this site is copied from an example that runs against a real anvil node in CI. How the docs are tested