Created
May 12, 2024 09:56
-
-
Save melardev/57b4d325a74c969355c0a0cbb5b013e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {clusterApiUrl, Connection, LAMPORTS_PER_SOL, PublicKey} from "@solana/web3.js"; | |
// const connection = new Connection("https://api.mainnet-beta.solana.com", 'confirmed'); | |
const connection = new Connection(clusterApiUrl("mainnet-beta")); | |
async function getAccountBalance(publicKey: PublicKey) { | |
const balanceInLamports = await connection.getBalance(publicKey); | |
const balanceInSOL = balanceInLamports / LAMPORTS_PER_SOL; | |
return balanceInSOL; | |
} | |
function sleep(ms: number) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
function permute(elements: string[]) { | |
var length = elements.length, | |
result = [elements.slice()], | |
c = new Array(length).fill(0), | |
i = 1, k, p; | |
while (i < length) { | |
if (c[i] < i) { | |
k = i % 2 && c[i]; | |
p = elements[i]; | |
elements[i] = elements[k]; | |
elements[k] = p; | |
++c[i]; | |
i = 1; | |
result.push(elements.slice()); | |
} else { | |
c[i] = 0; | |
++i; | |
} | |
} | |
return result; | |
} | |
async function run() { | |
const elements = ["sH9hT1sM", "JepXyrCGAeH", "hfEba2nV", "FitBcgbcM", "GdTyCmK"]; | |
const allCombinations = permute(elements); | |
console.log(`We have ${allCombinations.length} combinations`) | |
let wallet = null; | |
for (let i = 0; i < allCombinations.length; i++) { | |
const combo = allCombinations[i]; | |
const address = combo.join('') | |
const publicKey = new PublicKey(address); | |
const balance = await getAccountBalance(publicKey); | |
console.log(`[*] ${i} Checking ${address}`) | |
if (balance > 0) { | |
console.log(`Wallet ${publicKey.toString()} has a balance of ${balance} SOL`); | |
wallet = address; | |
break | |
} | |
await sleep(500) | |
} | |
if (wallet != null) { | |
console.log('\n\n') | |
console.log('\x1b[32m%s\x1b[0m', `[+] Address is ${wallet}`) | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment