How to generate vanity keypairs in typescript

How to generate vanity keypairs in typescript

Manage alerts

Loading saved threads...

Jimii · External communityPost link
External question — Solana Stack Exchange Author: Jimii Original post: https://solana.stackexchange.com/questions/18261 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Is there a way to generate vanity keypairs using Typescript apart from using the generate method and matching the prefix/suffix of generated keypairs const keypair = Keypair.generate(); while (true) { if (keypair.publicKey.toBase58().startsWith(prefix)) break; } Also, I'd love a solution that does not involve web workers.
Quote
Report
pizzza1bit · External communityPost link
External answer — Solana Stack Exchange Author: pizzza1bit Original post: https://solana.stackexchange.com/a/18263 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. To generate a vanity keypair in TypeScript, you can use a brute-force loop that repeatedly generates keypairs and checks if the public key matches the desired pattern. import { Keypair } from '@solana/web3.js'; function generateVanityKeypair(prefix: string): Keypair { let keypair: Keypair; do { keypair = Keypair.generate(); } while (!keypair.publicKey.toBase58().startsWith(prefix)); return keypair; } // Example usage const prefix = 'abc'; // Desired prefix const vanityKeypair = generateVanityKeypair(prefix); console.log('Vanity Public Key:', vanityKeypair.publicKey.toBase58()); console.log('Private Key:', Buffer.from(vanityKeypair.secretKey).toString('hex'));
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Solana Stack Exchange Author: Jimii Source score (net votes, not local likes): 1 Original post: https://solana.stackexchange.com/questions/18261 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Is there a way to generate vanity keypairs using Typescript apart from using the generate method and matching the prefix/suffix of generated keypairs const keypair = Keypair.generate(); while (true) { if (keypair.publicKey.toBase58().startsWith(prefix)) break; } Also, I'd love a solution that does not involve web workers.

Cancel quote

Checking account access…
How to generate vanity keypairs in typescript | Forex.com.bd