Skip to content

Commit 5e0c21e

Browse files
committed
Add dynamic table for Gas API supported networks
1 parent 3630ee3 commit 5e0c21e

File tree

2 files changed

+46
-83
lines changed

2 files changed

+46
-83
lines changed

services/get-started/endpoints.md

Lines changed: 3 additions & 83 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.
@@ -189,86 +191,4 @@ The Gas REST API supports multiple networks.
189191

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

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