Struct ethers_core::utils::Anvil
source · [−]pub struct Anvil { /* private fields */ }
Expand description
Builder for launching anvil
.
Panics
If spawn
is called without anvil
being available in the user’s $PATH
Example
use ethers_core::utils::Anvil;
let port = 8545u16;
let url = format!("http://localhost:{}", port).to_string();
let anvil = Anvil::new()
.port(port)
.mnemonic("abstract vacuum mammal awkward pudding scene penalty purchase dinner depart evoke puzzle")
.spawn();
drop(anvil); // this will kill the instance
Implementations
sourceimpl Anvil
impl Anvil
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty Anvil builder. The default port is 8545. The mnemonic is chosen randomly.
sourcepub fn port<T: Into<u16>>(self, port: T) -> Self
pub fn port<T: Into<u16>>(self, port: T) -> Self
Sets the port which will be used when the anvil
instance is launched.
sourcepub fn mnemonic<T: Into<String>>(self, mnemonic: T) -> Self
pub fn mnemonic<T: Into<String>>(self, mnemonic: T) -> Self
Sets the mnemonic which will be used when the anvil
instance is launched.
sourcepub fn block_time<T: Into<u64>>(self, block_time: T) -> Self
pub fn block_time<T: Into<u64>>(self, block_time: T) -> Self
Sets the block-time which will be used when the anvil
instance is launched.
sourcepub fn fork<T: Into<String>>(self, fork: T) -> Self
pub fn fork<T: Into<String>>(self, fork: T) -> Self
Sets the fork
argument to fork from another currently running Ethereum client
at a given block. Input should be the HTTP location and port of the other client,
e.g. http://localhost:8545
. You can optionally specify the block to fork from
using an @ sign: http://localhost:8545@1599200
sourcepub fn args<I, S>(self, args: I) -> Self where
I: IntoIterator<Item = S>,
S: Into<String>,
pub fn args<I, S>(self, args: I) -> Self where
I: IntoIterator<Item = S>,
S: Into<String>,
Adds multiple arguments to pass to the anvil
.
sourcepub fn spawn(self) -> AnvilInstance
pub fn spawn(self) -> AnvilInstance
Consumes the builder and spawns anvil
with stdout redirected
to /dev/null.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Anvil
impl Send for Anvil
impl Sync for Anvil
impl Unpin for Anvil
impl UnwindSafe for Anvil
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more