Skip to main content
added 200 characters in body
Source Link
Micah Zoltu
  • 955
  • 2
  • 8
  • 22

Yes. You will need to figure out how much gas (in ETH) the transaction will cost, but luckily simple ETH transfers are exactly 21,000 gas (I think, double check this number). This means to know how much ETH will be spent on gas you will need to multiply that by the chosen gas price (e.g., 10^10).

So your calculation will need to look something like this:

var gasPrice = 20*10**9;
var gas = 21000;
var attoethForGas = gasPrice * gas;
var amountToSend = web3.toWei(1) - attoethForGas;

Yes. You will need to figure out how much gas (in ETH) the transaction will cost, but luckily simple ETH transfers are exactly 21,000 gas (I think, double check this number). This means to know how much ETH will be spent on gas you will need to multiply that by the chosen gas price (e.g., 10^10).

Yes. You will need to figure out how much gas (in ETH) the transaction will cost, but luckily simple ETH transfers are exactly 21,000 gas (I think, double check this number). This means to know how much ETH will be spent on gas you will need to multiply that by the chosen gas price (e.g., 10^10).

So your calculation will need to look something like this:

var gasPrice = 20*10**9;
var gas = 21000;
var attoethForGas = gasPrice * gas;
var amountToSend = web3.toWei(1) - attoethForGas;
Source Link
Micah Zoltu
  • 955
  • 2
  • 8
  • 22

Yes. You will need to figure out how much gas (in ETH) the transaction will cost, but luckily simple ETH transfers are exactly 21,000 gas (I think, double check this number). This means to know how much ETH will be spent on gas you will need to multiply that by the chosen gas price (e.g., 10^10).