# NodeInfo

How a test node is set up: its head, its hard fork, its fees and blob parameters, and the
endpoint it forks.

```ts
import { Effect } from "effect";
import { Anvil } from "@ethect/core/rpc";

const fork = Effect.gen(function* () {
  const info = yield* Anvil.nodeInfo();
  // info: NodeInfo.NodeInfo
  const { forkUrl, forkBlockNumber } = info.forkConfig;
  return forkUrl === null ? "not a fork" : `${forkUrl} at block ${forkBlockNumber}`;
});
```

## Schemas

| Schema | Type | Describes | Returned by |
| --- | --- | --- | --- |
| `NodeInfo.schema` | `NodeInfo.NodeInfo` | the setup of a test node | [`Anvil.nodeInfo`](https://ethect.dev/rpc/anvil/node/#nodeinfo) |

## Fields

| Field | Type | Notes |
| --- | --- | --- |
| `currentBlockNumber` | `bigint` | the number of the head |
| `currentBlockTimestamp` | `bigint` | the timestamp of the head, in seconds |
| `currentBlockHash` | `Hash` | the hash of the head |
| `hardFork` | `string` | the name of the active hard fork, as anvil spells it |
| `transactionOrder` | `"fees" \| "fifo"` | how the node orders the transactions of a block |
| `environment` | an object | see below |
| `forkConfig` | an object | see below |
| `network` | `string` (optional) | the kind of network the node runs: `"ethereum"` on a default anvil |
| `blobParams` | an object (optional) | see below |

### environment

| Field | Type | Notes |
| --- | --- | --- |
| `baseFee` | `bigint` | the base fee of the next block, in wei |
| `chainId` | `number` | |
| `gasLimit` | `bigint` | the gas limit of a block |
| `gasPrice` | `bigint` | the node's gas price, in wei |

### forkConfig

| Field | Type | Notes |
| --- | --- | --- |
| `forkUrl` | `string \| null` | the endpoint the node forks |
| `forkBlockNumber` | `bigint \| null` | the block it was forked at |
| `forkRetryBackoff` | `number \| null` | the wait before a failed request to the endpoint is tried again, in milliseconds |

### blobParams

| Field | Type | Notes |
| --- | --- | --- |
| `targetBlobCount` | `number` | |
| `maxBlobCount` | `number` | |
| `updateFraction` | `bigint` | |
| `minBlobFee` | `bigint` | in wei |
| `maxBlobsPerTx` | `number` | |
| `blobBaseCost` | `number` | |

## On the wire

What anvil 1.9 answers when started without options:

```json
{
  "currentBlockNumber": "0x0",
  "currentBlockTimestamp": 1795857411,
  "currentBlockHash": "0x556ff4b89f7a003c8c90bc7363901efcc112ef515d5629825ee90a7cf0e84eed",
  "hardFork": "Bpo1",
  "transactionOrder": "fees",
  "environment": {
    "baseFee": "0x3b9aca00",
    "chainId": 31337,
    "gasLimit": "0x1c9c380",
    "gasPrice": "0x77359400"
  },
  "forkConfig": {
    "forkUrl": null,
    "forkBlockNumber": null,
    "forkRetryBackoff": null
  },
  "network": "ethereum",
  "blobParams": {
    "targetBlobCount": 10,
    "maxBlobCount": 15,
    "updateFraction": "0x7f5a51",
    "minBlobFee": "0x1",
    "maxBlobsPerTx": 6,
    "blobBaseCost": 8192
  }
}
```

## Behavior

- **Block numbers and timestamps are `bigint`s.** anvil sends `currentBlockTimestamp` and
  `forkBlockNumber` as JSON numbers and the head's number as a hex quantity: all three decode
  to `bigint`. The chain id, the retry backoff and the blob counts stay `number`.
- **`null` means not a fork.** The three fields of `forkConfig` are always present, and `null`
  unless the node is a fork.
- **On a fork**, anvil 1.9 reports `forkUrl` as the URL it was given with a trailing slash
  added, and a `forkRetryBackoff` of `1000`.
- **Optional means absent.** `network` and `blobParams` are left out of the object when the
  node does not send them.
- **A snapshot of the moment.** The head and the fees are those at the time of the call. The
  same node is described by [`NodeMetadata`](https://ethect.dev/rpc/types/node-metadata/) too.
