-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.html
More file actions
51 lines (48 loc) · 1.64 KB
/
index.html
File metadata and controls
51 lines (48 loc) · 1.64 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ethereum</title>
<h1>Ethereum static demo</h1>
</head>
<body>
<p>Content:</p>
</body>
<script src="assets/web3.min.js"></script>
<script src="assets/ABI.js"></script>
<script>
// Create JS API from contract ABI & bytecode located on rinkeby
// ABI is defined in <script src="assets/ABI.js">
var rinkebyAddress = '0xa016a2a7760f7779e5f0c1ae8788415547c67caa';
function main() {
greeterContract = window.greeterContract;
// See what our greeter says
greeterContract.greet((err, data) => {
print("Errors: " + err);
print("Data: " + data);
});
greeterContract.getBlockNumber((e,d) => {
print("Block number: " + d);
});
}
function print(str) {
document.body.innerHTML += "<pre>" + str + "</pre>";
}
// Wait for load event to get metamask injected web3
window.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') {
// Use Mist/MetaMask's provider
window.web3 = new Web3(web3.currentProvider);
if (window.web3.isConnected()) {
print("Web3 connected");
}
} else {
print('No web3? You should consider trying MetaMask!');
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
window.greeterContract = web3.eth.contract(ABI).at(rinkebyAddress);
main();
});
</script>
</html>