Skip to content

Commit 34ba62e

Browse files
authored
v2.0.0 (#22)
* feat(schema): txprice * feat: gasPrice response obj * feat: gasUsed obj * feat: Transaction Type * feat: blockNumber type * feat: chainId type * Create typeHydratedTransaction.json * feat reference results(report): metamask_suggestedGasFees.json (#30) * feat reference results(report): metamask_suggestedGasFees.json * feat(schema): metamask source: <"https://gas.api.infura.io/networks/1/suggestedGasFees"> * docs(readme): add new metamask endpoint
1 parent 8981e2f commit 34ba62e

File tree

10 files changed

+616
-3
lines changed

10 files changed

+616
-3
lines changed

README.md

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ Bacha, S. (2024) “SoK EVM Gas Pricing Methods, Mechanics and Transaction Prici
3535

3636
<!-- TOC start (generated with https://github.com/derlin/bitdowntoc) -->
3737

38-
- [Gas Price Reporting Index](#gas-price-reporting-index)
39-
* [EVM Gas Reporting Index: Catalogue of Transaction Pricing Services and their implementation differences ](#evm-gas-reporting-index-catalogue-of-transaction-pricing-services-and-their-implementation-differences)
38+
- [Ethereum Gas Price Reporting Index](#ethereum-gas-price-reporting-index)
4039
* [EIP-2930: Optional Access List transactions](#eip-2930-optional-access-list-transactions)
4140
+ [Accessed addresses](#accessed-addresses)
4241
+ [`eth_createAccessList`](#eth_createaccesslist)
4342
- [Conclusion](#conclusion)
43+
* [MetaMask Gas Fee API](#metamask-gas-fee-api)
44+
+ [Example Return](#example-return)
4445
* [Gas Fee Speed Definitions](#gas-fee-speed-definitions)
4546
* [Gas Reporting Table Format](#gas-reporting-table-format)
4647
* [Gas Snapshot Format](#gas-snapshot-format)
@@ -92,8 +93,21 @@ Bacha, S. (2024) “SoK EVM Gas Pricing Methods, Mechanics and Transaction Prici
9293
+ [URL Index](#url-index)
9394
+ [EVM Params](#evm-params)
9495

95-
<!-- TOC end -->
9696

97+
```
98+
author = {Bacha, Sam},
99+
license = {CC-2.5-NC/MIT},
100+
title = {{Gas Reporting Index}},
101+
url = {https://github.com/sambacha/gas-reporting},
102+
version = {2.0.0},
103+
month = {11},
104+
year = {2021-2024}
105+
}
106+
```
107+
108+
```
109+
Bacha, S. (2021, 2022, 2024). EVM Gas Reporting Index: Catalog of Transaction Pricing Services and their implementation differences (Version 2.0.0) [Computer software]. ~~https://doi.org/10.5281/zenodo.1234~~
110+
```
97111

98112

99113
<!-- TOC --><a name="gas-price-reporting-index"></a>
@@ -183,6 +197,86 @@ That is, it gives you the list of addresses and storage keys that will be used b
183197

184198
Does this mean that we always save gas when using transaction’s with access lists? No.
185199

200+
201+
## MetaMask Gas Fee API
202+
203+
> <https://gas.api.infura.io/networks/1/suggestedGasFees>
204+
205+
> **NOTE**
206+
> GET https://gas.api.infura.io/networks/${chainId}/suggestedGasFees
207+
208+
209+
- `low`, `medium`, `high` - Object containing recommended values for transactions by level of urgency:
210+
- `suggestedMaxPriorityFeePerGas`: `string` - The maximum suggested priority fee per gas (in gwei) to pay to have transactions included in a block.
211+
- `suggestedMaxFeePerGas`: `string` - The maximum suggested total fee per gas (in gwei) to pay, including both the base fee and the priority fee.
212+
- `minWaitTimeEstimate`: `number` - The minimum estimated wait time (in milliseconds) for a transaction to be included in a block at the suggested gas price.
213+
- `maxWaitTimeEstimate`: `number` - The maximum estimated wait time (in milliseconds) for a transaction to be included in a block at the suggested gas price.
214+
- `estimatedBaseFee`: `string` - The current estimated base fee per gas on the network.
215+
- `networkCongestion`: `number` - The current congestion on the network, represented as a number between `0` and `1`. A lower network congestion score (for example `0.1`), indicates that fewer transactions are being submitted, so it's cheaper to validate transactions.
216+
- `latestPriorityFeeRange`: `array` - The range of priority fees per gas for recent transactions on the network.
217+
- `historicalPriorityFeeRange`: `array` - The range of priority fees per gas for transactions on the network over a historical period.
218+
- `historicalBaseFeeRange`: `array` - The range of base fees per gas on the network over a historical period.
219+
- `priorityFeeTrend`: `string` - The current trend in priority fees on the network, either `up` or `down` (whether it's getting more expensive or cheaper).
220+
- `baseFeeTrend`: `string` - The current trend in base fees on the network, either `up` or `down` (whether it's getting more expensive or cheaper).
221+
222+
> source <https://docs.metamask.io/services/reference/gas-api/api-reference/gasprices-type2/>
223+
>
224+
>
225+
226+
### Example Return
227+
228+
| Priority Level | Suggested Max Priority Fee Per Gas | Suggested Max Fee Per Gas | Min Wait Time Estimate (ms) | Max Wait Time Estimate (ms) |
229+
|----------------|------------------------------------|---------------------------|-----------------------------|-----------------------------|
230+
| Low | N/A | N/A | 15000 | 60000 |
231+
| Medium | 0.97 | 11.694730357 | 15000 | 45000 |
232+
| High | 2 | 19.249566308 | 15000 | 30000 |
233+
234+
| Additional Data | Value |
235+
|--------------------------|-----------------|
236+
| Estimated Base Fee | 7.499811438 |
237+
| Network Congestion | 0.0305 |
238+
239+
240+
```jsonc
241+
{
242+
"low": {
243+
"suggestedMaxPriorityFeePerGas": "0.008836",
244+
"suggestedMaxFeePerGas": "7.508647438",
245+
"minWaitTimeEstimate": 15000,
246+
"maxWaitTimeEstimate": 60000
247+
},
248+
"medium": {
249+
"suggestedMaxPriorityFeePerGas": "0.97",
250+
"suggestedMaxFeePerGas": "11.694730357",
251+
"minWaitTimeEstimate": 15000,
252+
"maxWaitTimeEstimate": 45000
253+
},
254+
"high": {
255+
"suggestedMaxPriorityFeePerGas": "2",
256+
"suggestedMaxFeePerGas": "19.249566308",
257+
"minWaitTimeEstimate": 15000,
258+
"maxWaitTimeEstimate": 30000
259+
},
260+
"estimatedBaseFee": "7.499811438",
261+
"networkCongestion": 0.0305,
262+
"latestPriorityFeeRange": [
263+
"0.0094",
264+
"5.249868006"
265+
],
266+
"historicalPriorityFeeRange": [
267+
"0.000824616",
268+
"269.34304631"
269+
],
270+
"historicalBaseFeeRange": [
271+
"7.061724017",
272+
"10.741515604"
273+
],
274+
"priorityFeeTrend": "up",
275+
"baseFeeTrend": "up",
276+
"version": "0.0.1"
277+
}
278+
```
279+
186280
<!-- TOC --><a name="gas-fee-speed-definitions"></a>
187281
## Gas Fee Speed Definitions
188282

ref/metamask_suggestedGasFees.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"low":{"suggestedMaxPriorityFeePerGas":"0.008836","suggestedMaxFeePerGas":"7.508647438","minWaitTimeEstimate":15000,"maxWaitTimeEstimate":60000},"medium":{"suggestedMaxPriorityFeePerGas":"0.97","suggestedMaxFeePerGas":"11.694730357","minWaitTimeEstimate":15000,"maxWaitTimeEstimate":45000},"high":{"suggestedMaxPriorityFeePerGas":"2","suggestedMaxFeePerGas":"19.249566308","minWaitTimeEstimate":15000,"maxWaitTimeEstimate":30000},"estimatedBaseFee":"7.499811438","networkCongestion":0.0305,"latestPriorityFeeRange":["0.0094","5.249868006"],"historicalPriorityFeeRange":["0.000824616","269.34304631"],"historicalBaseFeeRange":["7.061724017","10.741515604"],"priorityFeeTrend":"up","baseFeeTrend":"up","version":"0.0.1"}

src/schema/blockNumber.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Block number",
3+
"schema": {
4+
"title": "hex encoded unsigned integer",
5+
"type": "string",
6+
"pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$"
7+
}
8+
}

src/schema/gasPrice.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Gas price",
3+
"schema": {
4+
"title": "Gas price",
5+
"type": "string",
6+
"pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$"
7+
}
8+
}

src/schema/gasUsed.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Gas used",
3+
"schema": {
4+
"title": "hex encoded unsigned integer",
5+
"type": "string",
6+
"pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$"
7+
}
8+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"properties": {
5+
"low": {
6+
"type": "object",
7+
"properties": {
8+
"suggestedMaxPriorityFeePerGas": {
9+
"type": "string"
10+
},
11+
"suggestedMaxFeePerGas": {
12+
"type": "string"
13+
},
14+
"minWaitTimeEstimate": {
15+
"type": "integer"
16+
},
17+
"maxWaitTimeEstimate": {
18+
"type": "integer"
19+
}
20+
},
21+
"required": [
22+
"suggestedMaxPriorityFeePerGas",
23+
"suggestedMaxFeePerGas",
24+
"minWaitTimeEstimate",
25+
"maxWaitTimeEstimate"
26+
]
27+
},
28+
"medium": {
29+
"type": "object",
30+
"properties": {
31+
"suggestedMaxPriorityFeePerGas": {
32+
"type": "string"
33+
},
34+
"suggestedMaxFeePerGas": {
35+
"type": "string"
36+
},
37+
"minWaitTimeEstimate": {
38+
"type": "integer"
39+
},
40+
"maxWaitTimeEstimate": {
41+
"type": "integer"
42+
}
43+
},
44+
"required": [
45+
"suggestedMaxPriorityFeePerGas",
46+
"suggestedMaxFeePerGas",
47+
"minWaitTimeEstimate",
48+
"maxWaitTimeEstimate"
49+
]
50+
},
51+
"high": {
52+
"type": "object",
53+
"properties": {
54+
"suggestedMaxPriorityFeePerGas": {
55+
"type": "string"
56+
},
57+
"suggestedMaxFeePerGas": {
58+
"type": "string"
59+
},
60+
"minWaitTimeEstimate": {
61+
"type": "integer"
62+
},
63+
"maxWaitTimeEstimate": {
64+
"type": "integer"
65+
}
66+
},
67+
"required": [
68+
"suggestedMaxPriorityFeePerGas",
69+
"suggestedMaxFeePerGas",
70+
"minWaitTimeEstimate",
71+
"maxWaitTimeEstimate"
72+
]
73+
},
74+
"estimatedBaseFee": {
75+
"type": "string"
76+
},
77+
"networkCongestion": {
78+
"type": "number"
79+
},
80+
"latestPriorityFeeRange": {
81+
"type": "array",
82+
"items": [
83+
{
84+
"type": "string"
85+
},
86+
{
87+
"type": "string"
88+
}
89+
]
90+
},
91+
"historicalPriorityFeeRange": {
92+
"type": "array",
93+
"items": [
94+
{
95+
"type": "string"
96+
},
97+
{
98+
"type": "string"
99+
}
100+
]
101+
},
102+
"historicalBaseFeeRange": {
103+
"type": "array",
104+
"items": [
105+
{
106+
"type": "string"
107+
},
108+
{
109+
"type": "string"
110+
}
111+
]
112+
},
113+
"priorityFeeTrend": {
114+
"type": "string"
115+
},
116+
"baseFeeTrend": {
117+
"type": "string"
118+
},
119+
"version": {
120+
"type": "string"
121+
}
122+
},
123+
"required": [
124+
"low",
125+
"medium",
126+
"high",
127+
"estimatedBaseFee",
128+
"networkCongestion",
129+
"latestPriorityFeeRange",
130+
"historicalPriorityFeeRange",
131+
"historicalBaseFeeRange",
132+
"priorityFeeTrend",
133+
"baseFeeTrend",
134+
"version"
135+
]
136+
}

src/schema/txprice.schema.json

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"properties": {
5+
"system": {
6+
"type": "string"
7+
},
8+
"network": {
9+
"type": "string"
10+
},
11+
"unit": {
12+
"type": "string"
13+
},
14+
"maxPrice": {
15+
"type": "number"
16+
},
17+
"currentBlockNumber": {
18+
"type": "number"
19+
},
20+
"msSinceLastBlock": {
21+
"type": "number"
22+
},
23+
"blockPrices": {
24+
"type": "array",
25+
"items": {
26+
"type": "object",
27+
"properties": {
28+
"blockNumber": {
29+
"type": "number"
30+
},
31+
"baseFeePerGas": {
32+
"type": "number"
33+
},
34+
"estimatedTransactionCount": {
35+
"type": "number"
36+
},
37+
"estimatedPrices": {
38+
"type": "array",
39+
"items": {
40+
"type": "object",
41+
"properties": {
42+
"confidence": {
43+
"type": "number"
44+
},
45+
"price": {
46+
"type": "number"
47+
},
48+
"maxPriorityFeePerGas": {
49+
"type": "number"
50+
},
51+
"maxFeePerGas": {
52+
"type": "number"
53+
}
54+
},
55+
"required": [
56+
"confidence",
57+
"price",
58+
"maxPriorityFeePerGas",
59+
"maxFeePerGas"
60+
]
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}

src/schema/typeChainId.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Chain ID",
3+
"schema": {
4+
"title": "hex encoded unsigned integer",
5+
"type": "string",
6+
"pattern": "^0x([1-9a-f]+[0-9a-f]*|0)$"
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Hydrated transactions",
3+
"required": true,
4+
"schema": {
5+
"title": "hydrated",
6+
"type": "boolean"
7+
}
8+
}

0 commit comments

Comments
 (0)