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
sourceimpl 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) -> 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 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.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Ganache
impl Send for Ganache
impl Sync for Ganache
impl Unpin for Ganache
impl UnwindSafe for Ganache
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