I'm trying to implement contract which interacts with ERC-20 via interface. Code of interface was taken from openzeppelin github.
The problem is that it fails any transaction which triggers contract func.
What have I done wrong? :(
Example: Following func checks if sender has enough tokens of ERC-20 and sender allowed to spend tokens earlier. If conditions are success it transfers tokens from sender to custom contract address.
function deposit(uint256 amount) public {
require(tokenContract.balanceOf(msg.sender) >= amount, "Sender has not enough balance");
require(tokenContract.allowance(msg.sender, address(this)) >= amount, "Contract is not allowed to transfer tokens");
require(tokenContract.transferFrom(msg.sender, address(this), amount) == true, "Could not send tokens from the buyer");
}
Extra info:
- sender has enough tokens to spend
- sender has approved custom contract before transaction
Failed transaction url: https://rinkeby.etherscan.io/tx/0x8df7513a0da10645ce3e300399e73bb58d28dcb8bddb92bddf40945751ae69fc
Sample contract code url: https://rinkeby.etherscan.io/address/0x479a28cff2194a67ccb95ddb960d09fcbb127462#code
ERC-20 (USDT) contract code url: https://rinkeby.etherscan.io/address/0x75cb130d6bbd3d915b34573dc3dd3fb45184f12f#code