-
Notifications
You must be signed in to change notification settings - Fork 12
/
example1.html
49 lines (43 loc) · 1.37 KB
/
example1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<script src="https://cdn.jsdelivr.net/npm/steem-tx/dist/steem-tx.min.js"></script>
<title>Test steem-tx</title>
</head>
<body>
<script>
// change api
steemTx.config.node = 'https://anyx.io'
const operations = [
[
'vote',
{
voter: 'guest123',
author: 'guest123',
permlink: '20191107t125713486z-post',
weight: 9900
}
]
]
const myKey = '5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg'
const privateKey = steemTx.PrivateKey.from(myKey)
const tx = new steemTx.Transaction()
// create transaction
tx.create(operations).then(() => {
console.log('Created transaction:', tx.transaction)
// sign the transaction
tx.sign(privateKey)
console.log('Signed transaction:', tx.signedTransaction)
// broadcast the transaction
tx.broadcast().then(res => console.log('Broadcast result:', res))
})
// get accounts
steemTx
.call('condenser_api.get_accounts', [['mahdiyari']])
.then(res => console.log('Get accounts:', res))
</script>
</body>
</html>