4
  const params = {
    to: '0xdbC0d76Fb1f2399b618FB29922dBC5cf763dd3d7',
    from: dbDeposit.depositAddress,
    value: balance,
    gas: 2000000,
    gasPrice: '234567897654321',
    nonce: 0
  };
  console.log(params);
  return web3.eth.signTransaction(params, myPrivateKey);

That's my code and I'm actually unsure as to how much gas and gasPrice to set. I understand that gasPrice is sort of an upper limit and gas is how much miners get to keep?

So how do I go about figuring out how much of each?

7

The amount you will pay for a transaction is gasPrice*gas, so gasPrice is exactly what the name indicates, is the price per 1 gas. The gas is a measure of how much computational work your transaction requires. You can omit these values and let the node select them if you do not know how to set it. The current gas price is 9000000000 yours is several orders of magnitude bigger.

Hope this helps,

5

By simulating the transaction or the call you'll be able to get a gas estimation you can put in the params object: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethestimategas

the same goes for the gas price: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethgasprice

5

As Jaime said gas price is the price you pay from computational work , ex - you have 1000 lines in your code and during transaction 500 lines gets executed then 500 will be the gas price (just a scenerio) , whereas gas limit is upper limit after which gas price computation stops.

i use gas price -- > 5000000 and gas limit --> 2000000000 for deploying and calling functions of smart contracts. This works fine for me.

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.