Quote the OP Fjord data fee from an unsigned transaction size
A fee estimator may know a transaction’s serialized size before the user signs it. Fjord’s GasPriceOracle can quote a practical upper estimate for the L1 data fee using that size.
Count the unsigned transaction envelope
On a compatible OP chain, call the oracle with the byte length of the serialized unsigned transaction. In the example it is 180 bytes. The contract adds its allowance for signatures internally. Use Foundry cast against the target L2 RPC.
cast call 0x420000000000000000000000000000000000000F \
"getL1FeeUpperBound(uint256)(uint256)" 180 --rpc-url "$L2_RPC"
A contract call carrying 100 bytes of calldata need not have a 100-byte unsigned transaction. Include the typed envelope and transaction fields when computing the input size. Read the result as the fee amount in base units.
Keep the estimate separate from total transaction cost
The oracle uses fee parameters from the queried L2 state and a compression estimate. Later inclusion can see different prices. Add execution fees and any other fees enabled on the chain when showing the total budget. specs.optimism.io OP Stack specification