aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/samplecoin/samplecoin.html
blob: 7b63f78e4538b4c1e50bc0e4b0ea37ed6aa802ed (plain) (blame)
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
<html>
<head>
<title>jeffcoin</title>

<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-theme.min.css">
<link rel="stylesheet" href="samplecoin.css">
<meta name="viewport" content="minimum-scale=1; maximum-scale=1; initial-scale=1;">

<script type="text/javascript">

var jefcoinAddr = "22fa3ebce6ef9ca661a960104d3087eec040011e"
var mAddr = ""

function createTransaction() {
    var addr = ("0x" + document.querySelector("#addr").value).pad(32);
    var amount = document.querySelector("#amount").value.pad(32);

    var data = (addr + amount).unbin();
    eth.transact(mAddr, jefcoinAddr, 0, "50000", "1000000", data, function(receipt) {
        debug("received tx hash:", reciept.address)
    })
}

function init() {
    eth.getKey(function(sec) {
        mAddr = sec;
        eth.getSecretToAddress(sec, function(addr) {
            eth.getStorageAt(jefcoinAddr, addr, function(storage) {
                document.querySelector("#current-amount").innerHTML = storage;
            });

            eth.watch(jefcoinAddr, addr, function(addr, value) {
                document.querySelector("#current-amount").innerHTML = value
            });
        });
    });
}

</script>
</head>

<body onload="init();">
<div class="container">
    <div class="header">
        <h3 class="text-muted">JeffCoin</h3>
    </div>

    <div class="jumbotron ">
        <img src="icon.png">
        <div>Amount: <strong id="current-amount"></strong></div>

        <div id="transactions">
            <div class="form-group">
                <input id="addr" 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 Tx</button>
        </div>
    </div>
</div>

<div id="debug" style="border: 1px solid black; min-height: 30px;"></div>

</body>
</html>