When I transfer USDT (ERC20) in the test environment, the code is copy from mainnet,contract address: 0xdAC17F958D2ee523a2206206994597C13D831ec7. the solidity version of USDT is 0.4.17.
I started by using the transferFrom method of IERC20,like this:
IERC20(applyToken).transferFrom(
msg.sender,
multiSign,
totalCost
);
but I got error,but no specific error content is displayed.
then I update the code,use SafeERC20 library,like this:
using SafeERC20 for IERC20;
IERC20(applyToken).safeTransferFrom(
msg.sender,
multiSign,
totalCost
);
this way I get the correct execution.
after that I add a new ERC20 contract like this:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
constructor() ERC20("MyToken", "MTK") {}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
I Using this new contract, I re-verified the two transfer methods and found that they were all successful.
Can anyone tell me what is willing to cause this problem, thanks a lot!
@abcoathup can you help me,thanks!