0

For some reason all my functions are able to return my calls except this one particular function. I call it using Truffle.

async function asdf() {
let contractInstance = await MyContract.at('0x...')
let currentSupply = await contractInstance.getCurrentSupply()
console.log(`Current Supply: ${currentSupply}`);
}

When I return it, it doesn't show up as 0. I put return 1 just to see if it would even return anything, but it's still returning 0

function getCurrentSupply() constant returns (uint256) {
    return 1;
}
  • I'm not sure "1" is a uint256. Have you tried "returns (uint)" instead? – Florian Castelain Jan 11 '18 at 0:53
  • uint is an alias for uint256. And 1 is definitely a valid value for uint256. – smarx Jan 11 '18 at 1:58
  • Hey, It would be better if you share some snippet from your code, but you can change MyContractInstance.getCurrentSupply() to MyContractInstance.getCurrentSupply.call() I am not sure but it can be the case – Mehmet Doğan Oct 26 '18 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.