-
Notifications
You must be signed in to change notification settings - Fork 0
/
topup.js
33 lines (29 loc) · 917 Bytes
/
topup.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
const { ethers } = require("ethers");
const fs = require("fs");
// set private key of funding account
const PK = "";
const provider = new ethers.providers.JsonRpcBatchProvider(
"https://rpc.xdaichain.com/"
);
const wallet = new ethers.Wallet(PK, provider);
const log = (str) => {
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(str);
};
const run = async () => {
// must be run after xdaiProofs.json is generated
const content = JSON.parse(fs.readFileSync("xdaiProofs.json"));
const addresses = Object.keys(content.claims);
const value = ethers.utils.parseUnits("0.1");
for (let i = 0; i < addresses.length; i++) {
log(`${i}/${addresses.length}`);
const to = addresses[i];
const balance = await provider.getBalance(to);
if (balance.lt(value)) {
const tx = await wallet.sendTransaction({ to, value });
await tx.wait();
}
}
};
run();