YESswap
English简体中文繁體中文日本語한국어РусскийالعربيةEspañolPortuguêsFrançaisDeutschTiếng ViệtBahasa IndonesiaTürkçe

Fair Launch on BSC: Estimating batch gas before you send: per-call limits, calldata

Updated 2026-12-02 · YESswap

Short answer. A batch gas limit is a sum you construct, not a number a node hands you. This walks the construction from eth_estimateGas through eth_call simulation to the receipt fields that confirm or refute your arithmetic.
Best match for this articleWallet toolsBatch balance, batch transfer, approvals and wallet creation.

What eth_estimateGas returns for a batch, and what it does not

Knowing how fair launch on BSC works is what separates a clean trade from a costly one. What the scalar cannot see is anything that becomes true only at inclusion time. A balance that lands in the same block, a nonce you have not yet consumed, a storage slot another pending transaction warms first — none of these exist in the estimator's snapshot. The estimator also applies an implicit buffer on top of the binary-search floor, so the returned number is a floor plus a node-defined margin, not a prediction.

Verify the gap yourself. Send the batch calldata to eth_estimateGas over curl against a public BSC endpoint on chainId 56, record the scalar, then pull gasUsed from eth_getTransactionReceipt after the transaction mines. The delta between the two is your real margin for that batch shape, and it is the only margin number worth trusting. If that delta comes back negative — gasUsed above the estimate — the snapshot was stale, and you should treat the estimator as advisory for that batch shape until you re-measure.

Two RPC endpoints disagreeing is the common edge case, and it is a state problem, not a bug. Run the same eth_estimateGas against a second BSC endpoint; if the scalars differ by more than your measured delta, one node is lagging a block behind and its snapshot lacks a write your batch depends on. Query eth_blockNumber on both and compare. When the heights match and the estimates still diverge, the higher figure is the one to budget against.

Three leaks: cold slots, calldata growth, and the 63/64 rule

Cold storage is the larger term. The first SSTORE or SLOAD against a slot in a transaction pays a cold surcharge, and a batch touching N distinct holder slots pays it N times. Estimate against a state where a prior call in the same simulation already warmed those slots, and the returned figure omits the surcharge the real transaction will pay. That is the classic mid-loop out-of-gas, and it is why an estimate taken after a dry run can understate a fresh send. If you dry-ran the batch in the same session, discard that estimate and re-run it cold.

The 63/64 rule caps how much gas a call can forward. Each nested call may pass at most 63/64 of the gas remaining at the call site, so a deep loop or a batch that fans out into subcalls loses headroom at every level. Past a few frames the retained 1/64 accumulates into a real shortfall, and a loop that fits in a flat estimate will revert near its tail. Keep nesting shallow, or budget the loss explicitly. If your batch calls a router that itself calls the token, you have at least two frames; measure the retained loss by differencing a direct transfer batch against the routed one at the same N.

Simulating the whole batch with eth_call and a state override

eth_call executes against current state and returns either the return data or the revert payload. Run the exact batch you intend to send and read what the contract does before any BNB moves. Because a batch loop usually reverts on the first failing row, one call tells you whether the batch is atomic or best-effort — a require inside the iteration makes it all-or-nothing, while a try/catch or skip branch makes it partial.

Partial-failure batches still burn gas for every row they attempt. That distinction changes your budget more than any percentage buffer, because a status-1 transaction with skipped rows has spent the full limit and delivered less than N transfers. Decision rule: if the loop is best-effort, budget the full N and reconcile the log count afterward; if it is atomic, one bad row costs the entire transaction, so pre-validate rows off chain.

Funding the sender inside the simulation needs a state override. Pass an override object that sets the sender's balance slot, re-run eth_call, and watch whether the revert disappears. A revert that flips to success under a funded override was a balance check, not a logic bug. If it persists, the problem is in the contract path and no amount of gas will fix it. The override changes only the simulation copy; it never touches mainnet state, so this costs nothing and takes one round trip.

Turning N rows into a limit you can defend

Measure one row in isolation, then measure a batch of a few rows, and subtract. Extrapolate to N and add a margin sized to the variance you actually observed across batch sizes, not a fixed percentage copied from a blog. Decision rule: if the per-row slope drifts upward as N grows, cold slots are being paid per row and your extrapolation is already wrong.

Check the contract source before you pick N. A gasleft() check or a maxRows parameter aborts mid-loop, which protects the sender but converts your batch into a partial execution. Choose N below the guard's threshold rather than discovering the threshold from a failed receipt. If the source is unverified on BscScan, treat the batch as best-effort and cap N conservatively until you have receipt evidence.

For a YES distribution, confirm the token first. The only YES contract on BNB. Smart Chain is 0xc22955b28e092060bc5d1e1f3b9d4dcd81091111, a BEP-20 with 18 decimals, and the fee router sits at 0x0c9a2351e6e982b16559a68767003e7f4d02fb0d. Any address that differs is not the token, and a batch sent to a lookalike is unrecoverable. Verify by calling symbol() and decimals() via eth_call against that address and comparing to the published values; a mismatch means you are pointed at the wrong contract.

Reading the receipt: gasUsed, status, and log count

gasUsed is the truth and your limit is only a ceiling. Unused gas is refunded, so over-estimating costs nothing beyond a higher upfront balance requirement — the real cost of a bad estimate is an under-estimate, which surfaces as a status of 0 with gasUsed pressed against your limit. That pairing means out-of-gas inside the loop. Timing note: BSC blocks are short, so the receipt usually lands within a few blocks; poll eth_getTransactionReceipt on the hash and stop when it returns non-null rather than assuming a fixed wait.

Status 0 with gasUsed well below the limit is a different animal. It is a require revert, which points at a balance or a logic condition rather than gas, and raising the limit will not help. Read the revert data from the failed transaction to separate the two before you resend. A missing receipt is its own case: if the hash is not found after a reasonable block window, the transaction may still be pending in the mempool, so check eth_getTransactionByHash before concluding it dropped.

On a successful batch, count the logs array against your intended row count. A status of 1 with fewer events than rows means the loop skipped entries — the distribution is incomplete while the gas was fully spent. Cross-check gasUsed against your per-row slope at the same time; a gasUsed far under the slope suggests rows exited early, and one far over suggests cold slots you did not budget. Decision rule: if log count is short, do not resend the whole batch; identify the skipped rows and send only those. Every claim above is checkable on BscScan for 0xc22955b28e092060bc5d1e1f3b9d4dcd81091111 on BNB Smart Chain (chain id 56); treat https://yesswap.vip and @web3yesswap as the only official channels.

Open YESswap

Frequently asked questions

Does eth_estimateGas return per-call gas or one number for the whole batch transaction?

One scalar for the entire transaction. The node simulates every loop iteration and binary-searches the smallest limit that completes without reverting, so per-call figures must be derived by differencing batch sizes, not read off the return value.

Why does my batch run out of gas when the estimate said it would fit?

The estimator ran against a warm or stale snapshot. Cold-slot surcharges, calldata appended after estimating, and the 63/64 rule's retained gas at each nested call are all invisible to that snapshot but charged at inclusion.

How do I simulate a full batch without spending BNB, and how do I fund the sender?

Call eth_call with the batch calldata from the sender address and read the revert payload. Re-run with a state override that sets the sender's balance slot; a revert that flips to success was a balance check. The override is simulation-only and costs nothing.

If the batch reverts on row 40 of 100, do rows 1-39 stay applied?

Only if the loop is best-effort. A require inside the iteration reverts the whole transaction and nothing applies; a try/catch or skip branch lets the transaction succeed with earlier rows applied and later rows silently missing. Check the source to know which you have.

Should I set the gas limit to the estimate or above it, and does over-estimating cost me anything?

Set it above, sized to the variance you measured across batch sizes. Unused gas is refunded, so the only cost of over-estimating is a higher upfront balance requirement; under-estimating costs the whole transaction.

Keep reading

Where do you want to go?

Every card below opens the live product with your own wallet — no signup, no custody.

Go straight to the tool

Everything above is one page away: bsc launchpad ido.

Wallet toolsStake and mineYour wallet signs every step. Nothing is custodied.