0

I have check this How to convert BN result into readable string or number in ethjs?

But their solution isn't working for me

let totalTokensMinted = await myContract.methods
          .getNumberOfTokensMinted()
          .call()
          .then( (result) => {
            console.log(result) // give 15
            totalTokensMinted = result.toNumber(); //Uncaught (in promise) TypeError: result.toNumber is not a function
          })
        this.setState({ totalTokensMinted });

The method return an uint256 so I need to convert it to number.

Any clue where I am using wrong?

  • What's the signature of getNumberOfTokensMinted? – Ismael Oct 04 '21 at 05:53
  • 1
    Hi Ismael, sorry for not understand what signature is. But here is the function

    function getNumberOfTokensMinted() public view returns(uint256) { uint256 totalNumberOfTokensMinted = totalSupply(); return totalNumberOfTokensMinted; }

    – someoneuseless Oct 04 '21 at 07:47

0 Answers0