OpenZeppelin / openzeppelin-contracts

OpenZeppelin Contracts is a library for secure smart contract development.
https://openzeppelin.com/contracts
MIT License
25.02k stars 11.82k forks source link

Can't Deploy Burnable, Mintable & Capped Token #1545

Closed Dycedlp closed 5 years ago

Dycedlp commented 5 years ago

Coin.sol:

pragma solidity ^0.4.24;

import "./ERC20Burnable.sol";
import "./ERC20Capped.sol";

contract Coin is ERC20Burnable, ERC20Capped {

    uint constant public decimals     = 18;
    string constant public name       = "XTZ Coin";
    string constant public symbol     = "XTZ";

    /**
      * @dev Initialize the test token
      */
    constructor () public {
    }

}

-- I have all the other inherited contracts in the remix IDE just published the coin.

💻 Environment Remix IDE

📝 Details

Says the contract doesn't implement all functions therefore can't be created.

🔢 Code to reproduce bug

Using the new open zeppelin contracts.

nventuro commented 5 years ago

Hey there @Dycedlp! The snippet you posted seems to be correct, could you share your full contract and the complete error message? Thanks!

Dycedlp commented 5 years ago

Ok @nventuro when I try to publish this coin.sol it says "This contract does not implement all functions and thus cannot be created." I have ERC20mintable.sol, Roles.sol, IERC20.sol, ERC20Burnable.sol, ERC20.sol, ERC20Capped.sol, MinterRole.sol, Safemath.sol and then finally the coin.sol in my Remix IDE directory... I was under the impression you had to just deploy the coin for it to function. Is there any chance you have a working example of a burnable + mintable/capped erc20 token? Or know how I can fix this contract to work/deploy? I'm using the newest commit of the 0.4.24 compiler as well, everything compiles perfect.

nventuro commented 5 years ago

Hmm, that error message should show you which functions it is that you're not implementig. Are you sure the contract you're deploying is the one you made, and now one of the OpenZeppelin ones (e.g. IERC20)?

Something like this ought to work for what you intend:

pragma solidity ^0.4.24;

import "openzeppelin-solidity/token/ERC20/ERC20Capped.sol";
import "openzeppelin-solidity/token/ERC20/ERC20Burnable.sol";

contract SimpleToken is ERC20Capped, ERC20Burnable {
    uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals()));

    constructor (uint256 cap) public ERC20Capped(cap) {
        _mint(msg.sender, INITIAL_SUPPLY);
    }
}