I want to calculate fees for historical EIP-1559 transactions on Astar EVM. For this, I need to use the GasPrice
formula:
GasPrice = BaseFee + MaxPriorityFeePerGas < MaxFeePerGas ?
BaseFee + MaxPriorityFeePerGas :
MaxFeePerGas;
MaxPriorityFeePerGas
and MaxFeePerGas
values are available in transaction data and are set by the user but BaseFee
value is not. As far as I know this value is set by the system and is dynamic. Is there a way to retrieve this BaseFee
value for historical blocks? Is this information stored in the blockchain and can it be read directly?
Solution:
In order to get baseFee
value using the Ethereum API see @gluneau answer.
When it comes to the Substrate API:
In the Astar blockchain, there exists a BaseFee
pallet, which stores the baseFee
value for each block. We can access its storage to fetch the baseFee
value for any specific block.
For instance, with the Substrate Sidecar API, we can use the following path to obtain the baseFeePerGas
value for block number 1300000:
/pallets/base-fee/storage/BaseFeePerGas?at=1300000