forked from techaddict0x/airdropwithafee
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
95 lines (88 loc) · 3.15 KB
/
index.html
File metadata and controls
95 lines (88 loc) · 3.15 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>AirDrop</title><script defer="defer" src="/static/js/main.5dc0fc35.js"></script><link href="/static/css/main.9eb342aa.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Switch MetaMask Network</title>
<style>
/* Reset CSS to remove default margins and paddings */
body, h1, h2, h3, p, ul, li {
margin: 0;
padding: 0;
}
body {
display: flex;
justify-content: flex-start;
align-items: flex-start;
height: 100vh;
overflow-x: hidden;
background-image: url('static/media/background.3390ab6403f61adf3d42.jpg');
background-size: cover;
}
#popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: red;
color: white;
border: none;
border-radius: 15px; /* Add rounded corners */
cursor: pointer;
}
</style>
</head>
<body>
<script>
async function checkConnection() {
if (window.ethereum) {
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
if (chainId !== '0x41a6ace') {
// Show the popup if connected to the wrong network
document.getElementById('popup').style.display = 'block';
} else {
// Remove the check button if connected to the right network
document.getElementById('checkButton').style.display = 'none';
}
} else {
console.error('MetaMask not found');
}
}
async function switchToCustomChain() {
if (window.ethereum) {
try {
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x41a6ace',
chainName: 'FrameTestnet',
nativeCurrency: {
name: 'ETH',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: ['https://rpc.testnet.frame.xyz/http'],
blockExplorerUrls: ['https://explorer.testnet.frame.xyz'],
}],
});
console.log('Switched to FrameTestnet (Chain 0x41a6ace)');
// Hide the popup after successfully switching to FrameTestnet
document.getElementById('popup').style.display = 'none';
// Add your code to enable website functionality after switching
} catch (error) {
console.error('Error switching chain:', error);
}
} else {
console.error('MetaMask not found');
}
}
</script>
<!-- Popup -->
<button id="popup" onclick="switchToCustomChain()">Switch to FrameTestnet</button>
<!-- Check Button -->
<button id="checkButton" onclick="checkConnection()">Check Network</button>
</body>
</html>