Locate the first OP L2 block of an L1 origin epoch
Several OP blocks can share one L1 origin. The sequence number stored by the L1Block predeploy identifies an L2 block’s position within that epoch.
Read sequenceNumber at the L2 block
Use Foundry cast with a retained L2 height. Read the predeploy’s number() and hash() at the same height to record the L1 origin as well. The sequence resets to zero at the first block of a new epoch.
cast call 0x4200000000000000000000000000000000000015 \
"sequenceNumber()(uint64)" --block "$L2_HEIGHT" --rpc-url "$L2_RPC"
If L2 height 10,004 reports sequence 4, the candidate first L2 height is 10,000. Requery that block and verify it reports zero with the same L1 origin hash. This avoids mistaking L1 block numbers for L2 heights.
Check the historical context source
Historical eth_call requires the L2 state at the selected block. An endpoint that only retains headers may be unable to serve it. Attribute transaction encoding also varies across protocol upgrades if you reconstruct the value from raw block transactions. specs.optimism.io OP Stack specification