-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (49 loc) · 1.75 KB
/
index.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
54
55
56
57
58
59
60
61
import { Ed25519Keypair, JsonRpcProvider, RawSigner, TransactionBlock} from '@mysten/sui.js'
import bip39 from 'bip39'
import axios from 'axios'
import fs from 'fs'
import consoleStamp from 'console-stamp'
import { createInterface } from "readline";
consoleStamp(console, { format: ':date(HH:MM:ss)' })
const provider = new JsonRpcProvider();
function saveMnemonic(address, mnemonic, keypair) {
#куда сохраняем аккаунты
fs.appendFileSync("./mnemonics/wallets.txt",`${address}\n ${keypair}\n ${mnemonic}\n`, "utf8");
}
function createwallet() {
#5 заменить на количество необходимых аккаунтов#
for (let i = 0; i < 5; i++) {
const mnemonic = bip39.generateMnemonic()
const keypair = Ed25519Keypair.deriveKeypair(mnemonic)
const address = keypair.getPublicKey().toSuiAddress()
console.log(`Sui Address: 0x${address}`)
console.log(`Keypair: ${keypair}`)
console.log(`Mnemonic: ${mnemonic}`)
console.log(`Result: https://explorer.sui.io/addresses/${address}?network=mainnet`)
saveMnemonic(address, mnemonic, keypair)
console.log("-".repeat(100))
}
}
(async () => {
const readline = createInterface({
input: process.stdin,
output: process.stdout
});
const readLineAsync = msg => {
return new Promise(resolve => {
readline.question(msg, userRes => {
resolve(userRes);
});
});
}
const mode = await readLineAsync(`Select app mode...
0 - Create SUI wallet
\n\n`);
readline.close();
console.log('Mode..', mode);
switch (parseInt(mode)) {
case 0:
await createwallet()
break;
}
})()