-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
75 lines (65 loc) · 2.7 KB
/
index.ts
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
67
68
69
70
71
72
73
74
75
import { Keyring } from "@polkadot/keyring"
import { cryptoWaitReady, mnemonicGenerate } from "@polkadot/util-crypto"
import { HDNodeWallet } from "ethers";
import { appendFileSync } from "node:fs";
import { Account } from "@aptos-labs/ts-sdk";
import 'dotenv/config';
function sleep(ms: number){
return new Promise(resolve => setTimeout(resolve, ms))
}
function isMatchWith(address: string){
if (process.env.POSTFIXS){
let postfixs = process.env.POSTFIXS.split(" ");
for (let index = 0; index < postfixs.length; index++) {
const postfix = postfixs[index];
if (address.endsWith(postfix)){
return true
}
}
}
return false
}
async function generate() {
await cryptoWaitReady();
while (true) {
sleep(100);
const mnemonic = mnemonicGenerate();
const seperate = "==========================================="
if (process.env.SS58_ENABLE){
const keyring = new Keyring({type: 'sr25519'});
const substrateWallet = keyring.createFromUri(`${mnemonic}`);
let substrateAddress = substrateWallet.address
console.log("substrate ", substrateAddress)
if (isMatchWith(substrateAddress)){
console.log("**************FOUND SUBSTRATE****************")
appendFileSync("result_substrate.txt", seperate + "\n" )
appendFileSync("result_substrate.txt", substrateWallet.address + "\n" )
appendFileSync("result_substrate.txt", mnemonic + "\n")
}
}
if (process.env.EVM_ENABLE) {
let etherWallet = HDNodeWallet.fromPhrase(mnemonic);
let evmAddress = etherWallet.address;
console.log("evm ", evmAddress)
if (isMatchWith(evmAddress)){
console.log("**************FOUND EVM****************")
appendFileSync("result_evm.txt", seperate + "\n" )
appendFileSync("result_evm.txt", etherWallet.address + "\n")
appendFileSync("result_evm.txt", mnemonic + "\n")
}
}
if (process.env.APTOS_ENABLE) {
const path = "m/44'/637'/0'/0'/0";
const account = Account.fromDerivationPath({ path, mnemonic });
let address = account.accountAddress.toString();
console.log("evm ", address)
if (isMatchWith(address)){
console.log("**************FOUND APTOS****************")
appendFileSync("result_apt.txt", seperate + "\n" )
appendFileSync("result_apt.txt", address + "\n")
appendFileSync("result_apt.txt", mnemonic + "\n")
}
}
}
}
generate()