-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
173 lines (149 loc) · 5.38 KB
/
index.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
text-decoration: none;
list-style-type: none;
}
h2,
div {
text-align: center;
margin: 1em 0 1em 0;
}
button {
width: 120px;
height: 40px;
background-color: -internal-light-dark(rgb(239, 239, 239), rgb(74, 74, 74));
outline: none;
border: none;
color: blacks;
font-weight: 700;
border-radius: 3px;
}
.button.black {
background: #303030;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#656565), to(#444));
background: -moz-linear-gradient(#656565, #444);
background: linear-gradient(#656565, #444);
border: solid 1px #535353;
border-bottom: solid 3px #414141;
box-shadow: inset 0 0 0 1px #939393;
color: #fff;
text-shadow: 0 1px 0 #2f2f2f; }
.button.black:hover {
background: #4c4c4c;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#4c4c4c), to(#565656));
background: -moz-linear-gradient(#4c4c4c, #565656);
background: linear-gradient(#4c4c4c, #565656);
border: solid 1px #464646;
border-bottom: solid 3px #414141;
box-shadow: inset 0 0 0 1px #818181; }
.button.black:active {
background: #474747;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#474747), to(#444));
background: -moz-linear-gradient(#474747, #444);
background: linear-gradient(#474747, #444);
border: solid 1px #2f2f2f;
box-shadow: inset 0 10px 15px 0 #3e3e3e; }
</style>
</head>
<body>
<script>
function connectToBSC() {
if (typeof window.ethereum == 'undefined') {
alert('MetaMask is not installed!');
} else {
if (window.ethereum.chainId == "0x38") {
alert("You are already connected to the network with ID 0x38")
}
const chain = {
chainId: "0x38",
chainName: "Binance Smart Chain Mainnet",
nativeCurrency: {
name: "Binance Chain Native Token",
symbol: "BNB",
decimals: 18,
},
rpcUrls: ["https://bsc-dataseed1.binance.org", "https://bsc-dataseed2.binance.org", "https://bsc-dataseed3.binance.org", "https://bsc-dataseed4.binance.org", "https://bsc-dataseed1.defibit.io", "https://bsc-dataseed2.defibit.io", "https://bsc-dataseed3.defibit.io", "https://bsc-dataseed4.defibit.io", "https://bsc-dataseed1.ninicoin.io", "https://bsc-dataseed2.ninicoin.io", "https://bsc-dataseed3.ninicoin.io", "https://bsc-dataseed4.ninicoin.io", "wss://bsc-ws-node.nariox.org"],
blockExplorerUrls: ["https://www.bscscan.com/"],
iconUrls: [
"https://bin.bnbstatic.com/image/admin_mgs_image_upload/20201110/550eda20-1b9a-4bc7-9a65-e4a329e8bb57.png"
]
};
window.ethereum.request({
method: "wallet_addEthereumChain",
params: [chain],
}).catch((error) => {
console.log(error);
alert("An error has occurred. Please make sure the metamask is ready to go. See error in log");
});
}
}
</script>
<style>
#forkongithub a {
background: #000;
color: #fff;
text-decoration: none;
font-family: arial, sans-serif;
text-align: center;
font-weight: bold;
padding: 5px 40px;
font-size: 1rem;
line-height: 2rem;
position: relative;
transition: 0.5s;
}
#forkongithub a:hover {
background: #c11;
color: #fff;
}
#forkongithub a::before,
#forkongithub a::after {
content: "";
width: 100%;
display: block;
position: absolute;
top: 1px;
left: 0;
height: 1px;
background: #fff;
}
#forkongithub a::after {
bottom: 1px;
top: auto;
}
@media screen and (min-width:800px) {
#forkongithub {
position: fixed;
display: block;
top: 0;
right: 0;
width: 200px;
overflow: hidden;
height: 200px;
z-index: 9999;
}
#forkongithub a {
width: 200px;
position: absolute;
top: 60px;
right: -60px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.8);
}
}
</style><span id="forkongithub"><a href="https://github.com/alexey-zhdanov/metamask-to-bsc">Fork me on
GitHub</a></span>
<div><img src="./bnb.png"></div>
<h2>Connect to BSC with Metamask</h2>
<div><button class="button black" onclick="connectToBSC()">connect!</button></div>
</body>
</html>