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

Bep20 Token Approval: Unlimited approvals on BSC: pricing the allowance mapping

Updated 2026-12-02 · YESswap

Short answer. An unlimited approval is not a vulnerability in the token contract. It is a standing delegation you signed, and its blast radius is exactly your balance at the second a spender calls transferFrom.
Best match for this articleWallet toolsBatch balance, batch transfer, approvals and wallet creation.

The mapping entry, not the wallet prompt

Knowing how bep20 token approval works is what separates a clean trade from a costly one. Approving a spender writes one uint256 into allowance[owner][spender] inside the token contract. That is the entire grant. The BEP-20 standard defines no ceiling and no expiry field, so the number sits in storage until the owner overwrites it. Wallets and routers prefill 2^256-1 because a max approval removes a signing step from every future swap, and that convenience is the only reason the value is called unlimited.

Revocability is the part most summaries skip. The owner can call approve again with any smaller number, including zero, and the spender's reach shrinks in the same block. Perpetual in storage does not mean permanent. It means nobody but the owner key can end it. Treat the entry as a liability with a named signer, not as a setting.

Exposure is the minimum of two numbers

transferFrom checks the allowance against the requested amount, then debits balanceOf[owner]. Whichever number is smaller is the binding constraint. An unlimited approval on a wallet holding a modest balance is a modest liability; the identical approval on a funded wallet is a large one. Ranking approvals by allowance alone overstates risk on empty addresses and understates it on loaded ones.

Pin both reads to one block. Call balanceOf(owner) and allowance(owner, spender) at the same block number via eth_call, then take the smaller value. Multiply by price only if you need a currency figure; otherwise report raw units and skip the oracle entirely. The Transfer event filtered to the owner address is the audit trail for how the balance moved since the grant was signed.

A finite approval is not automatically safe. If the balance exceeds the approved amount, a routine swap can re-grant the approval to max in the same flow, and the wallet returns to unlimited exposure without the owner noticing. Read the balance first, then the allowance, then the recent. Approval events in that order. Decision rule: if any Approval event for the owner carries max uint256 as its value, treat the wallet as unlimited-exposed regardless of what the UI last showed.

Sorting spenders by failure path

Router approvals and staking approvals fail differently, and the difference decides how long a grant should live. A router calls transferFrom inside the transaction the user just signed, so its risk is upgradeability and any arbitrary-call surface it exposes, not custody. A staking contract pulls tokens on deposit and returns them on withdrawal, which means the approval outlives its purpose once the position closes.

Check what the spender actually is before extending trust. An immutable contract cannot. Then filter that spender's. Approval events to see how often it has been exercised, and cross-reference the token's. Transfer events where the spender appears as the routed source.

Scope the grant to the duration of the job. Approve the exact amount for a one-off deposit, approve max only for a spender you have verified as immutable or as a proxy you accept, and re-check the entry after any protocol upgrade announcement. Decision rule: if the spender's implementation slot changed since your approval, zero the entry before interacting again. A grant that survives its purpose is pure residual risk.

Cutting exposure without stranding a position

BEP-20 has no revoke function. The only primitive is approve(spender, 0), which zeroes the mapping entry. Some older tokens also reject a direct change from one non-zero value to another, which is why the two-step approve(0) then approve(newAmount) sequence exists in the wild. Skipping the zero step on such a token reverts the second call.

Order of operations decides whether a live position survives. Enumerate open positions first, then zero the spenders with nothing pending, then re-approve narrowly where a strategy still needs the grant. Zeroing an approval that a pending limit order or staking withdrawal depends on makes the next transferFrom revert, and the position sits stuck until the owner re-approves. That is a self-inflicted outage, not an exploit.

Confirm the write landed. Each revocation emits. Approval(owner, spender, 0) in the transaction logs, and re-reading allowance(owner, spender) at the block after the revocation is mined shows the new state. A transferFrom attempted afterward returns the standard insufficient allowance error, which is the observable proof the zeroing took effect. Cost and timing: a revocation is one state-changing BSC transaction paying BSC gas, and it is final once mined. If the receipt is missing from the endpoint you queried, do not re-broadcast blindly; query the same transaction hash on a second RPC endpoint before assuming failure.

Auditing a YES holder against the fee router

The YES token at 0xc22955b28e092060bc5d1e1f3b9d4dcd81091111 is a standard BEP-20 with 18 decimals, so its allowance mapping behaves exactly as described above. An approval granted to the fee router at 0x0c9a2351e6e982b16559a68767003e7f4d02fb0d is a separate entry from approvals to any other spender and must be audited on its own line. YESswap is non-custodial and every transaction is signed in the user wallet, so the platform never holds the owner key and cannot overwrite that entry for you.

Two RPC calls cover the whole audit. First, call allowance(owner, 0x0c9a2351e6e982b16559a68767003e7f4d02fb0d) on the YES token contract via eth_call. Second, call balanceOf(owner) at the same pinned block. The smaller of the two is your router exposure in YES units.

Two edge cases distort that number. Thin liquidity means the quoted price of a large YES balance is not the price you could exit at, so a currency figure overstates realizable loss; report raw units when liquidity is shallow. Two RPC endpoints disagreeing on the same block usually means one is lagging, so compare blockNumber from eth_blockNumber on both and only trust reads pinned to a block both have passed.

Verify the spender address character by character against the one published on https://yesswap. vip before you act on any figure. A lookalike address pasted from a chat or a search result receives an unlimited grant to a contract you never intended to approve, and that is the failure mode no audit procedure can catch for you. The same rule covers the domain, the Telegram handle @web3yesswap, and the X account @web3yesswap. Anything that differs is not official. 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 an unlimited approval reach tokens I receive later?

As long as the allowance entry is non-zero, any balance that arrives afterward is reachable by the same spender until the owner zeroes it.

Is max uint256 riskier than approving an exact amount?

The ceiling is identical. The difference is duration: an exact approval is consumed by one transferFrom, while a max approval persists until revoked.

Can a spender raise its own allowance?

Only the owner address can write to allowance[owner][spender], and only by signing an approve call.

Does revocation cost the same as approval?

Both are state-changing BSC transactions and both pay gas. Revocation writes a zero instead of a value, so the cost is comparable.

Can YESswap revoke my approval for me?

The platform is non-custodial and never holds the owner key. Only the wallet that signed the original approval can overwrite it.

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: token approval checker bsc.

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