Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Why USDT Approve Reverts: The Zero-First Fix

Ethereum USDT reverts when you call approve(spender, value) with a nonzero value while that spender already has a nonzero allowance. Set the allowance to zero first, then set the new value; this works around TetherToken’s guard, which was added to mitigate the ERC-20 approval race condition. Say the allowance is 50 USDT and your dapp requests 100. The call to approve(spender, 100) reverts because…

USDT reverts when called with a nonzero approval while the spender already has a nonzero allowance. To workaround TetherToken's guard, first set the allowance to zero, then set the new value. For example, if the allowance is 50 USDT and the dapp requests 100, the approve call will revert because the current allowance is still nonzero.

Calling approve(spender, 0) followed by approve(spender, 100) will succeed. The inner workings of USDT’s approve call involve checking if the new value is nonzero and the current allowance is zero. If the check fails, the call reverts; if successful, the allowance is updated without returning a value. This can cause issues as Solidity checks return data, leading to reverts when decoding missing boolean values.

To handle these cases, use OpenZeppelin Contracts' SafeERC20.forceApprove, which first sets the allowance to zero if the approval fails and retries the requested value. Always verify the specific USDT deployment's approved behavior on the intended network, as TetherToken's rules may vary.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Podcast to Shorts: how to pick the best clips (what the ranking looks at)

TL;DR The ranking reads text, not video. RemixViral transcribes your upload with Whisper, numbers the sentences, and asks one language-model call (default gpt-4o-mini ) for the best standalone…

  • Transcript is transcribed using Whisper, each sentence numbered
  • LLM identifies best standalone moments based on criteria
  • Ranking determined by fixed rules assigning scores 0-100

Qui té dret a gaudir de la plaça? Creant La Plaça a la HackEPS

English This is a submission for the MLH x DEV Writing Challenge What I Built It’s summer in Lleida, and the bars on a residential street want to keep their outdoor tables open later.

  • "La Plaça" game created for HackEPS 2026 in Lleida
  • Players make decisions for five fictional neighbors in shared space scenarios
  • Game engine shows long-term consequences of seemingly small choices

More from Sunday, 29 November 2026 →