Documentation
¶
Index ¶
- type Client
- func (c *Client) DumpState() ([]byte, error)
- func (c *Client) LoadState(state string) error
- func (c *Client) NodeInfo() (*NodeInfo, error)
- func (c *Client) Reset(forkURL string, block *big.Int) error
- func (c *Client) SetBalance(account common.Address, balance *big.Int) error
- func (c *Client) SetChainId(id uint64) error
- func (c *Client) SetCode(account common.Address, code []byte) error
- func (c *Client) SetCoinbase(addr common.Address) error
- func (c *Client) SetLoggingEnabled(enable bool) error
- func (c *Client) SetMinGasPrice(price *big.Int) error
- func (c *Client) SetNextBlockBaseFeePerGas(fee *big.Int) error
- func (c *Client) SetNonce(account common.Address, nonce uint64) error
- func (c *Client) SetStorageAt(account common.Address, slot common.Hash, value []byte) error
- type Node
- type NodeInfo
- type Option
- func WithAllowOrigin(origin string) Option
- func WithBalance(balance *big.Int) Option
- func WithBaseFee(fee int) Option
- func WithBlockBaseFeePerGas(fee int) Option
- func WithBlockTime(seconds int) Option
- func WithChainID(id int) Option
- func WithCodeSizeLimit(limit int) Option
- func WithComputeUnitsPerSecond(cups int) Option
- func WithConfigOut(path string) Option
- func WithDerivationPath(path string) Option
- func WithDisableDefaultCreate2Deployer() Option
- func WithForkBlockNumber(block *big.Int) Option
- func WithForkRetryBackoff(backoff int) Option
- func WithForkTransactionHash(tx string) Option
- func WithForkURL(url string) Option
- func WithGasLimit(limit int) Option
- func WithGasPrice(price int) Option
- func WithHardfork(name string) Option
- func WithHelp() Option
- func WithHost(host string) Option
- func WithIPC(path string) Option
- func WithInit(path string) Option
- func WithMnemonic(mnemonic string) Option
- func WithNoCORS() Option
- func WithNoMining() Option
- func WithNoRateLimit() Option
- func WithNoRequestSizeLimit() Option
- func WithNoStorageCaching() Option
- func WithOrder(order string) Option
- func WithPort(port int) Option
- func WithPruneHistory() Option
- func WithRetries(count int) Option
- func WithSilent() Option
- func WithStepsTracing() Option
- func WithTimeout(ms int) Option
- func WithTimestamp(ts int64) Option
- func WithVersion() Option
- type Wallet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an RPC client for anvil specific functions
func (*Client) DumpState ¶
DumpState returns a hex-encoded snapshot of the entire chain state.
Equivalent to the `anvil_dumpState` RPC call.
func (*Client) LoadState ¶
LoadState merges a previously dumped state into the current chain state.
Equivalent to the `anvil_loadState` RPC call.
func (*Client) NodeInfo ¶
NodeInfo retrieves the current node configuration parameters.
Equivalent to the `anvil_nodeInfo` RPC call.
func (*Client) Reset ¶
Reset resets the node state to the original or a new forked state.
Equivalent to the `anvil_reset` RPC call.
func (*Client) SetBalance ¶
SetBalance sets the balance of a given account.
Equivalent to the `anvil_setBalance` RPC call.
func (*Client) SetChainId ¶
SetChainId sets the chain ID of the node.
Equivalent to the `anvil_setChainId` RPC call.
func (*Client) SetCode ¶
SetCode sets the EVM bytecode at the specified account.
Equivalent to the `anvil_setCode` RPC call.
func (*Client) SetCoinbase ¶
SetCoinbase sets the coinbase address for block rewards.
Equivalent to the `anvil_setCoinbase` RPC call.
func (*Client) SetLoggingEnabled ¶
SetLoggingEnabled enables or disables logging output.
Equivalent to the `anvil_setLoggingEnabled` RPC call.
func (*Client) SetMinGasPrice ¶
SetMinGasPrice sets the minimum gas price for the node.
Equivalent to the `anvil_setMinGasPrice` RPC call.
func (*Client) SetNextBlockBaseFeePerGas ¶
SetNextBlockBaseFeePerGas sets the base fee for the next block.
Equivalent to the `anvil_setNextBlockBaseFeePerGas` RPC call.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents an active Anvil client
type Option ¶
type Option []string
An Option configures a Node
func WithAllowOrigin ¶
WithAllowOrigin sets the CORS allowed origin.
Equivalent to the `--allow-origin <ALLOW-ORIGIN>` flag
func WithBalance ¶
WithBalance sets the initial balance of accounts.
Equivalent to the `--balance <BALANCE>` flag
func WithBaseFee ¶
WithBaseFee sets the base fee in a block.
Equivalent to the `--base-fee <FEE>` flag
func WithBlockBaseFeePerGas ¶
WithBlockBaseFeePerGas sets the block base fee per gas.
Equivalent to the `--block-base-fee-per-gas <FEE>` flag
func WithBlockTime ¶
WithBlockTime sets the block time in seconds for interval mining.
Equivalent to the `-b, --block-time <BLOCK-TIME>` flag
func WithCodeSizeLimit ¶
WithCodeSizeLimit sets the EIP-170 code size limit in bytes.
Equivalent to the `--code-size-limit <CODE_SIZE>` flag
func WithComputeUnitsPerSecond ¶
WithComputeUnitsPerSecond sets the assumed compute units per second.
Equivalent to the `--compute-units-per-second <CUPS>` flag
func WithConfigOut ¶
WithConfigOut writes the Anvil output to a given file as JSON.
Equivalent to the `--config-out <OUT_FILE>` flag
func WithDerivationPath ¶
WithDerivationPath sets the derivation path for HD wallets.
Equivalent to the `--derivation-path <DERIVATION_PATH>` flag
func WithDisableDefaultCreate2Deployer ¶
func WithDisableDefaultCreate2Deployer() Option
WithDisableDefaultCreate2Deployer disables the default CREATE2 factory.
Equivalent to the `--disable-default-create2-deployer` flag
func WithForkBlockNumber ¶
WithForkBlockNumber forks from a specific block number.
Equivalent to the `--fork-block-number <BLOCK>` flag
func WithForkRetryBackoff ¶
WithForkRetryBackoff sets initial retry backoff on fork errors.
Equivalent to the `--fork-retry-backoff <BACKOFF>` flag
func WithForkTransactionHash ¶
WithForkTransactionHash forks state from a specific transaction hash.
Equivalent to the `--fork-transaction-hash <TRANSACTION>` flag
func WithForkURL ¶
WithForkURL enables state forking from a remote endpoint.
Equivalent to the `-f, --fork-url <URL>` flag
func WithGasLimit ¶
WithGasLimit sets the block gas limit.
Equivalent to the `--gas-limit <GAS_LIMIT>` flag
func WithGasPrice ¶
WithGasPrice sets the gas price.
Equivalent to the `--gas-price <GAS_PRICE>` flag
func WithHardfork ¶
WithHardfork sets the EVM hardfork to use.
Equivalent to the `--hardfork <HARDFORK>` flag
func WithHelp ¶
func WithHelp() Option
WithHelp prints help information.
Equivalent to the `-h, --help` flag
func WithIPC ¶
WithIPC starts an IPC endpoint at a given path (optional).
Equivalent to the `--ipc [<PATH>]` flag
func WithInit ¶
WithInit initializes the genesis block using a genesis.json file.
Equivalent to the `--init <PATH>` flag
func WithMnemonic ¶
WithMnemonic sets the BIP39 mnemonic phrase for generating accounts.
Equivalent to the `-m, --mnemonic <MNEMONIC>` flag
func WithNoCORS ¶
func WithNoCORS() Option
WithNoCORS disables CORS support.
Equivalent to the `--no-cors` flag
func WithNoMining ¶
func WithNoMining() Option
WithNoMining disables auto and interval mining.
Equivalent to the `--no-mining` flag
func WithNoRateLimit ¶
func WithNoRateLimit() Option
WithNoRateLimit disables rate limiting for the node’s provider.
Equivalent to the `--no-rate-limit` flag
func WithNoRequestSizeLimit ¶
func WithNoRequestSizeLimit() Option
WithNoRequestSizeLimit disables the default request size limit (2MB).
Equivalent to the `--no-request-size-limit` flag
func WithNoStorageCaching ¶
func WithNoStorageCaching() Option
WithNoStorageCaching disables RPC storage slot caching.
Equivalent to the `--no-storage-caching` flag
func WithOrder ¶
WithOrder sets the transaction ordering strategy in the mempool.
Equivalent to the `--order <ORDER>` flag
func WithPruneHistory ¶
func WithPruneHistory() Option
WithPruneHistory disables full chain history retention.
Equivalent to the `--prune-history` flag
func WithRetries ¶
WithRetries sets the number of retry attempts for network issues.
Equivalent to the `--retries <RETRIES>` flag
func WithSilent ¶
func WithSilent() Option
WithSilent disables all startup logs.
Equivalent to the `--silent` flag
func WithStepsTracing ¶
func WithStepsTracing() Option
WithStepsTracing enables steps tracing for geth-style traces.
Equivalent to the `--steps-tracing` flag (alias: `--tracing`)
func WithTimeout ¶
WithTimeout sets the request timeout for forking mode in ms.
Equivalent to the `--timeout <TIMEOUT>` flag
func WithTimestamp ¶
WithTimestamp sets the timestamp of the genesis block.
Equivalent to the `--timestamp <TIMESTAMP>` flag
func WithVersion ¶
func WithVersion() Option
WithVersion prints version information.
Equivalent to the `-V, --version` flag