不断生成随机密钥对,检查地址是否符合要求。 基本要一百万次以上才能匹配到一个。
下面是 claude code 完成的代码,Node.js 实现,使用官方库。
package.json
{
"name": "solana-v2ex-generator",
"version": "1.0.0",
"description": "Generate Solana addresses ending with v2ex",
"main": "generate-v2ex-address.js",
"scripts": {
"start": "node generate-v2ex-address.js"
},
"dependencies": {
"@solana/web3.js": "^1.95.0",
"bs58": "^5.0.0"
}
}
generate-v2ex-address.js
const { Keypair } = require('@solana/web3.js');
const fs = require('fs');
const bs58 = require('bs58');
async function generateV2exAddress() {
let attempts = 0;
const startTime = Date.now();
console.log('开始生成以 V2EX 结尾的 Solana 地址...\n');
while (true) {
attempts++;
const keypair = Keypair.generate();
const publicKey = keypair.publicKey.toBase58();
if (attempts % 10000 === 0) {
console.log(`已尝试 ${attempts} 次...`);
}
if (publicKey.endsWith('v2ex')) {
const elapsedTime = (Date.now() - startTime) / 1000;
console.log('\n🎉 成功找到匹配的地址!');
console.log(`尝试次数: ${attempts}`);
console.log(`耗时: ${elapsedTime.toFixed(2)} 秒\n`);
console.log('='.repeat(60));
console.log('地址:', publicKey);
console.log('私钥 (Base58):', bs58.encode(keypair.secretKey));
console.log('='.repeat(60));
const result = {
address: publicKey,
privateKey: bs58.encode(keypair.secretKey),
privateKeyArray: Array.from(keypair.secretKey),
attempts: attempts,
timeInSeconds: elapsedTime
};
const filename = `v2ex-address-${Date.now()}.json`;
fs.writeFileSync(filename, JSON.stringify(result, null, 2));
console.log(`\n 结果已保存到: ${filename}`);
break;
}
}
}
generateV2exAddress().catch(console.error);
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.