-
Notifications
You must be signed in to change notification settings - Fork 11
/
index.js
58 lines (48 loc) · 2.19 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
const fs = require('fs');
const bs58 = require('bs58');
const solanaWeb3 = require("@solana/web3.js");
const Solana = new solanaWeb3.Connection("https://ssc-dao.genesysgo.net/");
// IF YOU ARE A NOOB JUST EDIT THIS PART
const wordsStart = ["art", "1312", "look"]; // words to look for at the beginning of the address
const wordsInclude = ["looksrare"]; // words to look for in the complete address
const stopAfter = 100; // setting this to 0 deactivates the limit
const outputDirectory = "./output"; // output directory WITHOUT "/" at the end
// FUNCTION PART
// create output directory if not exists
if (!fs.existsSync(outputDirectory)){
fs.mkdirSync(outputDirectory);
}
// write key to file
const writeSolKey = async (keyPair) => {
console.log(keyPair);
fs.writeFileSync(outputDirectory + "/" + keyPair.publicKey.toString() + '.json', bs58.encode(keyPair.secretKey));
}
const solKeyGen = async () => {
console.log('Solana Keypair Generator started with following filters:')
let count = 0;
if(wordsStart.length > 0) { console.log('--> starting or ending with ', wordsStart); }
if(wordsInclude.length > 0) { console.log('--> including ', wordsInclude); }
console.log('Please be patient while the computer does its thing. This can take a while!');
console.log('Usually a 3-digit word at the beginning will be found within a minute, 4-digit can take longer!')
while((count < stopAfter) || stopAfter == 0) {
// generate new keypair
const keyPair = solanaWeb3.Keypair.generate();
// lowercase the public key for more results
const checkKey = keyPair.publicKey.toString().toLowerCase();
// test for match - if match found, output the keypair to a file
let isMatch = false;
for (var i = wordsStart.length - 1; (i >= 0 ) && !isMatch; i--) {
if(checkKey.startsWith(wordsStart[i])) isMatch = true;
if(checkKey.endsWith(wordsStart[i])) isMatch = true;
}
for (var i = wordsInclude.length - 1; (i >= 0 ) && !isMatch; i--) {
if(checkKey.includes(wordsInclude[i])) isMatch = true;
}
if (isMatch) {
count++;
console.log("[" + count + "] New Match - Public Key:", keyPair.publicKey.toString());
writeSolKey(keyPair);
}
}
};
solKeyGen();