This index tracks the gas_spent_per_block
for Base L2 blocks. It sums up the total gas spent per transaction across a block, as defined as:
Total Gas Spent Per Transaction=(Effective GasPrice×GasUsed)+L1 Fee
Breaking down a Base transaction
What exactly is included in the index calculation?
Value | Definition |
---|---|
Gas price | This is the Gas price that the user paid for the Base L2 transaction. This includes both Priority Fee and Base Fee (Note: this is a term inherited from ETH, not the Base L2). |
Gas usage by txn | The actual gas unit that the transaction consumes |
L1 fee | The total amount of fee the transaction pays to post on Ethereum L1. This is not equal to L1 gas price × L1 gas used. |
Edge case: Transactions without L1 fee
There are two type of 0 l1_fee tx,System
and Legacy
. There are no more Legacy
-type tx after March 2024. All 0 l1 fee transactions are System
type. We can treat the l1Fee
as 0.
Legacy type is 126 in the
type
field
Edge case: Block re-org
Currently, all L2 data that comes from L1, such as deposits, are processed only after being confirmed in an L1 block. Therefore, there haven't been any reorganizations caused by L1 reorgs or hard forks yet. Since there is currently a single sequencer, uncle blocks or forked blocks do not exist either.
Source
Failsafe for re-org
To be absolutely safe, we can also query the latestfinalized
block, for example:
curl https://docs-demo.base-mainnet.quiknode.pro/ \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"eth_getBlockByNumber","params":["finalized",true],"id":1,"jsonrpc":"2.0"}'
What is excluded from the index calculation?
Field | Description |
---|---|
Gas fees (Base) | The fee transaction has to pay at the time of the block |
Gas fees (Max) | The maximum of total gas the user is willing to pay for the transaction |
Gas fees (Max priority) | The maximum of gas the user is willing to pay to the validator for the transaction |
Gas limit | The maximum amount of computational work a user is willing to pay for in a single transaction |
L1 gas used by txn | The amount of gas units that the transaction consumes when posted on ETH L1 |
L1 gas price | The gas price on Ethereum L1 that this transaction pays |
L1 fee scalar | This is a preventative premium in case L1 gas fee spikes |
Transaction fee | The total amount of gas fee the user pays for the transaction. Transaction fee = L2 base fee + L2 priority fee + L1 fee = (Gas usage x Gas price) + L1 fee |
Querying the data
Query from Base nodes from Quicknode .
Field | Description | Description |
---|---|---|
| Fetch full transaction object from a block by block number Iterate all transactions and get the hash of each transaction | |
| Fetch transaction Receipt using the hash from above |
Sample Response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0x7ab08ca50352724d43982b714b8df7d49198f0c19249687275be78b609431668",
"blockNumber": "0x156cf89",
"contractAddress": null,
"cumulativeGasUsed": "0x17e3433",
"effectiveGasPrice": "0x1af57f6",
"from": "0x79c88d58666313fc39b1929294376af298dd8c14",
"gasUsed": "0x78e9",
"l1BaseFeeScalar": "0x8dd",
"l1BlobBaseFee": "0x1ce2291bd",
"l1BlobBaseFeeScalar": "0x101c12",
"l1Fee": "0xca71da6f35",
"l1GasPrice": "0x3441aa4ca",
"l1GasUsed": "0x640",
"logs": [
{
"address": "0xc5bf05cd32a14bffb705fb37a9d218895187376c",
"topics": [
"0x5548c837ab068cf56a2c2479df0882a4922fd203edb7517321831d95078c5f62",
"0x00000000000000000000000079c88d58666313fc39b1929294376af298dd8c14",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"data": "0x000000000