When using the PolkadotJS API to query an ink! erc20 smart contract balanceOf() function from inside of react it returns some strange values. For example if i try this from a node script balanceOf.output returns these values the way you'd expect (a balance of 99 tokens). However, inside of react when querying balanceOf on a users token balance the only values i can seem to find that correspond to balance values are ones inside of balanceOf.output.words;

this is the output of querying the account of a user who has a token balance of 99 enter image description here

as you can see inside of output the only values that appear to correspond to balance values are inside of word but are not what you would expect (would expect 99)

any ideas how to interpret these values or convert them such that they display the true value of the users balance?

1 Answer 1




Reference: https://polkadot.js.org/docs/api-contract/start/contract.read#reading-contract-values

  • 1
    Yes this worked, thanks. I was using toHuman on the wrong value! Silly. Thanks again
    – nvx
    Mar 8, 2022 at 21:48

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.