-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoinMint.html
More file actions
208 lines (202 loc) · 4.22 KB
/
CoinMint.html
File metadata and controls
208 lines (202 loc) · 4.22 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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html lang="en">
<head>
<title>Coin Example</title>
<script src="http://rawgit.com/ethereum/web3.js/0.16.0/dist/web3.min.js"></script>
<script>
src="https://code.jquery.com/jquery-3.1.1.min.js"
</script>
<script>
window.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') {
// Use Mist/MetaMask's provider
web3 = new Web3(web3.currentProvider);
} else {
console.log('No web3? You should consider trying MetaMask!')
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
var abi =[
{
"constant": false,
"inputs": [
{
"name": "receiver",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "mint",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "receiver",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"name": "send",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "Sent",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": true,
"name": "amount",
"type": "uint256"
}
],
"name": "CoinMinted",
"type": "event"
},
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "address"
}
],
"name": "balances",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "minter",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
];
var MyContract = web3.eth.contract(abi);
//var myContractInstance = MyContract.at('0x3711919e63d94c5dc3c669ad0002d97657b126d9');// simple copy-pase from docs
var myContractInstance = MyContract.at('0x13a201a4edf16e1cd7056689b3778d5b6fc075e6'); // version 2 - from - ex1_sending_recv_coin.txt
// Now you can start your app & access web3 freely:
startApp(abi,MyContract,myContractInstance);
})
</script>
</head>
<body>
<div>
<h4>
Mint coin - can only be called from owner, failed otherwise.
</h4>
<div>
Receiver Address : <input id='mintCoinAdd'>
</div>
<div>
Amount of coin : <input id='amount'>
</div>
</div>
<button onclick='mintCoin()'>Mint Coin</button>
</div>
<hr/>
<p>Events generated for the Mint coins:
<h3 id='callback'></h3>
</p>
<hr/>
<h4>
Send coin - can be called by anyone who has coin, failed otherwise.
</h4>
<div>
Receiver Address : <input id='receiverAdd'>
</div>
<div>
Amount of coin : <input id='amountToSend'>
</div>
<button onclick='sendCoin()'>Submit</button>
</div>
<hr/>
<p>Events generated for the coins sent:
<h3 id='callback1'></h3>
</p>
<hr/>
<div>
Find Balance of any address: <input id='checkBalAdd'>
</div>
<button onclick='checkBalance()'>Check Balance</button>
<p>Balance:
<h3 id='balanceCallback'></h3>
</p>
<hr/>
<h4>Let's fetch all the events of Mint coin
</h4>
<div>
Address(Enter, if you want to fetch the history of specific address, leave blank otherwise):
<input id='AddForFetchinEvents'>
</div>
<hr/>
<button onclick='handleAllMintCoinEvent()'>Fetch All Events</button>
<hr/>
<p><h4>Mint Coin Events:</h4>
<h3 id='MintCoinEvents'></h3>
</p>
<script type="text/javascript" src='CoinMint_helper.js'>
</script>
</body>
</html>