forked from ethereum/btcrelay
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelayContractStatus.html
More file actions
130 lines (103 loc) · 4.46 KB
/
relayContractStatus.html
File metadata and controls
130 lines (103 loc) · 4.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ethereum: Bitcoin Relay Contract Status</title>
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/dapp.css">
<script src="./js/jquery-2.1.3.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/btcRelayAbi.js"></script>
<script src="./js/tokenContractAbi.js"></script>
<script src="./js/bignumber.js"></script>
<script src="./js/web3.min.js"></script>
<script>
var web3 = require('web3');
web3.setProvider(new web3.providers.HttpProvider('http://morden.cloudapp.net:8545'));
var heightPerRelay;
$(function() {
/*
do NOT forget to update ABI files when needed
*/
var relayAddr = '0xd34e752661c770ee2eb078326ed7a2a09acff135'; // ConsenSys testnet
// var relayAddr = web3.eth.namereg.addr('btcrelay'); // Olympic
$('#relayAddr').text(relayAddr);
updateBCI();
updateBlockr();
var RelayContract = web3.eth.contract(btcRelayAbi); // see ./js/btcRelayAbi.js
var contract = RelayContract.at(relayAddr);
heightPerRelay = contract.getLastBlockHeight.call().toString();
$('#latestBlockHeight').text(heightPerRelay);
var headHash = contract.getBlockchainHead.call();
$('#latestBlockHash').text(formatHash(headHash));
var feeVTX = web3.fromWei(contract.getFee.call(headHash), 'ether');
$('#feeVTX').text(feeVTX);
window.btcrelayTester = contract;
// signature of verifyTx is (txHash, txIndex, merkleSiblingArray, txBlockHash)
// to make a call to verifyTx so that btcrelay will get some fees,
// run this code in the browser developer console: fees will be sent
// from the coinbase
// res = btcrelayTester.verifyTx.sendTransaction(0, 1, [], 0, {from: web3.eth.coinbase, value: web3.toWei('0.1', 'ether')});
// console.log('txHash for verifyTx: ', res)
setTimeout(checkHeights, 1000);
});
function updateBCI() {
// 2 calls needed since https://blockchain.info/latestblock is missing CORS
$.getJSON('https://blockchain.info/q/getblockcount?cors=true', function(data) {
$('#bciBlockHeight').text(data);
});
// https://github.com/blockchain/api-v1-client-python/issues/17
// $.getJSON('https://blockchain.info/q/latesthash?cors=true', function(data) {
// $('#bciBlockHash').text(data);
// });
}
function updateBlockr() {
$.getJSON('http://btc.blockr.io/api/v1/block/info/last', function(data) {
$('#blockrBlockHeight').text(data.data.nb);
});
}
function checkHeights() {
var bciHeight = $('#bciBlockHeight').text();
var blockrHeight = $('#blockrBlockHeight').text();
if (!bciHeight || !blockrHeight ||
heightPerRelay === bciHeight || heightPerRelay === blockrHeight) {
$('#warnSync').hide();
}
else {
$('#nodeBlockNum').text(web3.eth.blockNumber);
$('#warnSync').show();
}
}
function formatHash(bnHash) {
var hash = bnHash.toString(16);
return Array(64 - hash.length + 1).join('0') + hash;
}
</script>
</head>
<body>
<div class="container">
<div class="logo">
<img src="./images/ethereum-logo-small.png"/>
</div>
<div class="jumbotron">
<h2><a href="https://github.com/ethereum/btcrelay">Ethereum Bitcoin Relay</a>
on <a href="https://github.com/ConsenSys/ConsenSys.github.io/wiki/ConsenSys-public-testnet">PUBLIC ETH TESTNET</a></h3>
<h3>BTC Relay: <strong id="relayAddr"></strong></h3>
<h3><a href="./js/btcRelayAbi.js">ABI</a></h2>
<h3>Latest Block Hash: <strong id="latestBlockHash"></strong></h3>
<div>
<h3 style="display: inline-block">Latest Block#: <strong id="latestBlockHeight"></strong></h3>
<div style="display: inline-block; margin-left:3em"><a href="https://blockchain.info" target="_">blockchain.info</a>: <strong id="bciBlockHeight"></strong></div>
<span><a href="https://btc.blockr.io" target="_">btc.blockr.io</a>: <strong id="blockrBlockHeight"></strong></span>
</div>
<h3 id="warnSync" style="display: none">Your Ethereum node may not be fully synced: <span id=nodeBlockNum></span>. Check <a href="https://stats.ethdev.com" target="_">stats</a>
for the latest blocks.
</h3>
<h3>ETH fee: <strong id="feeVTX"></strong></h3>
</div>
<!-- <h3>blockchain.info Latest Block Hash: <strong id="bciBlockHash"></strong></h3> -->
<!-- <div class="footer-logo">
<img src="./images/ETH_DEV_LOGO_LARGE.svg"/>
</div> -->
</div>
</body>
</html>