2

I was wondering what is the case when the plain transferFrom ERC20 method fails silently, i.e., just returning false.

Looking at the code, to me it looks like when the balance is insufficient or the allowence is the low, it'd just throw an error. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

Am I missing something?

1 Answer 1

2

Not all ERC20 tokens follow the OpenZeppelin implementation that you linked. Some implementations of ERC20 tokens will not revert and will simply return false if the transaction failed. This could lead to unexpected behaviour if you expect a failed transfer to revert.

In ERC20 safeTransferFrom library implementations (e.g. solmate, solady, and OpenZeppelin) the helper method will ensure that the function reverts if false is returned from transferFrom.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.