This repository has been archived by the owner on Feb 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.html
49 lines (42 loc) · 1.98 KB
/
example.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
<script src="metahash.min.js"></script>
<script>
metahash.apiUrl = 'http://172.104.224.65:5795'; // net-dev
// http://venus.mhscan.com/?page=address&id=0x009af1b05f5fa19d7054c0deeab32ecb3b1adac6c7f02b2c0b
metahash.fetchBalance('0x0003f6441039b7f944c82ac62f7c124918e02c203b5820f5ed', (res, err) => {
if (res) console.log('fetchBalance', res);
else console.error('fetchBalance', err)
});
// http://venus.mhscan.com/?page=address&id=0x009af1b05f5fa19d7054c0deeab32ecb3b1adac6c7f02b2c0b
metahash.fetchHistory('0x009af1b05f5fa19d7054c0deeab32ecb3b1adac6c7f02b2c0b', (res, err) => {
if (res) console.log('fetchHistory', res);
else console.error('fetchHistory', err)
});
// http://venus.mhscan.com/?page=tx&id=23fb8f98f1faecf04c23112ad47bba7b42ff7bcec0cdf22ce231061d02e9ad2c
metahash.getTx('23fb8f98f1faecf04c23112ad47bba7b42ff7bcec0cdf22ce231061d02e9ad2c', (res, err) => {
if (res) console.log('getTx', res);
else console.error('getTx', err)
});
metahash.balanceFormatter(20962350000);
let publicKeyBase64 = 'MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE8gBrTLUQxXDZQ4f/OpiFWe4dhNbEo11PtFkq/0NgXt+AxGwmiWUhojtI56Hj2H3QpxGZCqrjxldDC4IHzpyVfw=='; // from key.pub
metahash.apiUrl = 'http://139.162.42.43:9999'; // ?????????
let to = '0x0003f6441039b7f944c82ac62f7c124918e02c203b5820f5ed';
let value = 1000;
let fee = 0;
let nonce = null;
let data = '';
let publicKeyHex = metahash.base64toHex(publicKeyBase64); // convert from base64 to hex
/*
1. openssl ec -in key.pem -noout -text
2. copy "priv" value:
42:d1:ae:22:4c:27:fc:02:a4:bc:43:b9:ec:47:6b:
bd:21:b4:51:69:db:97:35:f9:c6:1d:31:a0:87:21:
04:4f
3. remove symbol ":"
*/
let privateKey = '42d1ae224c27fc02a4bc43b9ec476bbd21b45169db9735f9c61d31a08721044f';
let youHashAddress = '0x009b84f533aa2192456a7e944eb471183abbceafe678a98984';
metahash.createTx(to, value, fee, nonce, data, publicKeyHex, privateKey, youHashAddress, (res, err) => {
if (res) console.log('createTx', res, 'http://mhscan.com/?page=tx&id=' + res.params);
else console.error('createTx', err)
});
</script>