onERC20Received for safe ERC20 transfers

I see that ERC721's safeTransferFrom expects an onERC721Received function in the receiving contract. SafeERC20 also has a safeTransferFrom function, but the meaning appears to be completely different.

Is there a reason there isn't an onERC20Received interface implemented for contracts receiving ERC20 tokens? I do see online references to onERC20Received, but it's not implemented in the standard OZ contracts AFAICT.

Reference: https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#IERC721-safeTransferFrom-address-address-uint256-bytes-

Apologies for the confusion. These two functions are indeed different even though they are named the same! There is no onERC20Received standard.

1 Like

I see. Thank you. Is there a reason for this discrepancy? onERC721Received seems like a valuable concept. Why not apply it to ERC 20s as well?

ERC20 and ERC721 were developed separately, that explains why they're different.

A token would be able to add an onERC20Received but there are better and more standard alternatives to this currently, namely using permit.

1 Like