-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfund-address.js
46 lines (38 loc) · 1.12 KB
/
fund-address.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
import "dotenv/config";
import { execSync } from "child_process";
import { deriveAddressesFromMnemonic } from "./wallet.js";
import logger from "./logger.js";
const { MNEMONIC } = process.env;
if (!MNEMONIC) {
logger.error("Error: MNEMONIC is not defined in .env");
process.exit(1);
}
const addresses = deriveAddressesFromMnemonic(MNEMONIC, 10);
if (!addresses.length) {
logger.error("Error: No addresses derived from mnemonic.");
process.exit(1);
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
(async function main() {
logger.boldinfo(
"========== FUNDING ADDRESS DERIVED FROM MNEMNONIC ==========",
);
for (const address of addresses) {
const addrNo0x = address.replace(/^0x/, "");
logger.info(`Funding address: ${address}`);
try {
execSync(
`docker exec -i zama-dev-fhevm-validator-1 faucet "${addrNo0x}"`,
{
stdio: "inherit",
},
);
} catch (err) {
logger.error(`Error funding address ${address}:`, err.message);
}
await sleep(8000);
}
logger.boldinfo("✅ All addresses funded successfully!");
})();