alloy_provider::ext

Trait AnvilApi

Source
pub trait AnvilApi<N: Network, T>: Send + Sync {
Show 37 methods // Required methods fn anvil_impersonate_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_stop_impersonating_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_auto_impersonate_account<'life0, 'async_trait>( &'life0 self, enabled: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_get_auto_mine<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_auto_mine<'life0, 'async_trait>( &'life0 self, enable_automine: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_mine<'life0, 'async_trait>( &'life0 self, num_blocks: Option<U256>, interval: Option<U256>, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_interval_mining<'life0, 'async_trait>( &'life0 self, secs: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_drop_transaction<'life0, 'async_trait>( &'life0 self, tx_hash: TxHash, ) -> Pin<Box<dyn Future<Output = TransportResult<Option<TxHash>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_drop_all_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_reset<'life0, 'async_trait>( &'life0 self, forking: Option<Forking>, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_chain_id<'life0, 'async_trait>( &'life0 self, chain_id: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_balance<'life0, 'async_trait>( &'life0 self, address: Address, balance: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_code<'life0, 'async_trait>( &'life0 self, address: Address, code: Bytes, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_nonce<'life0, 'async_trait>( &'life0 self, address: Address, nonce: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_storage_at<'life0, 'async_trait>( &'life0 self, address: Address, slot: U256, val: B256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_logging<'life0, 'async_trait>( &'life0 self, enable: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_min_gas_price<'life0, 'async_trait>( &'life0 self, gas: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_next_block_base_fee_per_gas<'life0, 'async_trait>( &'life0 self, basefee: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_coinbase<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_dump_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<Bytes>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_load_state<'life0, 'async_trait>( &'life0 self, buf: Bytes, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_node_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<NodeInfo>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<Metadata>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_remove_pool_transactions<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<U256>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_revert<'life0, 'async_trait>( &'life0 self, id: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_increase_time<'life0, 'async_trait>( &'life0 self, seconds: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<i64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_next_block_timestamp<'life0, 'async_trait>( &'life0 self, timestamp: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_time<'life0, 'async_trait>( &'life0 self, timestamp: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_block_gas_limit<'life0, 'async_trait>( &'life0 self, gas_limit: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, seconds: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_remove_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn evm_mine<'life0, 'async_trait>( &'life0 self, opts: Option<MineOptions>, ) -> Pin<Box<dyn Future<Output = TransportResult<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_mine_detailed<'life0, 'async_trait>( &'life0 self, opts: Option<MineOptions>, ) -> Pin<Box<dyn Future<Output = TransportResult<Vec<Block>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_set_rpc_url<'life0, 'async_trait>( &'life0 self, url: String, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_reorg<'life0, 'async_trait>( &'life0 self, options: ReorgOptions, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn eth_send_unsigned_transaction<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = TransportResult<TxHash>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Available on crate feature anvil-api only.
Expand description

Anvil namespace rpc interface that gives access to several non-standard RPC methods.

Required Methods§

Source

fn anvil_impersonate_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send transactions impersonating specific account and contract addresses.

Source

fn anvil_stop_impersonating_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stops impersonating an account if previously set with anvil_impersonateAccount.

Source

fn anvil_auto_impersonate_account<'life0, 'async_trait>( &'life0 self, enabled: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

If set to true will make every account impersonated.

Source

fn anvil_get_auto_mine<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns true if auto mining is enabled, and false.

Source

fn anvil_set_auto_mine<'life0, 'async_trait>( &'life0 self, enable_automine: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enables or disables, based on the single boolean argument, the automatic mining of new blocks with each new transaction submitted to the network.

Source

fn anvil_mine<'life0, 'async_trait>( &'life0 self, num_blocks: Option<U256>, interval: Option<U256>, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mines a series of blocks.

Source

fn anvil_set_interval_mining<'life0, 'async_trait>( &'life0 self, secs: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the mining behavior to interval with the given interval (seconds).

Source

fn anvil_drop_transaction<'life0, 'async_trait>( &'life0 self, tx_hash: TxHash, ) -> Pin<Box<dyn Future<Output = TransportResult<Option<TxHash>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes transactions from the pool.

Source

fn anvil_drop_all_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes all transactions from the pool.

Source

fn anvil_reset<'life0, 'async_trait>( &'life0 self, forking: Option<Forking>, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reset the fork to a fresh forked state, and optionally update the fork config.

If forking is None then this will disable forking entirely.

Source

fn anvil_set_chain_id<'life0, 'async_trait>( &'life0 self, chain_id: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the chain ID.

Source

fn anvil_set_balance<'life0, 'async_trait>( &'life0 self, address: Address, balance: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Modifies the balance of an account.

Source

fn anvil_set_code<'life0, 'async_trait>( &'life0 self, address: Address, code: Bytes, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the code of a contract.

Source

fn anvil_set_nonce<'life0, 'async_trait>( &'life0 self, address: Address, nonce: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the nonce of an address.

Source

fn anvil_set_storage_at<'life0, 'async_trait>( &'life0 self, address: Address, slot: U256, val: B256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Writes a single slot of the account’s storage.

Source

fn anvil_set_logging<'life0, 'async_trait>( &'life0 self, enable: bool, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable or disable logging.

Source

fn anvil_set_min_gas_price<'life0, 'async_trait>( &'life0 self, gas: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the minimum gas price for the node.

Source

fn anvil_set_next_block_base_fee_per_gas<'life0, 'async_trait>( &'life0 self, basefee: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the base fee of the next block.

Source

fn anvil_set_coinbase<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the coinbase address.

Source

fn anvil_dump_state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a buffer that represents all state on the chain, which can be loaded to separate process by calling anvil_loadState

Source

fn anvil_load_state<'life0, 'async_trait>( &'life0 self, buf: Bytes, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append chain state buffer to current chain. Will overwrite any conflicting addresses or storage.

Source

fn anvil_node_info<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<NodeInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves the Anvil node configuration params.

Source

fn anvil_metadata<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<Metadata>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieves metadata about the Anvil instance.

Source

fn anvil_remove_pool_transactions<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes all transactions from the pool for a specific address.

Source

fn anvil_snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<U256>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Snapshot the state of the blockchain at the current block.

Source

fn anvil_revert<'life0, 'async_trait>( &'life0 self, id: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to.

Source

fn anvil_increase_time<'life0, 'async_trait>( &'life0 self, seconds: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<i64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Jump forward in time by the given amount of time, in seconds.

Source

fn anvil_set_next_block_timestamp<'life0, 'async_trait>( &'life0 self, timestamp: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Similar to evm_increaseTime but takes the exact timestamp that you want in the next block.

Source

fn anvil_set_time<'life0, 'async_trait>( &'life0 self, timestamp: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the specific timestamp and returns the number of seconds between the given timestamp and the current time.

Source

fn anvil_set_block_gas_limit<'life0, 'async_trait>( &'life0 self, gas_limit: U256, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the next block gas limit.

Source

fn anvil_set_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, seconds: u64, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets an interval for the block timestamp.

Source

fn anvil_remove_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Unsets the interval for the block timestamp.

Source

fn evm_mine<'life0, 'async_trait>( &'life0 self, opts: Option<MineOptions>, ) -> Pin<Box<dyn Future<Output = TransportResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mine blocks, instantly. This will mine the blocks regardless of the configured mining mode.

Source

fn anvil_mine_detailed<'life0, 'async_trait>( &'life0 self, opts: Option<MineOptions>, ) -> Pin<Box<dyn Future<Output = TransportResult<Vec<Block>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mine blocks, instantly and return the mined blocks. This will mine the blocks regardless of the configured mining mode.

Source

fn anvil_set_rpc_url<'life0, 'async_trait>( &'life0 self, url: String, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the backend rpc url.

Source

fn anvil_reorg<'life0, 'async_trait>( &'life0 self, options: ReorgOptions, ) -> Pin<Box<dyn Future<Output = TransportResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reorg the chain

Source

fn eth_send_unsigned_transaction<'life0, 'async_trait>( &'life0 self, request: N::TransactionRequest, ) -> Pin<Box<dyn Future<Output = TransportResult<TxHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute a transaction regardless of signature status.

Implementors§

Source§

impl<N, T, P> AnvilApi<N, T> for P
where N: Network, T: Transport + Clone, P: Provider<T, N>,