Skip to content

Commit c5ebe11

Browse files
committed
feat: added 'add network to wallet' button
1 parent e1525d3 commit c5ebe11

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

docs/general-info/add-status-network.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ description: Step-by-step guide on how to add Status Network to MetaMask and oth
44
keywords: [Status Network, MetaMask setup, add network, wallet configuration, RPC settings, Chain ID, blockchain network setup]
55
---
66

7+
import AddToMetaMask from '@site/src/components/AddToMetaMask';
8+
79
# Add Status Network
810

911
This guide shows how to add the **Status Network** to your wallet.
1012

11-
## Testnet
13+
You can add Status Network Testnet directly by clicking on the button below:
14+
15+
<AddToMetaMask />
16+
17+
18+
## Manual Configuration
1219

1320
To add **Status Network Testnet** as a custom network to MetaMask:
1421

docs/general-info/network-details.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import AddToMetaMask from '@site/src/components/AddToMetaMask';
2+
13
# Network Details
24

35
## Status Testnet
@@ -11,6 +13,9 @@
1113
| **Block Explorer** | https://sepoliascan.status.network |
1214
| **Bridge** | https://bridge.status.network |
1315

16+
<AddToMetaMask />
17+
<div style={{height: '2rem'}} />
18+
1419
These are the official network details for the Status Network testnet. You can use these details to:
1520
- Add the network to your wallet
1621
- Configure development environments

src/components/AddToMetaMask.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
3+
export default function AddToMetaMask(): JSX.Element {
4+
const addStatusNetwork = async () => {
5+
if (typeof window === 'undefined' || !window.ethereum) {
6+
alert('MetaMask is not installed. Please install MetaMask first.');
7+
return;
8+
}
9+
10+
try {
11+
await window.ethereum.request({
12+
method: 'wallet_addEthereumChain',
13+
params: [{
14+
chainId: '0x6300B5EA',
15+
chainName: 'Status Network Testnet',
16+
nativeCurrency: {
17+
name: 'ETH',
18+
symbol: 'ETH',
19+
decimals: 18
20+
},
21+
rpcUrls: ['https://public.sepolia.rpc.status.network'],
22+
blockExplorerUrls: ['https://sepoliascan.status.network']
23+
}]
24+
});
25+
} catch (error) {
26+
console.error(error);
27+
alert('Failed to add the network to MetaMask. Please try again.');
28+
}
29+
};
30+
31+
return (
32+
<button
33+
className="button button--primary"
34+
onClick={addStatusNetwork}
35+
>
36+
<img
37+
src="https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Fox.svg"
38+
alt="MetaMask Fox"
39+
style={{
40+
width: '20px',
41+
height: '20px',
42+
marginRight: '8px',
43+
verticalAlign: 'middle'
44+
}}
45+
/>
46+
Add Status Network Testnet
47+
</button>
48+
);
49+
}

src/types/global.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
interface Window {
2+
ethereum?: {
3+
request: (args: {
4+
method: string;
5+
params: any[];
6+
}) => Promise<any>;
7+
};
8+
}

0 commit comments

Comments
 (0)