I am trying to mint ERC20 tokens from another contract. I will add this contract address to the 'minter' role on the ERC20 contract.
I've noted below where I get the error. It's unclear to me why totalSupply() works but _mint(...) does not.
Also I am interested in why some functions on Open Zepplin contracts begin with an underscore.
Thank you !
pragma solidity ^0.8.3;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract claimTest {
ERC20 public token;
ERC20 public token2;
address private tokenAddress;
uint private fixedAmount;
constructor () {
}
function setToken(ERC20 _token) public {
token = _token;
}
function setAddress(address _address) public {
tokenAddress = _address;
token2 = ERC20(_address);
}
// Error
// Member "mint" not found or not visible after argument-dependent lookup in contract ERC20
function claim() public {
token._mint(msg.sender, fixedAmount);
}
// This works
function totalSupply() public view returns (uint) {
return token.totalSupply();
}
}