0

I have a small nodesjs app that is writing to a contract every now and then.

It works, but i had to manually check the current gas price and deploy afterwards.

What can I do to automate that? I dont want to hardcode the gasprice but set one dynamically that gets my TX through (in average) in one hour.

1

If you are using geth and you do not specify the gas prices parameter geth will set it automatically to the current standard price using information from the previous blocks.

If you need the value of the gas price that your node is using do: web3.eth.gasPrice and it will return the current gas price.

Hope this helps.

  • I'm running with infura service (i think they use in turn geth). However, web3.eth.gasPrice is undefined. web3js.readthedocs.io/en/1.0/… does work though :-) – shredding Jun 10 '18 at 6:10
  • the link you provided estimate the gas used, not the gas price. – Jaime Jun 10 '18 at 6:28

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.