Hello, 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:
Environment
"truffle": { "version": "5.1.57", "resolved": "https://registry.npmjs.org/truffle/-/truffle-5.1.57.tgz", "integrity": "sha512-hash", //there is a real hash ... feels kind of unconfy sharing hashes without to know for what they are "requires": { "app-module-path": "^2.2.0", "mocha": "8.1.2", "original-require": "1.0.1" } },
compilers: { solc: { version: "0.7.0", // Fetch exact version from solc-bin (default: truffle's version) docker: false, // Use "0.5.1" you've installed locally with docker (default: false) settings: { // See the solidity docs for advice about optimization and evmVersion optimizer: { enabled: false, runs: 200 }, evmVersion: "byzantium" } } }
{ "name": "participate", "version": "1.0.0", "description": "", "main": "truffle-config.js", "directories": { "test": "test" }, "dependencies": { "@openzeppelin/contracts": "^3.3.0", "truffle": "^5.1.57", "zeppelin-solidity": "^1.12.0" }, "devDependencies": {}, "scripts": { "test": "mocha" }, "author": "", "license": "ISC" } };
Details
"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.
Code to reproduce
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);
}
}
EDIT
Ok missunderstud ERC20 / IERC20 - but I would like to override ERC20 methodes and I get the error:
TypeError: Trying to override non-virtual function. Did you forget to add "virtual"?
function name() public view returns (string memory) {
Even when my openzeppelin is version 3.3.0 as you see..
But I guess thats another thread ...