BaseFeePerGas unit

I am using eth_feeHistory for EIP-1559 based transactoin and confuse regarding unit to use. baseFeePerGas in wei or gwei?

Gwei WEI is the amount you have to enter.

Hey @sachin_bisht

eth_feeHistory will return you values in wei, and also, when you're pricing a transaction, you have to provide in wei as well.

An example

curl -X POST -H 'Content-Type: application/json' --data \
'{"jsonrpc":"2.0","method":"eth_feeHistory","params":["0xa", "latest", []], "id": 1}'  \
<<YOUR_RPC_ENDPOINT>>


{"jsonrpc":"2.0","id":1,"result":{"baseFeePerGas":["0x2afd81e64","0x2b5a499a9","0x299004bce","0x2b0c66efa","0x2cc5cf304","0x2c56a76f3","0x2b57ed1f3","0x2c9eb1722","0x2c482ce61","0x2c26c2e7b","0x2ae7b9c44"],"gasUsedRatio":[0.5337213333333334,0.33483253333333335,0.6430011,0.6602145666666667,0.46120846666666665,0.41023326666666665,0.6177970666666667,0.4697032,0.48820976666666666,0.3870946],"oldestBlock":"0xf600db"}}

As you can see, values are expressed in the order of 1e9. For example, 0x2c482ce61 is 11.88e9

@CryptoWorld is also correct but only from a UI that takes care of parsing the values correctly. Or am I missing something?

Best to both

2 Likes

No you are absolutely right, it is WEI, i have no idea why i typed gwei :frowning:

1 Like

No problem @CryptoWorld
I was asking anyway in case I was missing a case :smiley:

Best