Skip to content

Commit 97f7f21

Browse files
Add dynamic table for Gas API supported networks (#1914)
* Add Sonic to Gas API supported networks * Add dynamic table for Gas API supported networks * update what's new
1 parent 95bef68 commit 97f7f21

File tree

3 files changed

+52
-78
lines changed

3 files changed

+52
-78
lines changed

docs/whats-new.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ The latest major MetaMask documentation updates are listed by the month they wer
99
For a comprehensive list of recent product changes, visit the "Release Notes" section at the bottom
1010
of the [MetaMask developer page](https://metamask.io/developer/).
1111

12-
## February
12+
## March 2025
13+
14+
- Added full table for [Gas API supported networks](/services/get-started/endpoints/#gas-api).
15+
([#1914](https://github.com/MetaMask/metamask-docs/pull/1914))
16+
17+
## February 2025
1318

1419
- Documented [Unichain Mainnet](/services/reference/unichain) support. ([#1878](https://github.com/MetaMask/metamask-docs/pull/1878))
1520

services/get-started/endpoints.md

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ sidebar_position: 2
44
toc_max_heading_level: 3
55
---
66

7+
import GasApiNetworks from "@site/src/components/GasApiNetworks.tsx";
8+
79
# All endpoints
810

911
The following lists all the network endpoints supported by Infura.
@@ -190,80 +192,4 @@ The Gas REST API supports multiple networks.
190192

191193
Specify the chain ID in your request to interact with the relevant network.
192194

193-
#### Arbitrum
194-
195-
| Network | Chain ID |
196-
|---------|----------|
197-
| Mainnet | 42161 |
198-
| Nova | 42170 |
199-
200-
#### Avalanche (C-Chain)
201-
202-
| Network | Chain ID |
203-
|---------|----------|
204-
| Mainnet | 43114 |
205-
206-
#### Base
207-
208-
| Network | Chain ID |
209-
|---------|----------|
210-
| Mainnet | 8453 |
211-
212-
#### BNB Chain
213-
214-
| Network | Chain ID |
215-
|-----------------|----------|
216-
| Mainnet | 56 |
217-
| opBNB (layer 2) | 204 |
218-
219-
#### Cronos
220-
221-
| Network | Chain ID |
222-
|---------|----------|
223-
| Mainnet | 25 |
224-
225-
#### Ethereum
226-
227-
| Network | Chain ID |
228-
|---------|----------|
229-
| Mainnet | 1 |
230-
| Holesky | 17000 |
231-
| Sepolia | 11155111 |
232-
233-
#### Fantom
234-
235-
| Network | Chain ID |
236-
|---------|----------|
237-
| Mainnet | 250 |
238-
239-
#### Filecoin
240-
241-
| Network | Chain ID |
242-
|---------|----------|
243-
| Mainnet | 314 |
244-
245-
#### Linea
246-
247-
| Network | Chain ID |
248-
|---------|----------|
249-
| Mainnet | 59144 |
250-
| Sepolia | 59141 |
251-
252-
#### Optimism
253-
254-
| Network | Chain ID |
255-
|---------|----------|
256-
| Mainnet | 10 |
257-
258-
#### Polygon
259-
260-
| Network | Network ID |
261-
|---------|------------|
262-
| Mainnet | 137 |
263-
| Amoy | 80002 |
264-
265-
#### ZKsync Era
266-
267-
| Network | Chain ID |
268-
|---------|----------|
269-
| Mainnet | 324 |
195+
<GasApiNetworks />

src/components/GasApiNetworks.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React, { useEffect, useState } from 'react';
2+
3+
const GasApiNetworks = () => {
4+
const [networks, setNetworks] = useState({});
5+
6+
useEffect(() => {
7+
const fetchData = async () => {
8+
try {
9+
const response = await fetch('https://gas.api.cx.metamask.io/v1/supportedChainNames');
10+
const data = await response.json();
11+
setNetworks(data);
12+
} catch (error) {
13+
console.error('Error fetching data:', error);
14+
}
15+
};
16+
17+
fetchData();
18+
}, []);
19+
20+
// Convert the networks object into an array of [chainId, networkName] pairs
21+
const networksArray = Object.entries(networks);
22+
23+
return (
24+
<table>
25+
<thead>
26+
<tr>
27+
<th>Network</th>
28+
<th>Chain ID</th>
29+
</tr>
30+
</thead>
31+
<tbody>
32+
{networksArray.map(([chainId, networkName]) => (
33+
<tr key={chainId}>
34+
<td>{networkName}</td>
35+
<td>{chainId}</td>
36+
</tr>
37+
))}
38+
</tbody>
39+
</table>
40+
);
41+
};
42+
43+
export default GasApiNetworks;

0 commit comments

Comments
 (0)