-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumanodeTransfer.jsENG
More file actions
66 lines (51 loc) · 1.71 KB
/
Copy pathHumanodeTransfer.jsENG
File metadata and controls
66 lines (51 loc) · 1.71 KB
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
59
60
61
62
63
64
65
66
// Read mnemonics from TXT file
const mnemonics = fs.readFileSync('mnemonics.txt', 'utf8')
.split('\n')
.map(line => line.trim())
.filter(Boolean);
const recipient = ''; // Destination address
const minimumBalance = BigInt(400_000_000_000); // Minimum balance to keep (0.4 HMND)
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function createApi() {
const wsProvider = new WsProvider('wss://explorer-rpc-ws.mainnet.stages.humanode.io');
const api = await ApiPromise.create({ provider: wsProvider });
wsProvider.on('disconnected', () => {
console.log(chalk.yellow('WebSocket connection closed. Exiting...'));
process.exit(0);
});
return api;
}
async function showSplashScreen() {
console.clear();
// Display banner
await sleep(2000);
console.log(chalk.blue.bold(humanodeText));
console.log(chalk.yellow.bold('Humanode Automation Tool'));
}
async function processAccounts() {
const api = await createApi();
for (let i = 0; i < mnemonics.length; i++) {
try {
if (i > 0) await sleep(1000);
const mnemonic = mnemonics[i];
const keyring = new Keyring({ type: 'sr25519' });
const account = keyring.addFromMnemonic(mnemonic);
const { data: balance } = await api.query.system.account(account.address);
const availableBalance = balance.free.toBigInt();
console.log(
chalk.green(
`Account checked: ${account.address} | Balance: ${availableBalance}`
)
);
} catch (error) {
console.error(
chalk.red(`Error processing account: ${error.message}`)
);
}
}
await api.disconnect();
console.log(chalk.green('All accounts processed successfully.'));
process.exit(0);
}