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;