0
    var balance = await web3.eth.getBalance('0xxxx') ;
    var valueToBeSent = balance - gasPrice
    var gasPrice = await web3.eth.getGasPrice() * 21000;

    console.log(balance)
    console.log(gasPrice)
    console.log(valueToBeSent)

When I do this, I get the result NaN in valueToBeSent.

Balance=199057199990657509
gasPrice= 1000000008
valueToBeSent=NaN

Thanks !

EDIT : thanks MAJD TL

I added:

    const BN = require('bn.js');

    var a = new BN(balance);
    var b = new BN(gasPrice);

    var valueToBeSent  = a -= b;
4

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.