Skip to content

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.

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.

Schema Type Describes Used by
BlockOverride.schema BlockOverride.BlockOverride the block fields to replace Eth.call, Eth.estimateGas, the blockOverrides of Eth.simulateV1 and of Debug.traceCall

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
prevRandao Hash the mixHash of a block
baseFeePerGas bigint in wei
blobBaseFee bigint in wei
withdrawals ReadonlyArray<Withdrawal> for a simulated block
  • The names are not those of a block. The override says time, feeRecipient and prevRandao where a 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 methods.
  • In a simulation, it shapes the block. In Eth.simulateV1 the simulated block comes back with the overridden fields.