ERC20 contract loses tokens sent to the contract's own address
See original GitHub issue🧐 Motivation Many people lose their ERC20 tokens by mistakenly sending their tokens back to the token contract address (presumably to redeem their tokens). However, there is no way to recover those tokens. https://np.reddit.com/r/ethereum/comments/sfz4kw/did_i_just_lose_half_a_million_dollars_by_sending/
📝 Details
ERC20 implementation should reject such transfers.
For example, we may add a require
statement to the _transfer
function in ERC20.sol.
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
...
require(recipient != address(this), "ERC20: transfer to the token contract address");
...
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
I accidentally sent a token to a token contract. Can I get it back?
If you sent a token to a contract address there's no way to get them back even if the contract's owner wanted. Unless...
Read more >How to prevent stuck tokens in contracts - Solidity developer
Just take a look at following token contracts. Those are all ERC-20 contracts where users sent the token directly to the contract itself,...
Read more >Prevent transferring Ethereum Tokens to 0x0 and your ...
are just stuck at the contract address. However, those locked EOS tokens will be claimed once the network is lunched according to their...
Read more >Blockchain enthusiast allegedly loses $500K by sending ...
Instead, the anonymous Reddit user sent the wETH directly back into the wETH smart contract address in the hopes of receiving ETH back....
Read more >Mistake Costs User $1.1 Million in AAVE - Decrypt
An AAVE holder mistakenly sent $1.1 million worth of the DeFi token to the token's smart contract address. · The mistake means that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello @duckki
The ERC20 standard doesn’t prevent sending tokens to the contract itself, and there might be legitimate use-cases where users lock/stake their tokens that result in the contract transferring them to itself. I’ve also seen ERC20+ICO combo contracts where the tokens are minted and given to the contract itself, and can then be bought for ETH.
So I don’t think we should include that by default for everyone.
On the other hand, we do encourage users to add these mechanisms, if they ever need it … and we make that easy for them:
I think a comment in the code will help. I’ll submit a PR to that effect.