Skip to main content

Introduction

A Foundry Anvil node in Docker per test file, with a viem test client already bound to it.

  • Every anvil flag, validated as you set it.
  • One client for everything: viem's test, public and wallet actions, anvil extras and fluent cheats.
  • Per-test isolation in milliseconds with snapshots.

New here? Start with the quick start.

Find your task​

I want to…Go to
Start a node per test file and reset it between testsShare a node, Isolate tests
Use, fund or impersonate accountsAccounts and signing
Send transactions, assert reverts, simulateTransactions and contracts
Move time, control mining and block contentsTime and blocks
Mock contracts, save or load state, boot from genesisState and mocks
Test against mainnet stateForking
React to eventsEvents
Configure the chain, EVM, RPC server, logs or clientConfigure the node
Find out why something failedDebug
Look up a method, flag or errorReference
Understand how it worksConcepts

How to read the samples​

Every sample is a tested #region of examples/, linked under the sample.

  • anvil (or node, fork…) is a started node, usually from useAnvil().
  • expect and it are Jest's; any runner works.
  • deployToken, mint, balanceOf, exampleToken, expectRevert and triggerUntil are helpers from examples/src.