9

On Remix, when implementing the contract suggested here - https://www.youtube.com/watch?v=JHrQ3l2tT78 - I'm getting the error "This contract does not implement all functions and thus cannot be published."

I've seen other posts saying that the constructor function needs to list parameters, but I've tried adding parameters to "NewToken" without success. Perhaps I'm adding these wrong, but given that the tut doesn't have any, I figure I might be doing something else wrong.

Appreciate any help.

pragma solidity ^0.4.11;

import './IERC20.sol';

/**
 * @title Standard ERC20 token
 */
contract NewToken is IERC20 {

    uint public constant _totalSupply = 1000000;
    uint8 public constant _decimals = 3;
    string public constant _symbol = 'NTK';
    string public constant _name = 'NewToken';

    mapping(address => uint256) balances;
    mapping(address => mapping(address => uint256)) approved;


    function NewToken() public {
        balances[msg.sender] = _totalSupply;
    }

    function decimals() public constant returns (uint8 decimals) {
        return _decimals;
    }

    function totalSupply() public constant returns (uint256 totalSupply) {
        return _totalSupply;
    }

    function balanceOf(address _owner) public constant returns (uint256 balance) {
        return balances[_owner];
    }

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(
            balances[msg.sender] >= _value && _value > 0    
        );
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        require(
            approved[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0
        );
        balances[_from] -= _value;
        balances[_to] += _value;
        approved[_from][msg.sender] -= _value;
        Transfer(_from, _to, _value);
        return true;
    }

    function approve(address _spender, uint256 _value) public returns (bool success) {
        approved[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
        return true;
    }

    function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
        return approved[_owner][_spender];
    }

    event Transfer(address indexed _from, address indexed _to, uint256 _value);

    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

}

IERC20.sol

pragma solidity ^0.4.11;

interface IERC20 {
    function decimals() public constant returns (uint8 decimals);
    function totalSupply() public constant returns (uint256 totalSupply);
    function balanceOf(address _owner) public constant returns (uint256 balance);
    function transfer(address _to, uint256 _value) public returns (bool success);
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
    function approve(address _spender, uint256 _value) public returns (bool success);
    function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
2

I decided to load your code in Remix and see for myself, and ... no problems.

Possibly the issue is one of familiarity with Remix or Solidity. The IERC20 contract cannot be compiled because it just describes a bunch of function signatures without defining what they do. That's what NewToken does. Main takeaway, you can compile, create and deploy NewToken as expected. Remix let' you choose, but only one choice will succeed.

Also. there is a quite new Remix I haven't quite got accustomed to, yet. The pic is using the old Remix at https://yann300.github.io/remix04. I wouldn't rule out that your issues may stem from the freshness of the Remix release.

Here it is in Remix to show it working.

enter image description here

Hope it helps.

  • Hmm, thanks. I think it is the old vs. the new remix. He shows the old remix in his sample as well, and this new one appears buggy in other ways. How does one get to the "old" remix? – daprezjer Oct 2 '17 at 22:57
  • Old Remix: yann300.github.io/remix04 – Rob Hitchens - B9lab Oct 2 '17 at 23:15
3

I had the same warning but in my case, it was related to the constructor access modifier. I had to change "internal" to "public" and It when all smooth :) just to say that there are different cases when you can have this situation.

2

Arg, yes, in the new UI (and maybe the old one), you select which one you want to publish on swarm or create, and I simply needed to alter the dropdown to the contract instead of the interface. Wasn't obvious from the tutorial. Stupid, but hopefully someone else finds this useful. Thanks!

1

I got this error; and this was the solution: When using inheritance and the superClass has a constructor which takes arguments, you have two ways to inherit from it:

contract Base {
    uint x;
    constructor(uint _x) public { x = _x; }
}

// Either directly specify in the inheritance list...
contract Derived1 is Base(7) {
    constructor() public {}
}

// or through a "modifier" of the derived constructor.
contract Derived2 is Base {
    constructor(uint _y) Base(_y * _y) public {}
}

Source: https://solidity.readthedocs.io/en/v0.5.0/contracts.html#arguments-for-base-constructors

0

The new remix interface throws this error when one of your functions has an internal/private visibility keyword, but should be public/external.

Double checking your visibility keywords should fix the issue.

  • Thanks @thegostep but see above, the answer was that the wrong funciton was selected. – daprezjer Nov 14 '17 at 19:59

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.