AnvilLaunch
Documentation for eth_defi.provider.anvil.AnvilLaunch Python class.
- class AnvilLaunch
Bases:
objectControl Anvil processes launched on background.
Comes with a helpful
close()method when it is time to put Anvil rest.The
chain_id,upstream_rpc_urls,fork_block_numberandeffective_fork_urlfields are the canonical launch metadata exposed to callers. The module-level metadata registry mirrors these values only so that latercreate_multi_provider_web3(launch.json_rpc_url)calls can attach the same context to retry diagnostics.Attributes summary
Chain id reported by the local Anvil instance after startup.
URL passed to Anvil as
--fork-url.Explicit fork block used for Anvil, if any.
Optional JSON-RPC failover proxy sitting between Anvil and upstream RPCs.
Original upstream RPC URLs passed to Anvil fork mode.
Which port was bound by the Anvil
Used command-line to spin up anvil
Where does Anvil listen to JSON-RPC
UNIX process that we opened
Methods summary
__init__(port, cmd, json_rpc_url, process[, ...])close([log_level, block, block_timeout])Close the background Anvil process.
- port: int
Which port was bound by the Anvil
- json_rpc_url: str
Where does Anvil listen to JSON-RPC
- process: psutil.Popen
UNIX process that we opened
- chain_id: Optional[int] = None
Chain id reported by the local Anvil instance after startup.
- fork_block_number: Optional[int] = None
Explicit fork block used for Anvil, if any.
- effective_fork_url: Optional[str] = None
URL passed to Anvil as
--fork-url.
- proxy: RPCProxy | None = None
Optional JSON-RPC failover proxy sitting between Anvil and upstream RPCs. Automatically started by
launch_anvil()when multiple RPCs are configured in space-separatedfork_urlandproxy_multiple_upstreamis notFalse. Seeeth_defi.provider.rpc_proxy.
- close(log_level=None, block=True, block_timeout=30)
Close the background Anvil process.
If this instance owns the
RPCProxy(i.e. it was auto-created, not passed in by the caller), the proxy is shut down after Anvil exits and its per-provider statistics are logged. Port-lease release runs from nestedfinallyblocks, so a shutdown or managed-proxy cleanup error cannot strand the lease until the Python worker exits.
- __init__(port, cmd, json_rpc_url, process, chain_id=None, upstream_rpc_urls=(), fork_block_number=None, effective_fork_url=None, proxy=None, _proxy_managed=True, _port_lease=None)