-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path11_1602613925863.html
96 lines (81 loc) · 2.67 KB
/
11_1602613925863.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
<!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>11</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<style type="text/css">
button {
background-color: #000;
color: #fff;
border: 0;
font-size: 1em;
}
</style>
</head>
<body>
<!DOCTYPE HTML>
<html>
<head>
<title> show_num Eth Contract </title>
</head>
<body>
<h2>show_num eth contract</h2>
<label for="num_in">Enter Number:</label>
<input id="num_in">
<button onclick="send_number()">Send Number to Contract</button>
<p>Show Number:</p>
<p id="num_out"></p>
<button onclick="reveal_number()">Get Number from Contract</button>
<script>
web3.eth.defaultAccount = web3.eth.accounts[0];
const contract_abi = [{"constant":true,"inputs":[],"name":"test","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set_num","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"reveal_num","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}];
const contract_address = "0xb421a6223b29b6791ad231bb1788ad9a38115834";
var contract_inst = web3.eth.contract(contract_abi).at(contract_address);
function send_number()
{
contract_inst.set_num(Number(document.getElementById("num_in").value), (err, res) =>
{
if(!err)
console.log(res);
else
console.error(err);
});
}
function reveal_number()
{
contract_inst.reveal_num((err, res) =>
{
if(!err)
{
document.getElementById("num_out").innerText = res;
console.log(res);
}
else
console.error(err);
});
}
</script>
</body>
</html>
<script type="text/javascript">
window.BuidlProviders = {
web3: {
url: "https://www.ethercluster.com/etc",
chainId: "61",
gasPrice: "3000000000",
gasLimit: "5000000",
},
es: {
url: "https://etc.search.secondstate.io"
}
}
</script>
<script type="text/javascript" src="https://buidl.secondstate.io/embed/main.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
</script>
</body>
</html>