I need some help to try to fix this issue. I'm building a lottery contract that uses a ERC20 created token and i get that error once i try to execute the BuyTicket function. This is all the changes i had made but i keep getting that error.
address public tokenAddress; //Custom Token Address
...
constructor(address payable _token) {
lotteryOperator = msg.sender;
expiration = block.timestamp + duration;
tokenAddress = _token;
lotteryId = 1;
}
....
function BuyTickets() public payable {
require(
msg.value % ticketPrice == 0,
string.concat(
"the value must be multiple of ",
Strings.toString(ticketPrice),
" Ether"
)
);
uint256 numOfTicketsToBuy = msg.value / ticketPrice;
...
IERC20(tokenAddress).approve(msg.sender, numOfTicketsToBuy);
IERC20(tokenAddress).transferFrom(msg.sender, address(this), numOfTicketsToBuy);
players.push(payable(msg.sender));
...
require(
numOfTicketsToBuy <= RemainingTickets(),
"Not enough tickets available."
);
for (uint256 i = 0; i < numOfTicketsToBuy; i++) {
tickets.push(msg.sender);
}
}
I get that error when it calls the IERC20.
Thanks