Description
The API query for eth_getBlockByNumber does not give correct "gas", "gas price", and "L1BlockNumber" details.
Query:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "id": 5, "method": "eth_getBlockByNumber", "params": ["0xdb58de", true]}' "https://opt-mainnet.g.alchemy.com/v2/<MY_API_ID>"
Response:
{ "jsonrpc": "2.0", "id": 5, "result": { "number": "0xdb58de", //14375134 "difficulty": "0x2", "extraData": "0xd98301090a846765746889676f312e31352e3133856c696e7578000000000000c3ab3a2a0ffb1ca35b12967d4f5efd4ee64ee06202e344c4e339859d9b71883b28c9ea423a8b08aa9ae08101fd7240dcbbf0e28ddb0796b5a8c9e358d34f69f201", "gasLimit": "0xe4e1c0", //15000000 "gasUsed": "0x3540d", //218125 //l2 gas used by tx "hash": "0x830e63c03eadc3108bf8bb7cc35cb51fd35350b73dc11a9a9cdbf2a8f3c33aad", "logsBloom": "0x00000002000400000000009000000000000000000000000404040000000000000001000000000000000000100000000000000040000020000000010000040000000000800000000800000008000000000000000000000000000004008000000010000000000000000000101000010000000000020000000000000010800800000000000000000000000000000000000000000401002000000000001000000000000000000000000000000000800001000000000000000000000000000000000000020002000000000000000000800000000000000000000000000000000000000000000000010000000000000000000400000000008000400000000000011000", "miner": "0x0000000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": "0x0000000000000000", "parentHash": "0x7dba5ebb8615d4e23432ee60c952d5adde1f1edf503b39bbd92bc9ce96e62a61", "receiptsRoot": "0x51f4c4552350dcdf04b3ec837b3f256dda48e31e02fc5e6e0721164c61065578", "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "size": "0x97d", "stateRoot": "0xfc4400d157b2f193862a6ceebded34d9f1723cc5b57b0419b5cecb69d5284bc7", "timestamp": "0x62ce8900", //1657702656 "totalDifficulty": "0x1b6b1bd", "transactions": [ { "hash": "0x815804d4fdf5786ff955658f21191fcdf34c7ad437d0d5f517ff83b4a97325cf", \\tx hash "blockHash": "0x830e63c03eadc3108bf8bb7cc35cb51fd35350b73dc11a9a9cdbf2a8f3c33aad", "blockNumber": "0xdb58de", //14375134 "from": "0xc6c3e4bbcdc719e7b5793a31a36937f729605c33", "gas": "0x4f294", //324244 "gasPrice": "0xf4240", //1000000 //l2gasprice "index": "0xdb58dd", //14375133 "input": "0x415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000a1045f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000060000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000012556e6973776170563300000000000000000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000a1045f000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f47f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd0000000000000000000000003ce37278de6388532c3949ce4e886f365b14fb5600000000000000000000000000000000000000000000001f4a14c6b462ce88f1", "l1BlockNumber": "0xe6ea7d", //15133309 "l1Timestamp": "0x62ce8900", "nonce": "0x5a", //90 "queueOrigin": "sequencer", "r": "0x9ee8e6c2f2916d0cf16cbe3b1ae1d58b39f7edfdc740b39d2b72882ab6867393", "rawTransaction": "0xf907145a830f42408304f29494def1abe32c034e558cdd535791643c58a13acc10872386f26fc10000b906a8415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000a1045f00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000060000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000012556e6973776170563300000000000000000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000a1045f000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002b42000000000000000000000000000000000000060001f47f5c764cbc14f9669b88837ca1490cca17c31607000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000004200000000000000000000000000000000000006000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd0000000000000000000000003ce37278de6388532c3949ce4e886f365b14fb5600000000000000000000000000000000000000000000001f4a14c6b462ce88f138a09ee8e6c2f2916d0cf16cbe3b1ae1d58b39f7edfdc740b39d2b72882ab6867393a00194b4bf431dc430facd52bea4e1e00f5609cb43a3ab12d7b6951e7959c0105f", "s": "0x194b4bf431dc430facd52bea4e1e00f5609cb43a3ab12d7b6951e7959c0105f", "to": "0xdef1abe32c034e558cdd535791643c58a13acc10", "transactionIndex": "0x0", "v": "0x38", //56 "value": "0x2386f26fc10000" //10000000000000000 wei } ], "transactionsRoot": "0xf27d553d0d8dd4d0166056ec016f94e329106529a59f827fe1d7b7181ddfae7f", "uncles": [] } }
The response does not have all gas details required to calculate transaction fee. Also L1 block number as per explorer (https://optimistic.etherscan.io/batch/91177) is 15133361, but response shows 15133309.
To calculate transaction fee, "gasprice", "gasused", "l1gasprice", "l1gasused", and "l1feescalar" are required as per explorer (https://optimistic.etherscan.io/tx/0x815804d4fdf5786ff955658f21191fcdf34c7ad437d0d5f517ff83b4a97325cf). But all values are missing from the response.
The response has gas limit instead of gas used, and L1 gas details are missing