0

On etherscan gas tracker there are three gas prices: Low / Avg / High.

The code var gasPrice = await provider.getGasPrice() only returns the Avg price. Sometimes I need the Low/High price, how to get them?

2
  • the only way to get low gas price is to send your TX on Saturday morning or Sunday morning of New York time
    – Nulik
    Jul 17 at 15:16
  • just pull the latest block with all the transactions and get the minimum value
    – Nulik
    Jul 17 at 15:17
1

If you want the exact data from Etherscan gas tracker you can use their APIs.

Gas Oracle API (docs):

https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken

Response:

{
  "status": "1",
  "message": "OK",
  "result": {
    "LastBlock": "12845223",
    "SafeGasPrice": "21",
    "ProposeGasPrice": "24",
    "FastGasPrice": "25"
  }
}

Note that the free tier API key has a rate limit of 5 req/s, you might need to cache or upgrade the key for production usage.

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.