This is my error message

ParserError: Expected '{' but got 'constant' --> amkcoin.sol:50:35: | 50 | function totalSupply() public constant returns (uint); | ^^^^^^^^

and this is code line..


ERC Coin Standard #20 Interface
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address CoinOwner) public constant returns (uint balance);
    function allowance(address CoinOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint Coins) public returns (bool success);
    function approve(address spender, uint Coins) public returns (bool success);
    function transferFrom(address from, address to, uint Coins) public returns (bool success);
    event Transfer(address indexed from, address indexed to, uint Coins);
    event Approval(address indexed CoinOwner, address indexed spender, uint Coins);

can u tell me whats wrong with totalSupply line any one can fix this line pls thanks.

  • Can you share the complete code from amkcoin.sol ? Thx. Commented Jun 5, 2021 at 10:42

1 Answer 1


I think you got an older version of that interface and it should say view instead of constant. If I remember correctly, constant was the predecessor to view.

For more details on the ERC20 token standard refer to the EIP20 GitHub page: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

They also link to example implementations. This probably helps you the most. Here you can find a new version of the ERC20Interface contract: https://github.com/ConsenSys/Tokens/blob/fdf687c69d998266a95f15216b1955a4965a0a6d/contracts/eip20/EIP20Interface.sol


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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