Skip to content

Wallet authorization

Wallet authorization is an on-chain token allowance that lets a named spender contract call transferFrom for a user's tokens. Learn how approvals differ from signatures, why unlimited allowances persist, and how to verify or revoke them.

Updated

For educational purposes only; not investment advice. Investing may result in loss.

Direct answer

Wallet authorization (usually called a token approval) is an on-chain allowance from a token owner to one named spender address. For an ERC-20 token, approve(spender, amount) records the allowance, and the spender can later call transferFrom(owner, recipient, amount) within that remaining amount. It does not give the spender the owner’s private key or permission over other tokens.

An approval is a state-changing transaction, while a login signature is usually an off-chain statement. A typed permit such as ERC-2612 is signed data that a contract can submit to create an allowance without the owner paying that transaction’s gas; it is still an authorization and must be checked like an approval. Native coins such as ETH do not use ERC-20 allowances.

The practical question is always: which token, which spender, how much, for how long, and on which chain? A large or unlimited amount can remain usable until it is spent, replaced, expired by a token-specific mechanism, or revoked. The wallet connection itself is not the permission.

Wallet authorization
0 / 5
0 items reviewed; 5 items still unresolved

Completing this review does not prove an asset, transaction, or system is safe.

How it works

  1. A user sends approve(spender, amount) to the token contract. The contract stores the owner-to-spender allowance; 0 means no remaining allowance, while a very large value is commonly displayed as “unlimited.”
  2. The spender uses transferFrom in a later transaction. The token contract checks the owner balance and allowance, transfers the tokens, and normally decreases the allowance by the amount spent.
  3. Changing an allowance is an on-chain state transition, not an instant wallet setting. Replacing one non-zero value with another can create a race in the mempool; use a confirmed zero-first flow when the token or its documentation requires it.
  4. ERC-2612 permit and similar typed-data systems move the approval into a signed message. Check the token, chain ID, nonce, deadline, spender and amount; a signature may be submitted by someone else and can outlive a website session.
  5. To reduce exposure, approve only the verified spender and required amount, simulate the exact call, then check the receipt, Approval/Transfer events, balance and current allowance. Revoke by submitting a new approval for 0 on the correct network; revocation does not undo transfers already confirmed.

Example

Alice holds 100 USDC and approves a verified swap router for 40 USDC. The router can spend at most 40 USDC through transferFrom; it cannot use that approval to move her ETH or a different token. After a 15 USDC swap, the remaining allowance is normally 25 USDC.

If Alice instead approves an unlimited amount, the router contract can spend future USDC deposited in the same wallet while the allowance remains active. If the router is compromised or Alice approved a counterfeit address, the exposure can approach her whole USDC balance. Alice should verify the chain and contract, use a finite amount, and later submit approve(router, 0) if the permission is no longer needed.

Risks

  • A malicious or upgraded spender can use every token covered by its active allowance.
  • An unlimited approval can expose future deposits, not only the balance present when it was signed.
  • A wrong chain, token contract, spender address, decimal interpretation or calldata can make a legitimate-looking prompt dangerous.
  • A pending approval change or revocation can race with transferFrom; a confirmed zero does not reverse a transfer that already executed.
  • Permit-style signatures can be submitted later, and disconnecting a website does not invalidate them or an on-chain allowance.
  • Non-standard, fee-on-transfer, rebasing, paused or callback tokens may not follow the usual allowance behavior; inspect the verified contract and final state.

Common misconceptions

  • “Connecting a wallet grants spending access.” Connection normally exposes an address and lets a site request actions; only a confirmed approval, permit or transaction grants the relevant authority.
  • “A signature is harmless because it does not show a gas fee.” A relayer can pay gas for a permit or other signed authorization and submit it later.
  • “Revoking the site connection revokes token approval.” Connection state is separate from the token contract’s on-chain allowance.
  • “Unlimited means the token contract can take anything immediately.” The spender still needs an executed call, a sufficient balance and a compatible token implementation, but the active allowance removes the amount limit.
  • “A successful simulation proves the transfer is safe.” Simulation is state-dependent; verify the exact chain, calldata, recipient, contract code, receipt and resulting balances.

Sources

Navigation

Search the wiki...