Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Troubleshooting — Gas estimation · Boson Protocol
Skip to content

Gas estimation

Symptom

Tx reverts with "out of gas" despite estimation; or estimation succeeds but the tx fails on certain chains.

Causes

Polygon's gas dynamics

Polygon's L1 fee and base fee fluctuate fast; estimation captured at time t may be 30 % low at time t+1. Bump the gas limit ~20–30 % above the SDK's estimate for write-heavy paths.

Base / Optimism / Arbitrum L1 data fee

L2s have two gas components: L2 execution gas + L1 data fee. The L1 data fee is computed against the call data size; very large calldata (e.g. heavy metadata in a meta-tx) can spike it.

Use viem / ethers' estimateGas and bump cautiously; over-estimating doesn't waste much on L2 (you only pay for what you use), but reverts cost the full reserved amount.

Diamond's facet routing overhead

Diamond calls have a small constant overhead (~3-5k gas) for the routing. Inside an OrchestrationHandlerFacet call that batches multiple operations, this overhead is paid once — but the inner operations each touch many storage slots.

createOfferAndCommitAndRedeem is one of the heaviest paths. Reserve generously.

MetaTx envelope overhead

Meta-tx adds signature verification + nonce bumping (~30k gas) on top of the inner call. If your buyer client's estimator forgets to include this, the relayed tx reverts.

The SDK's relayMetaTransaction accounts for this; if you build the envelope yourself, add 50k gas as a safety margin.

Fix

Always wait and bump

const estimate = await sdk.estimateGas.commitToOffer(buyer, offerId)
const tx = await sdk.commitToOffer(buyer, offerId, {
  gasLimit: estimate.mul(120).div(100), // +20%
})

Watch chain congestion

Use a paid RPC for production. Free-tier RPCs (default Alchemy demo, public RPCs) throttle aggressively and give stale gas estimates under load.

Monitor on a dashboard

Track median gas per tx type per chain. Alert when median jumps > 2x — usually a chain-congestion event you'll want to ride out, not retry into.

Related