I'm using Etherscan Gas Fee API to get current gas fees in GWEI. It can only return gas fee in GWEI and I tried to find online but can't find an answer on how to convert the Fee from GWEI to ETH or to USD. How can I do that?
I can't comment on previous answer so I will just write here. the 33 gwei value that your are getting is 'per gas' . so you need to multiply this value by the amount of gas your transaction will consume. A basic ethereum transfer is 21 000 gas. so : 21000 * 0.00009063351 = 1.9 usd approximately
From ethereum.org docs -
Gas prices are denoted in gwei, which itself is a denomination of ETH - each gwei is equal to 0.000000001 ETH
You can use the above to manually convert prices from gwei to ETH.
Additionally, can use any trusted source such as the Etherscan API to find the latest ETH-USD price.
I tried it but that doesn't gives the current gas fee either in ETH or USD. For example, current gas fee on etherscan is 33 GWEI, if I used the above method, I get 0.00009063351 USD. But actually current network fees is 1.84 USD, so I guess I'm missing something here:/– AdvikFeb 27, 2022 at 7:37