I am trying to build a smart contract that is using my custom token. Below you can find the sample of smart contract that I have created that showcases the approve function.
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.11;
import "IERC20.sol";
contract Contract {
address public contractOwner;
IERC20 token;
constructor() {
token = IERC20(0x000000000000); //your token here
contractOwner = msg.sender;
}
function Approvetokens(uint256 _tokenamount) public returns(bool){
token.approve(address(this), _tokenamount);
return true;
}
}
Then, in my react application I am using a function to call the contract like so:
async addTokens() {
let abc = process.env.myPrice // where I have tried with either 1 or 1*1000000000 (as my token has 9 digits)
await this.state.myContract.methods.Approvetokens(abc).send({
from:this.state.account
});
}
The contract gets called and metamask is opening the transaction, but the price to pay is HUGE, please see the screenshot below. I am connected to the fantom test network, but replicated this in Rinkeby as well.
I do not understand what I am doing wrong here...
token = IERC20(0x000000000000);