I wrote the following contract:
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract enviaToken { address public tokenAddress = 0x; address public acc1 = 0x; address public acc2 = 0x; function giveAllowance() public { IERC20 token = IERC20(tokenAddress); token.approve(address(this), 1); } function send() public { IERC20 token = IERC20(tokenAddress); require(token.allowance(acc1, address(this)) > 0); uint256 saldoacc1 = token.balanceOf(acc1); require(saldoacc1 >= 1 ether, "Saldo insuficiente na acc1"); require(token.transferFrom(acc1, acc2, 1)); } } But when I call the send function in remix i receive the "insufficient allowance" error...
This is just a test contract, thats why I hardcoded the address (removed the hex here).
My MetaMask is connected to the remix, when I deploy, call "giveAllowance" and "send" a Pop-Up appears.
My acc1 has 100 tokens in Sepholia.
I searched everywhere, and always is the same answer: call the approve function to give allowance.
But even giving the needed allowance (calling the "giveAllowance" before transfering, successfully) I got the error.


