Documentation for eth_defi.provider.anvil Python module.

Anvil integration.

This module provides Python integration for Anvil.

  • Anvil is a blazing-fast local testnet node implementation in Rust from Foundry project

  • Anvil can replace eth_tester.main.EthereumTester as the unit/integration test backend.

  • Anvil is mostly used in mainnet fork test cases.

  • Anvil is a more stable an alternative to Ganache (eth_defi.ganache)

  • Anvil is part of Foundry, a toolkit for Ethereum application development.

To install Anvil on:

curl -L | bash
foundryup  # Needs to be in path, or installation fails

This will install foundryup, anvil at ~/.foundry/bin and adds the folder to your shell rc file PATH.

For more information see Anvil reference.

See also eth_defi.trace for Solidity tracebacks using Anvil.

The code was originally lifted from Brownie project.

Module Attributes


Mappings between Anvil command line parameters and our internal argument names



Call evm_snapshot on Anvil

fork_network_anvil([fork_url, ...])

Creates Anvil unit test backend or mainnet fork.

launch_anvil([fork_url, unlocked_addresses, ...])

Creates Anvil unit test backend or mainnet fork.

load_state(web3, state)

Call evm_snapshot on Anvil

make_anvil_custom_rpc_request(web3, method)

Make a request to special named EVM JSON-RPC endpoint.

mine(web3[, timestamp])

Call evm_setNextBlockTimestamp on Anvil

revert(web3, snapshot_id)

Call evm_revert on Anvil

sleep(web3, seconds)

Call emv_increaseTime on Anvil


Call evm_snapshot on Anvil

unlock_account(web3, address)

Make Anvil mainnet fork to accept transactions to any Ethereum account.



Control Anvil processes launched on background.



Lifted from Brownie.


Lifted from Brownie.