Skip to content

MineOptions

What to mine on a test node: how many blocks, and the timestamp of the first.

import { Effect } from "effect";
import { Anvil } from "@ethect/core/rpc";
import type { MineOptions } from "@ethect/core/rpc";
const options: MineOptions.MineOptions = { timestamp: 2_000_000_000n, blocks: 2 };
const timestamps = Anvil.mineDetailed(options).pipe(
Effect.map((blocks) => blocks.map((block) => block.timestamp)),
);
// [2000000000n, 2000000001n]
Schema Type Describes Used by
MineOptions.schema MineOptions.MineOptions how many blocks to mine and when the first is Evm.mine, Evm.mineDetailed, Anvil.mineDetailed
Field Type Notes
timestamp bigint (optional) the timestamp of the first block mined, in seconds
blocks number (optional) how many blocks to mine. One when left out.
  • Everything is optional. The options can be left out altogether, and both fields can: one block is mined at the node’s current time.
  • Only the first block is timed. With blocks: 2, the second block is one second after the first when anvil mines them in one go.
  • Not before the latest block. A timestamp lower than the latest block’s fails the call with an RpcError of reason InvalidParams.
  • blocks is a JSON number on the wire. anvil refuses a hex quantity there, so the field is sent as it is, while timestamp is sent as a quantity.
  • Not for Anvil.mine. Anvil.mine takes a number of blocks and an interval as two params.