0

I'm using ganache network, truffle network, web3, chai and mocha.

while using truffle console in terminal it shows: truffle(develompment)> balance

BN {
negative: 0,

words: [ 16777216, 62077800, 20718012, <1 empty item> ],

length: 4,

red: null }

what i'm try to acheieve is <BN 56bc75e2d6300000>

can you please help me i'm new to this field feel free to ask anything which i'm missing

Truffle-config-js :

  require('babel-register'); 

  require('babel-polyfill');

  module.exports = {

   networks:{

     development: {

       host: '127.0.0.1',

       port: '7545',

       network_id: '*'

     },
  },

  contracts_directory: './src/centracts',

  contracts_build_directory: './src/truffle_abis',

  compilers: {

    solc: {

      version: '^0.5.0',

      optimizer: {

        enabled: true,

        runs: 200

    },
  }

}}

Tether.sol:

enter image description here

enter image description here

1 Answer 1

0

The problem is that javascript doesn't support large numbers required by solidity so web3 wraps them in an BN object. You can make the more legible with .toString().

For example:

truffle(develompment)> balance.toString()
4
  • Hey Thanks for your effort i use this and it shows 1 million tether but when I put truffle(development)> balance its shows BN { negative: 0, words: [ 16777216, 62077800, 20718012, <1 empty item> ], length: 4, red: null } instead of <BN 56bc75e2d6300000> Commented Nov 20, 2021 at 15:06
  • @AhmedYarKhan It is a javascript / BN thing. I don't think you can change it, perhaps it changes depending on the node version.
    – Ismael
    Commented Nov 20, 2021 at 16:32
  • thanks brother can i share its code to you so can check it and help me and also Thanks a lot man Commented Nov 20, 2021 at 22:48
  • @AhmedYarKhan Sure you can add the code to the question. What's the value supposed to be? What does balance.toString() print?
    – Ismael
    Commented Nov 21, 2021 at 3:44

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.