# BlockOverride

Header fields a call pretends its block has: its number, its timestamp, its gas limit, its fee
recipient and its fees, for the time of one call.

```ts
import { Effect } from "effect";
import { Address } from "@ethect/core";
import { type BlockOverride, Eth } from "@ethect/core/rpc";

const ADDRESS = Address.makeUnsafe("0x70997970C51812dc3A010C7d01b50e0d17dc79C8");

const at = Effect.gen(function* () {
  // TIMESTAMP PUSH0 MSTORE PUSH1 32 PUSH0 RETURN: returns the block's timestamp
  const code = "0x425f5260205ff3";
  const blockOverride: BlockOverride.BlockOverride = { time: 2_000_000_000n };
  return yield* Eth.call(
    { to: ADDRESS },
    "latest",
    { [ADDRESS]: { code } },
    blockOverride,
  );
});
// "0x0000000000000000000000000000000000000000000000000000000077359400"
```

The code sees a block whose timestamp is `2000000000`, which is `0x77359400`.

## Schemas

| Schema | Type | Describes | Used by |
| --- | --- | --- | --- |
| `BlockOverride.schema` | `BlockOverride.BlockOverride` | the block fields to replace | [`Eth.call`](https://ethect.dev/rpc/eth/call/), [`Eth.estimateGas`](https://ethect.dev/rpc/eth/estimate-gas/), the `blockOverrides` of [`Eth.simulateV1`](https://ethect.dev/rpc/eth/simulate-v1/) and of [`Debug.traceCall`](https://ethect.dev/rpc/debug/trace-call/) |

## Fields

Every field is optional.

| Field | Type | Notes |
| --- | --- | --- |
| `number` | `bigint` | the block number |
| `time` | `bigint` | the timestamp, in seconds since the Unix epoch |
| `gasLimit` | `bigint` | |
| `feeRecipient` | `Address` | the `miner` of a [`Block`](https://ethect.dev/rpc/types/block/) |
| `prevRandao` | `Hash` | the `mixHash` of a block |
| `baseFeePerGas` | `bigint` | in wei |
| `blobBaseFee` | `bigint` | in wei |
| `withdrawals` | `ReadonlyArray<`[`Withdrawal`](https://ethect.dev/rpc/types/withdrawal/)`>` | for a simulated block |

## Behavior

- **The names are not those of a block.** The override says `time`, `feeRecipient` and
  `prevRandao` where a [`Block`](https://ethect.dev/rpc/types/block/) says `timestamp`, `miner` and
  `mixHash`.
- **Last param of a call.** `Eth.call` and `Eth.estimateGas` take it after the state override.
  To pass it alone, pass `{}` as the state override.
- **One call only.** The override lasts for the call it is passed to. To move the clock of a
  test node for good, use the [`Anvil`](https://ethect.dev/rpc/anvil/time/#settime) methods.
- **In a simulation, it shapes the block.** In [`Eth.simulateV1`](https://ethect.dev/rpc/eth/simulate-v1/)
  the simulated block comes back with the overridden fields.
