I'm new on Ethereum blockchain and I'm working on deploy and using smart contract using truffle on my private blockchain.

I have followed exactly this guide https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts

But every time i call getBalance() function

  truffle(develop)> let balance = await instance.getBalance(accounts[0])
  truffle(develop)> balance.toNumber()

I get the error: Returned values are not valid, did it run Out of Gas

So I added a simply smart contract getNumber() then return a simply integer (3) and I always get the same error.

But if I invoke sendCoin() function I don't get any error and i write correctly the transaction.

So i get the error any time i try to get values from blockchain.

Someone can help me?

1 Answer 1


The result of a view (read-only) function in web3.js and ethjs are object-like types, with string keys for the integer positions of the return values.

If you stringified it, it would look like {'0': BN<some balance here>}

Try balance['0'].toNumber()

If your view functions return multiple values, it would look like

`{'0': val0, '1': val1, ... }`

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.