-
Notifications
You must be signed in to change notification settings - Fork 1
/
send-txn.ts
49 lines (40 loc) · 1.2 KB
/
send-txn.ts
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
const Lamden = require('lamden-js');
import axios from 'axios';
import { config } from './src/config';
// const axiosDefaultConfig = {
// proxy: false,
// };
axios.defaults.proxy = false;
// const axios = require('axios').create(this.axiosDefaultConfig);
export const create_lamden_wallet = () => Lamden.wallet.new_wallet();
export const create_transaction_info = () => {
return {
senderVk: config.operator_vk,
contractName: 'currency',
methodName: 'transfer',
kwargs: {
to: 'nowhere', // string
amount: { __fixed__: '0.0001' }, // fixed object required for float values
},
stampLimit: 500, //Max stamps to be used. Could use less, won't use more.
};
};
export const submit_transacton = async () => {
let tx = new Lamden.TransactionBuilder(config.network, create_transaction_info());
return await tx.send(config.operator_sk, undefined, async (res, err) => {
if (err) throw new Error(err);
console.log(res.hash);
return await tx.checkForTransactionResult();
});
};
export const go = async () => {
const res = await submit_transacton();
console.log(res);
};
let tx_num = 0;
setInterval(() => {
if (tx_num < 20) {
tx_num ++
go();
}
}, 2000);