You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GanacheProvider uses an in-memory Ethereum instance (via
Ganache) which can be
used for testing allowing free transactions and performing
explicit operations against an account not normally possible on a
real network.
import{GanacheProvider}from"@ethers-ext/provider-ganache";// Create a new in-memory GanacheProviderconstprovider=newGanacheProvider();///////////////////// Snapshotsconstrevert=awaitprovider.snapshot();// ... perform operations// Revert back to the snapshot stateawaitrevert();///////////////////// Account Stateawaitprovider.setAccount(addr,{balance: 1000000000000000000n,nonce: 5,code: "0x00"});awaitprovider.setStorageAt(addr,123,data);
API
new GanacheProvider(optionsOrGanache?)
When constructing a GanacheProvider, either the standard options
normally passed to Ganache may be used or an existing Ganache
instance created with the desired configuration.
provider.snapshot() => Promise<() => void>
Takes a snapshot of the current state and resolves to a function, that
when called will revert the Provider to the state at the time snapshot
was called.