I have a very simple contract.
contract MyContract {
address _owner;
modifier owner() {
require(msg.sender == _owner);
_;
}
constructor(address manager) {
_owner = manager;
}
function adminApprove(address token, uint256 amount, address spender) external owner
{
IERC20(token).approve(spender, amount);
}
}
Function adminApprove works fine for USDT and USDC on POLYGON network and works fine for USDC on ETHEREUM network, but not works for USDT on ETHEREUM network.
Error encountered during contract execution [execution reverted]
Even if I try to set amount to zero.
Help me please.
>Solution :
The USDT contract on ethereum doesn’t implement the IERC20 interface correctly. Namely, functions that are supposed to return a bool (like approve does) don’t. Since you’re using the standard IERC20 interface, your contract is looking for that return value, can’t find it, and reverts. Update your interface or use something like openzeppelin’s SafeERC20, which supports both cases.