SafeERC20FailedOperation is a custom error from OpenZeppelin Contracts v5. It means a smart contract tried to move or approve a token through the SafeERC20 library, and the token call did not clearly succeed. In current OpenZeppelin versions, that almost always means one of two things: the token returned false instead of true, or there is no contract deployed at the token address the contract used.
This guide explains what the error means, what each case looks like (we reproduced all of them in local Foundry tests, including on a fork of Core mainnet), and how to fix it whether you are a user whose transaction failed or a developer whose contract keeps reverting.
What SafeERC20FailedOperation Means
Many ERC-20 tokens don’t behave the same way. Some return true on success and revert on failure. Some return false on failure instead of reverting. Some older tokens (USDT on Ethereum is the classic example) return nothing at all. OpenZeppelin’s SafeERC20 library wraps transfer, transferFrom and approve so a contract can handle all of them safely. When the result can’t be treated as a success, the library reverts with:
error SafeERC20FailedOperation(address token);
The single argument is the token address that caused the problem. That address is your best clue. The 4-byte selector of the error is 0x5274afe7 (we checked this with cast sig "SafeERC20FailedOperation(address)"). If a block explorer or wallet shows raw revert data starting with 0x5274afe7, this is the error you are dealing with.
Which functions can throw it
In the OpenZeppelin v5.7.0 source, SafeERC20FailedOperation is thrown by safeTransfer, safeTransferFrom, forceApprove (which safeIncreaseAllowance also uses), and the ERC-1363 “relaxed” helpers. The trySafeTransfer and trySafeTransferFrom variants, added in v5.3.0, return false instead of reverting.
What Triggers It: Test Results
The OpenZeppelin changelog for v5.1.0 changed how SafeERC20 reports failures. A missing contract now raises SafeERC20FailedOperation instead of AddressEmptyCode. Return data that can’t be decoded as a bool also raises it. When the token itself reverts, the token’s own revert message is passed through instead.
To confirm this, we wrote a small Foundry test. A simple vault contract calls safeTransfer on five kinds of “token”. We ran it against OpenZeppelin 5.6.1 and the older 4.9.6. The SafeERC20 logic in 5.6.1 matches the current 5.7.0 release except for a new, unrelated tryGetDecimals helper. Here is what each case returned:
| Token behavior | OpenZeppelin v5 (5.6.1) | OpenZeppelin v4 (4.9.6) |
|---|---|---|
Returns false |
SafeERC20FailedOperation(token) |
“SafeERC20: ERC20 operation did not succeed” |
| No contract at the address | SafeERC20FailedOperation(token) |
“Address: call to non-contract” |
| Reverts with a reason string | Token’s own reason is passed through | Token’s own reason is passed through |
| Reverts with no data | Empty revert (plain “execution reverted”) | “SafeERC20: low-level call failed” |
| Returns nothing, doesn’t revert (USDT-style) | Treated as success | Treated as success |
The key takeaway: on modern v5 contracts, a plain “insufficient balance” or “insufficient allowance” usually does not show up as SafeERC20FailedOperation. Most tokens revert in those cases, and SafeERC20 passes the token’s own error through. For example, the “ERC20: transfer amount exceeds balance” message or an ERC20InsufficientAllowance error. If you see SafeERC20FailedOperation, look first at the token address and at tokens that return false.

What we saw on a Core mainnet fork
We also ran the v5 test on a local fork of Core mainnet (chain ID 1116, block 40,598,274, forked from rpc.coredao.org on 20 November 2026). No real transactions were sent. We used Core’s bridged USDT contract at 0x9001...45F1:
- A
safeTransferfrom a vault with zero USDT reverted with “ERC20: transfer amount exceeds balance”. This is the token’s own message passed through, notSafeERC20FailedOperation. - After giving the vault test USDT on the fork, the same
safeTransfersucceeded. - Pointing the vault at an address with no contract code (
0x...dEaD) reverted withSafeERC20FailedOperation(0x000000000000000000000000000000000000dEaD).
If you want to reproduce this yourself, our guide to forking Core mainnet with Anvil covers the setup.
How to Fix SafeERC20FailedOperation (Users)
If a dApp transaction failed with this error, you usually can’t fix the contract. You can still find out why it failed and avoid wasting more gas:
- Check the token address. Open the failed transaction in the explorer and decode the error argument. Compare that address with the token’s official contract address from the project’s docs or a trusted source. Lookalike or fake tokens are a common cause.
- Make sure you are on the right network. A token address that exists on one chain may have no contract on another. If you bridged funds, confirm which token contract you actually hold on Core. Our USDT and USDC on Core guide explains the difference.
- Check whether the token can be transferred right now. Some tokens return
falsewhen transfers are paused, when an address is restricted, or when a balance or allowance check fails. Look at the token’s verified source code or announcements. - Don’t keep retrying. A failed transaction still costs gas. If the token or the dApp is misbehaving, contact the project’s official support channel. Never share your seed phrase with anyone who offers to “fix” it.
How to Fix SafeERC20FailedOperation (Developers)
1. Decode the error and read the token address
Foundry’s cast can decode the raw revert data. With the selector known, it decodes without an ABI:
cast decode-error 0x5274afe7000000000000000000000000000000000000000000000000000000000000dead \
--sig "SafeERC20FailedOperation(address)"
# 0x000000000000000000000000000000000000dEaD
2. Confirm there is code at that address
cast code <TOKEN_ADDRESS> --rpc-url https://rpc.coredao.org
If this returns 0x, there is no contract there. The usual culprits are a wrong address in a constructor or config, a testnet address used on mainnet (or the reverse), a token that hasn’t been deployed yet in your deployment script, or a typo in an environment variable.
3. Check whether the token returns false
Read the token’s verified source on the explorer. If its transfer, transferFrom or approve can return false instead of reverting, SafeERC20 turns that into SafeERC20FailedOperation. The underlying cause can still be low balance, low allowance, a pause, or a blocklist, depending on how that token is written. Simulate the token call directly (for example, with cast call using --from set to your contract’s address) to see the raw return value.
4. Use forceApprove for USDT-style approvals
Some tokens refuse to change a non-zero allowance to another non-zero value. OpenZeppelin’s forceApprove handles this: if the first approve fails, it sets the allowance to zero and tries again. If both attempts fail, it reverts with SafeERC20FailedOperation.
5. Decide whether failure should revert
When one failing token shouldn’t block a whole batch (payouts or reward claims, for example), v5.3.0 and later offer trySafeTransfer and trySafeTransferFrom. They return a bool instead of reverting:
using SafeERC20 for IERC20;
if (!token.trySafeTransfer(to, amount)) {
// record the failed payout and let the user retry or claim later
}
6. Watch for v4 vs v5 messages
Older contracts built on OpenZeppelin 4.x report the same problems as plain strings: “SafeERC20: ERC20 operation did not succeed” (token returned false), “Address: call to non-contract” (no code), and “SafeERC20: low-level call failed” (the token reverted without a reason). If you’re upgrading to v5, update any tests or front-end code that match those strings. Verifying your contracts on the explorer also helps users and tools decode errors.
FAQ
Is SafeERC20FailedOperation a bug in OpenZeppelin?
No. It’s a safety check working as designed. It stops a contract from carrying on as if a transfer succeeded when the token did not confirm it.
Does SafeERC20FailedOperation mean my funds are lost?
No. When it reverts, the whole transaction is undone, so no tokens move. You only lose the gas fee paid for the failed transaction.
What is 0x5274afe7?
It is the 4-byte selector for SafeERC20FailedOperation(address). The next 32 bytes in the revert data hold the token address.
Why do I get “execution reverted” with no message instead?
On OpenZeppelin v5.1+ contracts, if the token reverts without any data, SafeERC20 passes that empty revert through, so you see no reason at all. Our execution reverted guide covers how to dig further.
Disclaimer: This article is for educational purposes only and is not financial or investment advice. Always verify contract addresses from official sources and test on a fork or testnet before deploying or moving real funds.
