Node
The three methods about the test node itself: how it is set up, what identifies it, and whether it logs the requests it gets.
| Method | JSON-RPC | Returns | Description |
|---|---|---|---|
nodeInfo |
anvil_nodeInfo |
NodeInfo |
How the node is set up: its head, hard fork and fees, and the endpoint it forks. |
metadata |
anvil_metadata |
NodeMetadata |
What identifies the node: its version, chain and head, its fork, its snapshots. |
setLoggingEnabled |
anvil_setLoggingEnabled |
null |
Turns the node’s logging of requests on or off. |
Each returns an Effect<…, Method.Error, Transport>.
nodeInfo
Section titled “nodeInfo”Returns how the node is set up: its head, its hard fork, its fees and the endpoint it forks, if any.
import { Effect } from "effect";import { Anvil } from "@ethect/core/rpc";
const setup = Effect.gen(function* () { const info = yield* Anvil.nodeInfo(); return { hardFork: info.hardFork, // "Bpo1" chainId: info.environment.chainId, // 31337 baseFee: info.environment.baseFee, // 1000000000n forked: info.forkConfig.forkUrl !== null, // false };});- JSON-RPC:
anvil_nodeInfo - Parameters: none.
- Returns:
NodeInfo.
metadata
Section titled “metadata”Returns what identifies the node: its version, its chain and head, where it was forked from and the snapshots it holds.
import { Effect } from "effect";import { Anvil } from "@ethect/core/rpc";
const identity = Effect.gen(function* () { const metadata = yield* Anvil.metadata(); return { client: metadata.clientVersion, // "anvil/v1.9.0" chainId: metadata.chainId, // 31337 head: metadata.latestBlockNumber, // 0n forked: metadata.forkedNetwork !== null, // false };});- JSON-RPC:
anvil_metadata - Parameters: none.
- Returns:
NodeMetadata.
setLoggingEnabled
Section titled “setLoggingEnabled”Turns the node’s logging of the requests it gets on or off.
import { Effect } from "effect";import { Anvil } from "@ethect/core/rpc";
const quiet = Effect.gen(function* () { yield* Anvil.setLoggingEnabled(false);});- JSON-RPC:
anvil_setLoggingEnabled - Parameters:
enabled(boolean). - Returns:
null. - The log is what the anvil process prints. Nothing about it can be read back over JSON-RPC.
Behavior
Section titled “Behavior”- Two views of the head.
nodeInfogives the head ascurrentBlockNumberandmetadataaslatestBlockNumber. Both arebigints. - Fork fields are
nulloff a fork.forkConfigalways has its three keys, eachnullunless the node is a fork, andforkedNetworkisnullas a whole. SeeAnvil.reset.