I want my contract to use my token. So I coded it like this. first my token code
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
contract Elena is ERC20{
constructor(string memory name, string memory symbol) ERC20(name,symbol){
// mint 1000 token
_mint(msg.sender, 100000*10**18);
}
}
and my contract
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
import "./myToken.sol";
contract FundingTest{
uint public constant MINIMUM_AMOUNT = 1 ether;
address myToken;
IERC20 private _currencyContract;
constructor(address _myToken){
myToken = _myToken;
_currencyContract = IERC20(myToken);
}
function funding(uint sendMoney) public payable {
_currencyContract.approve(msg.sender, sendMoney*10**18);
_currencyContract.approve(address(this),_currencyContract.totalSupply());
_currencyContract.transferFrom(msg.sender, address(this), sendMoney*10**18);
}
function currentBalance() public view returns(uint256){
return _currencyContract.balanceOf(address(this));
}
}
Token issuance is confirmed. But this kind of error happens
please help me