-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTOKEN.html
More file actions
67 lines (55 loc) · 2.46 KB
/
Copy pathTOKEN.html
File metadata and controls
67 lines (55 loc) · 2.46 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
<html>
<head>
<title>Rainbow Coin</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js">
<script type="text/javascript">
//change this contract address to the one you have created!
var contractAddress = "0xfe8d5c113b5240d2950e69b64610beb1bafcce74";
//Our coloured coins are stored in our public address prefixed by the numbers 0-6 as we have added multiples of 2**160 to them.
//var Red_Address = eth.secretToAddress(eth.key);
web3.eth.watch({altered: web3.eth.accounts}).changed(function() {
web3.eth.balanceAt(web3.eth.coinbase).then(function (balance) {
document.getElementById("ether").innerText = web3.toDecimal(balance);
});
web3.eth.coinbase.then(function (coinbase) {
document.getElementById("coinbase").innerText = coinbase;
x = coinbase;
web3.eth.watch({altered: {at: coinbase, id: contractAddress}}).changed(function() {
web3.eth.stateAt(contractAddress, x).then( function(value){
document.getElementById("balance").innerText = web3.toDecimal(value);
});
});
});
});
//function createTransaction() {
// var receiverAddress = '0x' + document.querySelector("#receiverAddress").value;
// var amount = document.querySelector("#amount").value;
// var data = eth.pad(receiverAddress, 32) + eth.pad(amount, 32);
// eth.transact({from: eth.key, value: 0, to: contractAddress, data: data, gas: 5000, gasPrice: 100000}, function() {})
// }
//
//eth.watch({altered: {at: eth.secretToAddress(eth.key), id: contractAddress}}).changed(function() {
// document.getElementById("balance").innerText = eth.toDecimal(eth.stateAt(contractAddress, Red_Address));
// });
</script>
</head>
<body>
<div class="header">
<h1 class="text-muted">My Token</h1>
</div>
<div class="jumbotron">
<h3>Account: <strong id="coinbase"></strong></h3>
<h3>Ether: <strong id="ether"></strong>
<h3>Balance: <strong id="balance"></strong></h3>
<br>
<div>
<div class="form-group">
<input id="receiverAddress" class="form-control" type="text" placeholder="Receiver address"></input><br>
<input id="amount" class="form-control" type="text" placeholder="Amount"></input><br>
</div>
<button class="btn btn-default" onclick="createTransaction();">Send some tokens!</button>
</div>
</div>
</body>
</html>