-
Notifications
You must be signed in to change notification settings - Fork 6
/
injectAvalancheNetwork.js
52 lines (49 loc) · 1.24 KB
/
injectAvalancheNetwork.js
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
43
44
45
46
47
48
49
50
51
52
const AVALANCHE_MAINNET_PARAMS = {
chainId: '0xA86A',
chainName: 'Avalanche Mainnet C-Chain',
nativeCurrency: {
name: 'Avalanche',
symbol: 'AVAX',
decimals: 18,
},
rpcUrls: ['https://api.avax.network/ext/bc/C/rpc'],
blockExplorerUrls: ['https://snowtrace.io/'],
}
const AVALANCHE_TESTNET_PARAMS = {
chainId: '0xA869',
chainName: 'Avalanche Testnet C-Chain',
nativeCurrency: {
name: 'Avalanche',
symbol: 'AVAX',
decimals: 18,
},
rpcUrls: ['https://api.avax-test.network/ext/bc/C/rpc'],
blockExplorerUrls: ['https://testnet.snowtrace.io/'],
}
const AVALANCHE_LOCAL_PARAMS = {
chainId: '0xA868',
chainName: 'Avalanche Local C-Chain',
nativeCurrency: {
name: 'Avalanche',
symbol: 'AVAX',
decimals: 18,
},
rpcUrls: ['https://localhost:9650/ext/bc/C/rpc'],
blockExplorerUrls: ['https://testnet.snowtrace.io/'],
}
export default function addAvalancheNetwork(network) {
window.ethereum
.request({
method: 'wallet_addEthereumChain',
params: [
network === 'main'
? AVALANCHE_MAINNET_PARAMS
: network === 'test'
? AVALANCHE_TESTNET_PARAMS
: AVALANCHE_LOCAL_PARAMS,
],
})
.catch((error) => {
console.log(error)
})
}