10 Contract

Gas and costs

Measured gas for every function, what that costs at the gas price we measured on Robinhood Chain, and who pays what.

#Measured gas

These numbers come from forge test --gas-report on the real test suite (min to max across the runs of each function), and from a run on a local anvil chain with the compiled contract. They are measurements of this code, not estimates.

FunctionGas (forge, range)Gas (anvil run)
createLinkEthabout 104k at the top of the range101,934
createLinkTokenabout 164k to 170k165,107
claim (ETH)about 85k to 117k93,131
claim (token)within the same range92,394
undoabout 53k to 67k42,398
expireRefundabout 56k to 68k44,899
sweepFeesabout 69k60,306
setParamsabout 28knot run

Runtime code size is 6,101 bytes.

The forge ranges are wider because the suite includes cold and warm storage, fuzzed inputs and different token types. The anvil figures are single runs on a fresh chain with a warm test token, so treat them as typical rather than as limits. A first createLinkEth costs more than the numbers suggest if the sender is a brand-new account, and a token with expensive transfer logic costs more than the mock token used here.

#What that costs in money

Gas is only one component of a transaction's fee, and the price moves. On 2026-10-09 we measured a gas price of about 0.0202 gwei on Robinhood Chain. At that price:

ActionGasCost at 0.0202 gwei
Create an ETH link~104k~0.0000021 ETH
Claim~117k~0.0000024 ETH
Undo~67k~0.0000014 ETH
Refund after expiry~68k~0.0000014 ETH

The arithmetic is gas × gasPrice: for example 67,000 × 0.0202 gwei = 0.0000013534 ETH. At that measured price an undo costs a tiny fraction of a cent.

#Who pays what

CostPaid by
Gas of createLinkEth / createLinkToken (and the token approve)the sender
Gas of claimwhoever submits it: the recipient, or a relayer
Gas of undothe sender
Gas of expireRefundwhoever calls it: a keeper, the sender, anyone
Gas of sweepFeeswhoever calls it
The fee (0.3% by default)taken from the amount on a claim only, so the recipient receives the net
Undo or expiryno protocol fee: the sender gets 100% back, and only paid the gas

Unlike some chains, there is no rent or account deposit to recover: an escrow record is a storage entry that is cleared when the link ends.

#Why a claim by a brand-new wallet works

The recipient's wallet signs a message and never sends a transaction, so it needs no ETH. The relayer pays the gas of claim. At the gas price above, that is a few millionths of an ETH, which is why a free relayer is plausible. See Relayer.

#Sends too small to be worth it

The fee rounds down. At 0.3%, any amount below 334 base units carries a zero fee. On the other side of the ledger, gas is a fixed cost, so very small sends are dominated by it. Nothing in the contract blocks a tiny send, but the app should warn when gas would be a large share of the amount.

#Reproduce the numbers

cd contracts && forge test --gas-report --match-contract OopsendTest
node scripts/docs-e2e.mjs     # anvil run: prints gas for each call

The second command starts its own anvil, deploys the compiled contract, and prints the figures in the right-hand column above.