Struct ethers_core::utils::Ganache
source · pub struct Ganache { /* private fields */ }
Expand description
Builder for launching ganache-cli
.
Panics
If spawn
is called without ganache-cli
being available in the user’s $PATH
Example
use ethers_core::utils::Ganache;
let port = 8545u16;
let url = format!("http://localhost:{}", port).to_string();
let ganache = Ganache::new()
.port(port)
.mnemonic("abstract vacuum mammal awkward pudding scene penalty purchase dinner depart evoke puzzle")
.spawn();
drop(ganache); // this will kill the instance
Implementations§
source§impl Ganache
impl Ganache
sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty Ganache builder. The default port is 8545. The mnemonic is chosen randomly.
sourcepub fn startup_timeout_millis<T: Into<u64>>(self, timeout: T) -> Self
pub fn startup_timeout_millis<T: Into<u64>>(self, timeout: T) -> Self
Sets the startup timeout which will be used when the ganache-cli
instance is launched in
miliseconds. 10_000 miliseconds by default).
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 ganache-cli
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 ganache-cli
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 ganache-cli
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) -> Selfwhere
I: IntoIterator<Item = S>,
S: Into<String>,
pub fn args<I, S>(self, args: I) -> Selfwhere
I: IntoIterator<Item = S>,
S: Into<String>,
Adds multiple arguments to pass to the ganache-cli
.
sourcepub fn spawn(self) -> GanacheInstance
pub fn spawn(self) -> GanacheInstance
Consumes the builder and spawns ganache-cli
with stdout redirected
to /dev/null. This takes ~2 seconds to execute as it blocks while
waiting for ganache-cli
to launch.