Etherex.Time (Etherex v1.0.0) View Source

Some Ethereum clients support jumping through time simulating time events like advance the time and the blocks or set and revert to a snapshot.

Ganache-cli, for example, support the following non-standard JSON RPC methods:

  • evm_snapshot : Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created. A snapshot can only be used (reverted) once.
  • evm_revert : Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. This deletes the given snapshot, as well as any snapshots taken after.
  • evm_increaseTime : Jump forward in time. Takes one parameter, which is the amount of time to increase in seconds. Returns the total time adjustment, in seconds.
  • evm_mine : Force a block to be mined. Takes one optional parameter, which is the timestamp a block should setup as the mining time. Mines a block independent of whether or not mining is started or stopped.

Link to this section Summary

Functions

Forces a block to be mined. Takes one optional parameter, which is the timestamp a block should setup as the mining time. Returns the block mined.

Enables automatic mining.

Disables automatic mining.

Link to this section Functions

Specs

mine(integer() | nil) :: {:ok, Etherex.quantity()} | {:error, Etherex.error()}

Forces a block to be mined. Takes one optional parameter, which is the timestamp a block should setup as the mining time. Returns the block mined.

Specs

miner_start() :: :ok | {:error, Etherex.error()}

Enables automatic mining.

Specs

miner_stop() :: :ok | {:error, Etherex.error()}

Disables automatic mining.

Specs

revert(id :: non_neg_integer()) :: :ok | {:error, Etherex.error()}

Specs

snapshot() :: {:ok, non_neg_integer()} | {:error, Etherex.error()}