I am using geth to transfer some ether to another account.

After geth attach to my node, I just do is the following


eth.sendTransaction({from:eth.accounts[0], to:'0x....', value: web3.toWei(0.05, "ether")})

In a transaction I did a few days ago I paid 0.00168 Ether ($2.30) transaction fees. The transaction was confirmed in under a minute, so I want to to manually reduce the transaction fee if I am not in a rush to get my transaction confirmed.

In this post I see that you can set the gas price to any value you want by supplying a gasPrice argument in eth.sendTransaction(). I also now check in ethgasstation.info that a "standard" gas price is 114 Gwei. I also see in the documentation that the units of gasPrice is wei.

My question is how would I put my desired gas price in my sending transaction? I don't want to make a big mistake with units and drain my whole account by paying huge fees! Would I put something like

eth.sendTransaction({from:eth.accounts[0], to:'0x....', value: web3.toWei(0.05, "ether"), gasPrice:114e9})



Ok so what you wanna do is:

eth.sendTransaction({from:eth.accounts[0], to:'0x....', value: web3.toWei(0.05, "ether"), gas: 21000, gasPrice: 50000000000});

In my example, gas is the gas amount used by the transaction ( it should always be 21000 when transfering ethers, because that's how much ether transfer costs on the ethereum blockchain ) and the gasPrice parameter defines how fast you want your transaction to be confirmed ( the higher tax you pay the faster your transaction will be accepted by the miners and confirmed ). The value is in wei, you can this eth calculator to convert gwei into wei and set the proper value. The value that I've set in the example 50000000000 wei are actually 50 gwei.

  • So is it mandatory to supply a gas argument when supplying a gasPrice? – Panos Feb 7 at 16:18
  • Both parameters are optional. – Miroslav Nedelchev Feb 8 at 3:04

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.