Truffle console weird output with getBalance()

I’m just now completing the truffle assignment to deploy the multisig wallet, and I’ve gotten it to work but there is one weird thing I don’t understand.

When I query the getBalance() view function, I don’t see the balance returned and I’m not sure what it’s displaying. Truffle works just fine for getOwners() and getTransfer() so I’m confused why it’s showing weird output for a view function that returns a uint.

getBalance()

truffle(develop)> instance.getBalance()
BN {
  negative: 0,
  words: [ 31981568, 29933858, 2220, <1 empty item> ],
  length: 3,
  red: null
}

getOwners()

truffle(develop)> instance.getOwners()
[
  '0xFb0fA9D3c78a01cc3FA04E3e8324ac5378559094',
  '0xE441Af8707e649Efd4404A74288090DC32b77400',
  '0x9411Fd0275cc3734a4BB683BD9D3ef4D8a050D68'
]

getTransfer()

truffle(develop)> instance.getTransfer(0)
[
  '0xFb0fA9D3c78a01cc3FA04E3e8324ac5378559094',
  '0xf04E2c7331E3469dDba32ff6C357d8360235f0e9',
  '5000000000000000000',
  '0',
  false,
  initiator: '0xFb0fA9D3c78a01cc3FA04E3e8324ac5378559094',
  recipient: '0xf04E2c7331E3469dDba32ff6C357d8360235f0e9',
  amount: '5000000000000000000',
  numApprovals: '0',
  completed: false
]
1 Like

Everything seems to work fine.
BN means bigNumber.
getBalance() returns an object containing the members => negative, words, length and red.
Words is showing the Balances.
try instance.getBalance().words[0] to access the first value of the words member.

Read this article for more insights.

Can you share the code of your getBalance function?
Also, try to use await web3.eth.getBalance(insertContractOrWalletAddressHere)
you can try this command directly in the truffle console.
The Web3 Library has many useful commands, have a look at the documentation.

Hope this helps.

1 Like

Thanks, that answers my question! It’s BigNumber.