0

I create this contract using Remix.

When I call to totalsupply,it shows 0.

What am I doing wrong? Any help is much appreciated.

enter image description here

enter image description here

2
  • Check if your contract is deployed properly. You can also try to debug your tx. Commented Jun 29, 2018 at 4:15
  • Please copy and paste your code, rather than a screen shot. Having the actual code makes your question show up in the search results more easily - a screenshot will impede that search. Commented Jun 29, 2018 at 10:09

2 Answers 2

1

You have naming conflict here:

function totalSupply () public constant returns (uint totalSupply) {
    return totalSupply;
}

Statement return totalSupply refers to returns (uint totalSupply) rather than to totalSupply state variable.

BTW, simplest fix would be to remove this function completely, as totalSupply state variable is already declared as public, so no need to define explicit getter.

0

If you are using the compiler version greater than 0.4.18 than replace the constant with view.

1
  • 1
    Please could you expand upon your answer, as it is rather short and, as it stands, would serve better as a comment? Maybe provide an example of the corrected code? See How do I write a good answer? Commented Jun 29, 2018 at 10:12

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.