Does require(transferFrom) equal to SafeERC20 library?

Is using require(IERC20(tokenaddress).transferFrom(from, to, amount)) same as using the safeTransferFrom using SafeERC20 library?

My question is if using require transferFrom guarantees the security(or could something go wrong, something that SafeERC20 library solves?)


I think no, in your case, require(IERC20(tokenaddress).transferFrom(from, to, amount)) should be used for a standard ERC20 token if tokenaddress is an ERC20 token, for example, it can be DAI or USDC, but it can not be USDT, USDT is not a standard ERC20 token, that is it does have a return value for the function transferfrom, so in order to be more compatible with standard token and non-standard token, I think you should use SafeERC20 library, but this is up to you.


That's right. There are some non-standard ERC20 tokens that do not have the required boolean return values, and the SafeERC20 library handles those properly as well.

1 Like