immortal-bnb/fix-env.sh
2025-11-21 05:05:57 +03:00

50 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Quick script to fix the WALLET_PRIVATE_KEY in .env
echo "๐Ÿ”ง Fixing .env configuration..."
# Backup existing .env
cp .env .env.backup
echo "โœ… Backed up .env to .env.backup"
# Generate a new test wallet using Node.js
echo "๐Ÿ”‘ Generating test wallet..."
node -e "
const { Wallet } = require('ethers');
const wallet = Wallet.createRandom();
console.log('');
console.log('='.repeat(60));
console.log('NEW TEST WALLET GENERATED');
console.log('='.repeat(60));
console.log('Address:', wallet.address);
console.log('Private Key:', wallet.privateKey);
console.log('='.repeat(60));
console.log('');
console.log('โš ๏ธ TESTNET ONLY - DO NOT USE WITH REAL FUNDS');
console.log('');
// Update .env file
const fs = require('fs');
let envContent = fs.readFileSync('.env', 'utf8');
// Replace the WALLET_PRIVATE_KEY line
envContent = envContent.replace(
/WALLET_PRIVATE_KEY=.*/,
'WALLET_PRIVATE_KEY=' + wallet.privateKey
);
fs.writeFileSync('.env', envContent);
console.log('โœ… Updated .env with new private key');
console.log('');
console.log('Get testnet BNB from:');
console.log('https://testnet.bnbchain.org/faucet-smart');
console.log('');
console.log('Your wallet address: ' + wallet.address);
"
echo ""
echo "โœ… Done! Now run: bun start"