I read that there is an option to pass blocknumber to contract.methods.balanceOf I am currently passing it like this:

const address ='0x6C1F09F6271fbE133Db38DB9c9280307F5d22160';
  contract.methods.balanceOf(address).call((error, balance) => {
    contract.methods.decimals().call((error, decimals) => {
    //   balance = balance.div(10 ** decimals);

Any ideas how to pass the blocknumber into this?

  • 1
    And I think I told you that on a different post (though it might have been someone else's post) - don't do 10 ** decimals, because it most likely exceeds Number.MAX_SAFE_INTEGER. You can instead use 1e${decimals} encapsulated with a pair of ` , but I'm not entirely sure about the type of balance, so div might disallow this. – goodvibration Aug 29 '19 at 5:35

Change this:

call((error, balance) => {

To this:

call(null, blockNumber, (error, balance) => {
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.