Trait AnvilNamespaceServer

Source
pub trait AnvilNamespaceServer:
    Sized
    + Send
    + Sync
    + 'static {
Show 31 methods // Required methods fn dump_state<'life0, 'async_trait>( &'life0 self, preserve_historical_states: Option<bool>, ) -> Pin<Box<dyn Future<Output = RpcResult<Bytes>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn load_state<'life0, 'async_trait>( &'life0 self, bytes: Bytes, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn mine_detailed<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<Block<DetailedTransaction>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_rpc_url<'life0, 'async_trait>( &'life0 self, url: String, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_next_block_base_fee_per_gas<'life0, 'async_trait>( &'life0 self, base_fee: U256, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn drop_transaction<'life0, 'async_trait>( &'life0 self, hash: H256, ) -> Pin<Box<dyn Future<Output = RpcResult<Option<H256>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn drop_all_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_pool_transactions<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_auto_mine<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_auto_mine<'life0, 'async_trait>( &'life0 self, enable: bool, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_interval_mining<'life0, 'async_trait>( &'life0 self, seconds: u64, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, seconds: u64, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn remove_block_timestamp_interval<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_min_gas_price<'life0, 'async_trait>( &'life0 self, gas: U256, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_logging_enabled<'life0, 'async_trait>( &'life0 self, enable: bool, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn snapshot<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<U64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn revert<'life0, 'async_trait>( &'life0 self, id: U64, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_time<'life0, 'async_trait>( &'life0 self, timestamp: Numeric, ) -> Pin<Box<dyn Future<Output = RpcResult<i128>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn increase_time<'life0, 'async_trait>( &'life0 self, seconds: Numeric, ) -> Pin<Box<dyn Future<Output = RpcResult<u64>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_next_block_timestamp<'life0, 'async_trait>( &'life0 self, timestamp: Numeric, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn auto_impersonate_account<'life0, 'async_trait>( &'life0 self, enabled: bool, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_balance<'life0, 'async_trait>( &'life0 self, address: Address, balance: U256, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_nonce<'life0, 'async_trait>( &'life0 self, address: Address, nonce: U256, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn anvil_mine<'life0, 'async_trait>( &'life0 self, num_blocks: Option<U64>, interval: Option<U64>, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn reset_network<'life0, 'async_trait>( &'life0 self, reset_spec: Option<ResetRequest>, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn impersonate_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn stop_impersonating_account<'life0, 'async_trait>( &'life0 self, address: Address, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_code<'life0, 'async_trait>( &'life0 self, address: Address, code: String, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_storage_at<'life0, 'async_trait>( &'life0 self, address: Address, slot: U256, value: U256, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_chain_id<'life0, 'async_trait>( &'life0 self, id: u32, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided method fn into_rpc(self) -> RpcModule<Self> { ... }
}
Expand description

Server trait implementation for the AnvilNamespace RPC API.

Required Methods§

Source

fn dump_state<'life0, 'async_trait>( &'life0 self, preserve_historical_states: Option<bool>, ) -> Pin<Box<dyn Future<Output = RpcResult<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.

§Arguments
  • preserve_historical_states - Whether to preserve historical states
§Returns

Buffer representing the chain state.

Source

fn load_state<'life0, 'async_trait>( &'life0 self, bytes: Bytes, ) -> Pin<Box<dyn Future<Output = RpcResult<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.

§Arguments
  • bytes - Buffer containing the chain state
§Returns

true if a snapshot was reverted, otherwise false.

Source

fn mine_detailed<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = RpcResult<Block<DetailedTransaction>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Mines a single block in the same way as evm_mine but returns extra fields.

§Returns

Freshly mined block’s representation along with extra fields.

Source

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

Sets the fork RPC url. Assumes the underlying chain is the same as before.

§Arguments
  • url - Fork’s new URL
Source

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

Sets the base fee of the next block.

§Arguments
  • base_fee - Value to be set as base fee for the next block
Source

fn drop_transaction<'life0, 'async_trait>( &'life0 self, hash: H256, ) -> Pin<Box<dyn Future<Output = RpcResult<Option<H256>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes a transaction from the pool.

§Arguments
  • hash - Hash of the transaction to be removed from the pool
§Returns

Some(hash) if transaction was in the pool before being removed, None otherwise

Source

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

Remove all transactions from the pool.

Source

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

Remove all transactions from the pool by sender address.

§Arguments
  • address - Sender which transactions should be removed from the pool
Source

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

Gets node’s auto mining status.

§Returns

true if auto mining is enabled, false otherwise

Source

fn set_auto_mine<'life0, 'async_trait>( &'life0 self, enable: bool, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + 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.

§Arguments
  • enable - if true automatic mining will be enabled, disabled otherwise
Source

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

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

§Arguments
  • seconds - Frequency of automatic block production (in seconds)
Source

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

Sets the block timestamp interval. All future blocks’ timestamps will have the provided amount of seconds in-between of them. Does not affect the block production interval.

§Arguments
  • seconds - The interval between two consecutive blocks (in seconds)
Source

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

Removes the block timestamp interval if it exists.

§Returns

true if an existing interval was removed, false otherwise

Source

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

Set the minimum gas price for the node. Unsupported for ZKsync as it is only relevant for pre-EIP1559 chains.

§Arguments
  • gas - The minimum gas price to be set
Source

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

Enable or disable logging.

§Arguments
  • enable - if true logging will be enabled, disabled otherwise
Source

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

Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the id of the snapshot that was created. A snapshot can only be reverted once. After a successful anvil_revert, the same snapshot id cannot be used again. Consider creating a new snapshot after each anvil_revert if you need to revert to the same point multiple times.

§Returns

The U64 identifier for this snapshot.

Source

fn revert<'life0, 'async_trait>( &'life0 self, id: U64, ) -> Pin<Box<dyn Future<Output = RpcResult<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. This deletes the given snapshot, as well as any snapshots taken after (e.g.: reverting to id 0x1 will delete snapshots with ids 0x1, 0x2, etc.)

§Arguments
  • id - The snapshot id to revert
§Returns

true if a snapshot was reverted, otherwise false.

Source

fn set_time<'life0, 'async_trait>( &'life0 self, timestamp: Numeric, ) -> Pin<Box<dyn Future<Output = RpcResult<i128>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set the current timestamp for the node. Warning: This will allow you to move backwards in time, which may cause new blocks to appear to be mined before old blocks. This will result in an invalid state.

§Arguments
  • time - The timestamp to set the time to
§Returns

The difference between the current timestamp and the new timestamp.

Source

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

Increase the current timestamp for the node

§Arguments
  • seconds - The number of seconds to increase time by
§Returns

The applied time delta to the current timestamp in seconds.

Source

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

Set timestamp for the next block. The timestamp must be in future.

§Arguments
  • timestamp - The timestamp to set the time to
Source

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

Sets auto impersonation status.

§Arguments
  • enabled - true makes every account impersonated, false disables this behavior
§Returns

A BoxFuture containing a Result representing the success of the operation.

Source

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

Sets the balance of the given address to the given balance.

§Arguments
  • address - The Address whose balance will be edited
  • balance - The new balance to set for the given address, in wei
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

Modifies an account’s nonce by overwriting it.

§Arguments
  • address - The Address whose nonce is to be changed
  • nonce - The new nonce
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

Sometimes you may want to advance the latest block number of the network by a large number of blocks. One way to do this would be to call the evm_mine RPC method multiple times, but this is too slow if you want to mine thousands of blocks. The anvil_mine method can mine any number of blocks at once, in constant time. (It exhibits the same performance no matter how many blocks are mined.)

§Arguments
  • num_blocks - The number of blocks to mine, defaults to 1
  • interval - The interval between the timestamps of each block, in seconds, and it also defaults to 1
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

fn reset_network<'life0, 'async_trait>( &'life0 self, reset_spec: Option<ResetRequest>, ) -> Pin<Box<dyn Future<Output = RpcResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Reset the state of the network back to a fresh forked state, or disable forking.

§Arguments
  • reset_spec - The requested state, defaults to resetting the current network.
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

anvil-zksync allows transactions impersonating specific account and contract addresses. To impersonate an account use this method, passing the address to impersonate as its parameter. After calling this method, any transactions with this sender will be executed without verification. Multiple addresses can be impersonated at once.

§Arguments
  • address - The address to impersonate
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

Use this method to stop impersonating an account after having previously used anvil_impersonateAccount The method returns true if the account was being impersonated and false otherwise.

§Arguments
  • address - The address to stop impersonating.
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

Modifies the bytecode stored at an account’s address.

§Arguments
  • address - The address where the given code should be stored.
  • code - The code to be stored.
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

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

Directly modifies the storage of a contract at a specified slot.

§Arguments
  • address - The contract address whose storage is to be modified.
  • slot - The storage slot to modify.
  • value - The value to be set at the specified slot.
§Returns

A BoxFuture containing a Result with a bool representing the success of the operation.

Source

fn set_chain_id<'life0, 'async_trait>( &'life0 self, id: u32, ) -> Pin<Box<dyn Future<Output = RpcResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Sets the chain id.

§Arguments
  • id - The chain id to be set.

Provided Methods§

Source

fn into_rpc(self) -> RpcModule<Self>

Collects all the methods and subscriptions defined in the trait and adds them into a single RpcModule.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§