-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
53 lines (39 loc) · 1.02 KB
/
app.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
51
52
53
const csv = require('csv-parser');
const fs = require('fs');
const koiSdk = require("@_koi/sdk/common");
const fsPromises = require("fs/promises");
const walletpath = "wallet.json";
const tools = new koiSdk.Common();
const filepath = "data.csv" //path to csv file
const list = []
//Read
fs.createReadStream(filepath)
.on('error', () => {
// handle error
})
.pipe(csv())
.on('data', (data) => {
try {
console.log("Name: "+data["NAME"]);
console.log("Wallet Address: "+data["WALLET ADDRESS"]);
list.push(data["WALLET ADDRESS"]);
} catch (err) {}
})
.on('end', async function () {
// handle end of CSV
await tools.loadWallet(
JSON.parse(await fsPromises.readFile(walletpath, "utf8"))
);
console.log("Addresses :" + list);
list.forEach(transferKOII);
console.log(list);
});
const transferKOII = async (address) => {
const tx = await tools.transfer(
0.01,
address,
"KOI"
);
console.log("tx:" + tx);
console.log("TRANSFER COMPLETE!")
};