0

after some trouble with remix I'm back at a npm/truffle/ganache setup...

The reason why I tried out remix was:

DeclarationError: Undeclared identifier. Did you mean "mint"?
        _mint(to, amount);

And what can I say... stuck at the same place:

pragma solidity >=0.5.0 <0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";


contract Testyis IERC20, Ownable {
   using SafeMath for uint256;
   using SafeMath for uint8;
   
   address _owner;
   
   
...
   

constructor () public {
    _owner = address(msg.sender);
    _decimals = 18;

...
    
    function mint(address to, uint256 amount) public {
        require((pre == msg.sender), "Caller is not a minter");
        _mint(to, amount);
    }

    function burn(address from, uint256 amount) public {
        require((pre == msg.sender), "Caller is not a burner");
        _burn(from, amount);
    }
}

"pre" is in this case another contract. When I use remix and import ERC20Detailed with a "normal" github path, then it works. Okay the other contract cant mint or burn, but at least I can do it and also set the pre address.

Hope someone can help :)

2
  • IERC20 does not define function _mint. – goodvibration Dec 18 '20 at 21:27
  • Cant use ERC20 need to override ... even when it should supported I cant .... – M Token Dec 18 '20 at 22:08
1

Function _mint is not declared in interface IERC20.

However, it is implemented as an internal function in contract ERC20.

So just change contract Test is IERC20 to contract Test is ERC20.

By the way, even if function _mint was declared in interface IERC20, your code still wouldn't compile because you'd need to implement that function in the contract which inherits that interface.

1
  • Can't override function anymore if I use ERC20 Even when I use the latest openzeppelin/contracts "dependencies": { "@openzeppelin/contracts": "^3.3.0", "truffle": "^5.1.57", "zeppelin-solidity": "^1.12.0" }, – M Token Dec 18 '20 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.