using SafeERC20 for IERC20;
require(IERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED);
both SafeERC20 and IERC20 are from openzeppelin. ^0.8.0 versions.
The above code fails and doen't get compiled.
No matching declaration found after argument-dependent lookup.
I looked into it and realize that none of the safe functions return any booleans. So how can I achieve what I want ? I need to have my own require which will have my own error message.
If you want your own error message, SafeERC20 will not be useful to you. But using IERC20 directly and checking the boolean will not help you either, because most ERC20 implementations will revert and Solidity will bubble the revert, so you would need to use try catch.