provider.anvil

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 https://foundry.paradigm.xyz | bash
PATH=~/.foundry/bin:$PATH
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

CLI_FLAGS

Mappings between Anvil command line parameters and our internal argument names

Functions

dump_state(web3)

Call evm_snapshot on Anvil

fork_network_anvil([fork_url, ...])

Creates Anvil unit test backend or mainnet fork.

is_anvil(web3)

Are we connected to Anvil node.

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

snapshot(web3)

Call evm_snapshot on Anvil

unlock_account(web3, address)

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

Classes

AnvilLaunch

Control Anvil processes launched on background.

Exceptions

InvalidArgumentWarning

Lifted from Brownie.

RPCRequestError

Lifted from Brownie.