-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetamask_add_network.html
42 lines (40 loc) · 1.56 KB
/
metamask_add_network.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MetaMask Network Adder</title>
</head>
<body>
<h1>MetaMask Network Adder</h1>
<button id="addNetworkButton">Add Berachain Artio Network</button>
<script>
const addNetworkButton = document.getElementById('addNetworkButton');
addNetworkButton.addEventListener('click', async () => {
if (window.ethereum) {
try {
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x1385D', // 80085 in hexadecimal
chainName: 'Berachain Artio',
nativeCurrency: {
name: 'BERA',
symbol: 'BERA', // 2-6 characters long
decimals: 18
},
rpcUrls: ['https://artio.rpc.berachain.com/'],
blockExplorerUrls: ['https://artio.beratrail.io/']
}]
});
} catch (addError) {
console.error('Error adding network:', addError);
}
} else {
alert('MetaMask is not installed. Please install it to use this feature.');
}
});
</script>
</body>
</html>