Balance of account returns 0, yet mint function is set to 1000

After entering the mint function,
contract MyToken is ERC20 {
constructor() ERC20(“MyToken”, “MTKN”) {
_mint(msg.sender, 1000);

followed as the video instructs and get this in the terminal:

truffle(develop)> instance.balanceOf(accounts[0])
BN {
negative: 0,
words: [ 1000, <1 empty item> ],
length: 1,
red: null
}
truffle(develop)> result.toNumber
[Function: toNumber]

Please help?

Hi @VEXAHEDRON

Looks good to me

BN {
negative: 0,
words: [ 1000, <1 empty item> ],
length: 1,
red: null
}

You are parsing the result wrongly, use:

  • console.log(result.toString())
  • console.log(Number(result))
  • console.log(parseInt(result))

cheers,
Dani

1 Like