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]Schemas
Section titled “Schemas”| 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 |
Fields
Section titled “Fields”| 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. |
Behavior
Section titled “Behavior”- 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
timestamplower than the latest block’s fails the call with anRpcErrorof reasonInvalidParams. blocksis a JSON number on the wire. anvil refuses a hex quantity there, so the field is sent as it is, whiletimestampis sent as a quantity.- Not for
Anvil.mine.Anvil.minetakes a number of blocks and an interval as two params.