immortal-bnb/generate-wallet.js
caelum0x 28e5c4997a โœจ Fix TypeScript errors & add Polymarket agents submodule
- Fixed all 25 TypeScript compilation errors in frontend
- Updated usePolling hook interface for cleaner usage
- Added proper type exports for API functions
- Fixed Dashboard profitChange null safety
- Added wallet validation in config
- Created wallet setup utilities (check-env.js, generate-wallet.js)
- Added Polymarket agents as git submodule
- Added comprehensive documentation (TYPESCRIPT_FIXES.md, WALLET_SETUP.md, GIT_SUBMODULES.md)
2025-11-11 19:06:10 +03:00

83 lines
2.7 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Generate a new test wallet for development
*/
const { ethers } = require('ethers');
const fs = require('fs');
const path = require('path');
console.log('\n๐Ÿ” Generating New Test Wallet...\n');
// Generate random wallet
const wallet = ethers.Wallet.createRandom();
console.log('โœ… Wallet generated successfully!\n');
console.log('๐Ÿ“ SAVE THIS INFORMATION SECURELY:\n');
console.log('Private Key:', wallet.privateKey);
console.log('Address: ', wallet.address);
console.log('Mnemonic: ', wallet.mnemonic.phrase);
console.log('\nโš ๏ธ IMPORTANT SECURITY WARNINGS:');
console.log(' 1. This is for TESTING ONLY - use small amounts');
console.log(' 2. NEVER share your private key with anyone');
console.log(' 3. NEVER commit .env file to git');
console.log(' 4. Store the mnemonic phrase securely as backup');
console.log('\n๐Ÿ“ To use this wallet:');
console.log(' 1. Copy the private key above');
console.log(' 2. Open your .env file');
console.log(' 3. Update: WALLET_PRIVATE_KEY=' + wallet.privateKey);
console.log(' 4. Save the file');
console.log(' 5. Send some test BNB to ' + wallet.address);
// Ask if user wants to update .env automatically
console.log('\nโ“ Update .env file automatically? (y/n)');
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => {
const answer = input.toString().trim().toLowerCase();
if (answer === 'y' || answer === 'yes') {
try {
const envPath = path.join(__dirname, '.env');
if (!fs.existsSync(envPath)) {
console.error('โŒ .env file not found');
process.exit(1);
}
// Read current .env
let envContent = fs.readFileSync(envPath, 'utf-8');
// Update or add WALLET_PRIVATE_KEY
if (envContent.includes('WALLET_PRIVATE_KEY=')) {
envContent = envContent.replace(
/WALLET_PRIVATE_KEY=.*/,
`WALLET_PRIVATE_KEY=${wallet.privateKey}`
);
} else {
envContent += `\nWALLET_PRIVATE_KEY=${wallet.privateKey}\n`;
}
// Backup old .env
fs.copyFileSync(envPath, envPath + '.backup');
console.log('โœ… Backed up old .env to .env.backup');
// Write new .env
fs.writeFileSync(envPath, envContent);
console.log('โœ… Updated .env file with new private key');
console.log('โœ… Wallet address:', wallet.address);
console.log('\n๐ŸŽ‰ Configuration complete! Run: node check-env.js to verify');
} catch (error) {
console.error('โŒ Failed to update .env:', error.message);
}
process.exit(0);
} else {
console.log('\n๐Ÿ‘ Okay, you can manually update your .env file');
process.exit(0);
}
});