Anvil requires a local installation to work with Anvil. It is also not possible to manage from nodejs. Anvild solves all these problems:
- does not require local installation of Anvil
- easy to use interface from Nodejs
- good type support
To install Anvil Docker Manager, follow these steps:
-
Ensure you have Node.js and Docker installed.
-
Install
anvild
using npm/yarn/pnpm
yarn add anvild
- Create Anvil node using Nodejs
import { cleanAll, createAnvil } from "anvild";
(async () => {
// clean all Anvil instances
await cleanAll();
// run anvil node with default config
const node = await createAnvil({});
})();
- https://github.com/wagmi-dev/anvil.js — nodejs wrapper for Anvil. Depends on local Anvil installation.
- Type:
number
- Default:
350
- Description: Sets the number of assumed available compute units per second for this fork provider.
- Type:
string
- Description: Fetch state over a remote endpoint instead of starting from an empty state. If you want to fetch state from a specific block number, add a block number like
http://localhost:8545@1400000
or use theforkBlockNumber
option.
- Type:
number
orbigint
- Description: Fetch state from a specific block number over a remote endpoint. Requires
forkUrl
to be set.
- Type:
number
- Description: Specify chain id to skip fetching it from the remote endpoint. This enables offline-start mode. You still must pass both
forkUrl
andforkBlockNumber
, and already have your required state cached on disk, anything missing locally would be fetched from the remote.
- Type:
number
- Description: Initial retry backoff on encountering errors.
- Type:
boolean
- Default:
false
- Description: Disables rate limiting for this node's provider. See here.
- Type:
boolean
- Description: Explicitly disables the use of RPC caching. All storage slots are read entirely from the endpoint.
- Type:
number
- Default:
5
- Description: Number of retry requests for spurious networks (timed out requests).
- Type:
number
- Default:
45000
- Description: Timeout in ms for requests sent to remote JSON-RPC server in forking mode.
- Type:
bigint
- Description: The base fee in a block.
- Type:
number
- Description: The chain id.
- Type:
number
- Default:
0x6000
(~25kb) - Description: EIP-170: Contract code size limit in bytes. Useful to increase this because of tests.
- Type:
boolean
- Description: Disable the
call.gas_limit <= block.gas_limit
constraint.
- Type:
bigint
- Description: The block gas limit.
- Type:
bigint
- Description: The gas price.
- Type:
number
- Default:
10
- Description: Number of dev accounts to generate and configure.
- Type:
bigint
- Default:
10000
- Description: The balance of every dev account in Ether.
- Type:
string
- Default:
m/44'/60'/0'/0/
- Description: Sets the derivation path of the child key to be derived.
- Type:
string
- Description: BIP39 mnemonic phrase used for generating accounts.
- Type:
number
- Default:
8545
- Description: Port number to listen on.
- Type:
boolean
- Description: Enable steps tracing used for debug calls returning geth-style traces.
- Type:
bigint
- Description: The timestamp of the genesis block.
- Type:
string
- Default:
*
- Description: Set the Access-Control-Allow-Origin response header (CORS).
- Type:
number
- Description: Block time in seconds for interval mining.
- Type:
string
- Description: Writes output of
anvil
as JSON to user-specified file.
- Type:
string
- Description: Dump the state of the chain on exit to the given file. If the value is a directory, the state will be written to
<VALUE>/state.json
.
- Type:
enum
(chainstart
,berlin
,london
) - Description: The EVM hardfork to use.
- Type:
string
- Default:
0.0.0.0
- Description: The host the server will listen on.
- Type:
string
- Description: Initialize the genesis block with the given
genesis.json
file.
- Type:
string
- Description: Launch an IPC server at the given path or default path =
/tmp/anvil.ipc
.
- Type:
string
- Description: Initialize the chain from a previously saved state snapshot.
- Type:
boolean
- Description: Disable CORS.
- Type:
boolean
- Description: Disable auto and interval mining, and mine on demand instead.
- Type:
string
- Default:
fees
- Description: How transactions are sorted in the mempool.
- Type:
number
orboolean
- Description: Don't keep full chain history.
- Type:
number
- Description: Interval in seconds at which the status is to be dumped to disk.
- Type:
boolean
- Description: Don't print anything on startup and don't print logs.
- Type:
string
- Description: This is an alias for both
loadState
anddumpState
.
- Type:
number
- Description: Number of blocks with transactions to keep in memory.
- Type:
string
- Description: Docker socket path.
- Type:
boolean
- Default:
true
- Description: Attach Anvil logs to the current process.
- Type:
boolean
- Default:
true
- Description: Force re-create the instance with the same configuration.