0

We are creating a cryptocurrency analytics website and I am currently trying to calculate the transaction confirmation time just like in the ETH gas tracker (https://etherscan.io/gastracker).

The API docs over here (https://docs.etherscan.io/api-endpoints/gas-tracker#get-estimation-of-confirmation-time) say that you should use this type of request indicating the current gasprice in WEI.

https://api.etherscan.io/api?module=gastracker&action=gasestimate&gasprice=2000000000&apikey=YourApiKeyToken

Let's imagine that the current high gasprice is 32 GWEI (29 base + 3 priority), which I must multiply by 1,000,000,000 to get the value in WEI and replace this value in the link above.

https://api.etherscan.io/api?module=gastracker&action=gasestimate&gasprice=32000000000&apikey=YourApiKeyToken

The response is in seconds and it's 45, but the thing is that I am not receiving any other types of responses apart from 45 and 3615 using this link irrespective of the &gasprice value.

Tried replacing it with a value as low as 2000000000 or as high as 120000000000. The results are either 45 seconds or 3615 seconds and neither are true to the current gas tracker values on the Etherscan page.

Am I doing something wrong? Etherscan says that "gasprice is the price paid per unit of gas, in wei", but am I understanding this calculation right? Thanks a lot!

1 Answer 1

0

Well, it's not that you doing something wrong but you must understand that there are some cases:

  • You pay much more than the highest gas fee: Block isn't created every second, it takes more than few. Also, your transaction might take time to arrive to miners. this time isn't related to your gwei amount and it might be a base time like 45 seconds.

  • You pay much less than the lowest gas fee: Than your transaction might never be accepted and you'll get some max statistic evalutaion.

Because it's really edgy, try inserting the exact current gas price and check for the time, than you'll see other estimations.

Also check:

https://api.etherscan.io/api
   ?module=gastracker
   &action=gasoracle
   &apikey=YourApiKeyToken
4
  • The link for the gas oracle API you provided is exactly what we're using for the calculation of the exact current gas price. It's calculated by summing the base and priority fees. However, irrespective of the current gas price, the transaction confirmation time APIs respond with either 45 or 3615 all the time. I tried it out with over 25 different values, the response is the same. Oct 11, 2022 at 20:40
  • try the exact gwei price, in the current second, like this for now: api.etherscan.io/… @buckwhitzer
    – matank001
    Oct 11, 2022 at 20:45
  • Okay, I think I'm getting it. We probably should request the current gas price and transaction confirmaiton estimate simultaneously in order to get true-to-life values. Am I understanding it right? Oct 11, 2022 at 20:58
  • Exactly, because one gwei to here or to here really matters in a specific second
    – matank001
    Oct 11, 2022 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.