Trait era_test_node::namespaces::HardhatNamespaceT
source · pub trait HardhatNamespaceT: Sized + Send + Sync + 'static {
// Required methods
fn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>;
fn set_nonce(&self, address: Address, balance: U256) -> RpcResult<bool>;
fn hardhat_mine(
&self,
num_blocks: Option<U64>,
interval: Option<U64>
) -> RpcResult<bool>;
fn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>;
fn impersonate_account(&self, address: Address) -> RpcResult<bool>;
fn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>;
fn set_code(&self, address: Address, code: Vec<u8>) -> RpcResult<()>;
fn set_storage_at(
&self,
address: Address,
slot: U256,
value: U256
) -> RpcResult<bool>;
// Provided method
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M> { ... }
}
Required Methods§
sourcefn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>
fn set_balance(&self, address: Address, balance: U256) -> RpcResult<bool>
sourcefn hardhat_mine(
&self,
num_blocks: Option<U64>,
interval: Option<U64>
) -> RpcResult<bool>
fn hardhat_mine( &self, num_blocks: Option<U64>, interval: Option<U64> ) -> RpcResult<bool>
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 hardhat_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 1interval
- 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.
sourcefn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>
fn reset_network(&self, reset_spec: Option<ResetRequest>) -> RpcResult<bool>
sourcefn impersonate_account(&self, address: Address) -> RpcResult<bool>
fn impersonate_account(&self, address: Address) -> RpcResult<bool>
Hardhat Network allows you to send 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.
sourcefn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>
fn stop_impersonating_account(&self, address: Address) -> RpcResult<bool>
Use this method to stop impersonating an account after having previously used hardhat_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.
sourcefn set_storage_at(
&self,
address: Address,
slot: U256,
value: U256
) -> RpcResult<bool>
fn set_storage_at( &self, address: Address, slot: U256, value: U256 ) -> RpcResult<bool>
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.
Provided Methods§
sourcefn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
fn to_delegate<M: Metadata>(self) -> IoDelegate<Self, M>
Create an IoDelegate
, wiring rpc calls to the trait methods.