-
Notifications
You must be signed in to change notification settings - Fork 0
/
addbundles.js
50 lines (46 loc) · 1.39 KB
/
addbundles.js
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
// Add Bundled Transactions to FIO Handle Action
var action = 'addbundles'
var contract = 'fio.address'
const {FIOSDK} = require('@fioprotocol/fiosdk')
var fetch = require('node-fetch')
const fetchJson = async (uri, opts = {}) => {
return fetch(uri, opts)
}
// EDIT this section then type node addbundles.js in Terminal to run
// API endpoint, see https://github.com/fioprotocol/fio.mainnet for complete list
const apiNode = 'https://test.fio.eosusa.io/v1/'
// FIO Chain Testnet private key. Get one from http://monitor.testnet.fioprotocol.io:3000/#createKey
// and then add tokens via faucet: http://monitor.testnet.fioprotocol.io:3000/#faucet
const privateKey = '5K9du1JcEVNyBZKU6Uc9bSihgUzmMvGUxPDRwyxVmo9Xuh2NNW3'
const publicKey = FIOSDK.derivedPublicKey(privateKey).publicKey
const account = FIOSDK.accountHash(publicKey).accountnm
// Action parameters
var actionData =
{
fio_address: 'user10006@regtest',
bundle_sets: 1,
max_fee: 10000000000000,
tpid: '',
actor: account
}
// Push transaction
const main = async () => {
user = new FIOSDK(
privateKey,
publicKey,
apiNode,
fetchJson
)
try {
const result = await user.genericAction('pushTransaction', {
action: action,
account: contract,
data: actionData
})
console.log('Result: ', result)
} catch (err) {
console.log('Error: ', err)
console.log('Fields: ', err.json.fields)
}
}
main();