Can you please double-check this command for me and tell me if I screwed up the units?

eth.sendTransaction({ from: "blah", to: "blah", value:20000000000000000, nonce:5, gas:120000, gasPrice:80000000000 })

I had a little panic attack afterward about whether I was supposed to put gasPrice in wei or gwei. I checked the documentation and it says wei, but nevertheless I'd like the peace of mind of a second set of eyes.

If one screws it up and puts in a ridiculously high gas price beyond the available funds, will that burn up all of what's remaining in the account before it fails?


You can use web3.toWei to easily convert amounts to wei from other units

    from: "blah",
    to: "blah",
    value: web3.toWei(0.02, "ether"),
    nonce: 5,
    gas: 120000,
    gasPrice: web3.toWei(80, "gwei")

Also useful is web.fromWei to convert from wei to other units

> web3.fromWei("80000000000", "gwei");
> web3.fromWei("20000000000000000", "ether");
  • Thanks; this is very helpful! So my values were reasonable? i.e. My gasPrice was 80 gwei and I was sending 0.02 eth? What happens if you screw up and use a ballistic gas price either within or outside the means of your account balance? Does anything protect you from a typo with extra zeroes recklessly burning through all your account funds? – rkagerer Sep 14 '17 at 4:02
  • 1
    Gas price is a dynamic value, sometime during a popular ICO the cost goes up. You can use ethgasstation.info to determine the convenient price at given moment, ie how much time can you wait for a transaction to be mined vs the price you want to pay. A good wallet can calculate the total of a transaction, but otherwise if you have enough funds there's nothing that can save you if you put too many zeros in the gas price. – Ismael Sep 14 '17 at 7:41
  • Thanks that answers my question. Ethgasstation.info was down at the time so I just looked at gas prices of recent transactions on Etherscan.io and added a nice fat margin. – rkagerer Sep 18 '17 at 14:31

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.