-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path11_multisend.ts
58 lines (53 loc) · 1.34 KB
/
11_multisend.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
50
51
52
53
54
55
56
57
58
import { MsgSend } from "@terra-money/terra.js";
import * as fs from "fs";
import yargs from "yargs/yargs";
import { createLCDClient, createWallet, sendTxWithConfirm } from "./helpers";
import * as keystore from "./keystore";
const argv = yargs(process.argv)
.options({
network: {
type: "string",
demandOption: true,
},
key: {
type: "string",
demandOption: true,
},
"key-dir": {
type: "string",
demandOption: false,
default: keystore.DEFAULT_KEY_DIR,
},
"csv-file": {
type: "string",
demandOption: true,
},
"sender-address": {
type: "string",
demandOption: true,
default: "terra1alxk3fmhcl0ga80gl9yj9zp3ezjm4sdh8a9l9c",
},
})
.parseSync();
(async function () {
const terra = createLCDClient(argv["network"]);
const csv = fs
.readFileSync(argv["csv-file"], "ascii")
.split(/\n|\r/)
.map((a) => {
const parts = a.split(";");
return {
address: parts[0],
amount: +parts[1],
};
})
.filter((a) => a.amount > 0);
const worker = await createWallet(terra, argv["key"], argv["key-dir"]);
const { txhash } = await sendTxWithConfirm(
worker,
csv.map(
(a) => new MsgSend(argv.senderAddress, a.address, { uluna: a.amount })
)
);
console.log(`Success! Txhash: ${txhash}`);
})();