65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
/**
|
||
* Wallet Generation Script
|
||
* Generates a new Celo wallet for the protocol
|
||
*
|
||
* Usage: npm run wallet:generate
|
||
*/
|
||
|
||
const { Wallet } = require('ethers')
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
|
||
console.log('đ Generating new Celo wallet for PollCelo protocol...\n')
|
||
|
||
// Generate random wallet
|
||
const wallet = Wallet.createRandom()
|
||
|
||
console.log('â
Wallet generated successfully!\n')
|
||
console.log('đ Wallet Details:')
|
||
console.log('â'.repeat(80))
|
||
console.log(`Address: ${wallet.address}`)
|
||
console.log(`Private Key: ${wallet.privateKey}`)
|
||
console.log(`Mnemonic: ${wallet.mnemonic.phrase}`)
|
||
console.log('â'.repeat(80))
|
||
|
||
console.log('\nâ ď¸ SECURITY WARNING:')
|
||
console.log('1. NEVER commit the private key to git')
|
||
console.log('2. Add this to your .env.local file (NOT .env)')
|
||
console.log('3. Add this to Vercel environment variables')
|
||
console.log('4. Keep the mnemonic in a safe place (offline backup)')
|
||
|
||
console.log('\nđ Add these to your .env.local file:\n')
|
||
console.log(`PROTOCOL_WALLET_ADDRESS=${wallet.address}`)
|
||
console.log(`PROTOCOL_WALLET_PRIVATE_KEY=${wallet.privateKey}`)
|
||
|
||
console.log('\nđ° Fund this wallet:')
|
||
console.log('1. Go to https://faucet.celo.org/ (testnet)')
|
||
console.log('2. Send some CELO for gas fees')
|
||
console.log('3. Get cUSD from Ubeswap or Mento')
|
||
console.log('4. Wallet is ready to receive poll payments!')
|
||
|
||
// Optionally save to file (DANGEROUS - delete after copying)
|
||
const saveToFile = process.argv.includes('--save')
|
||
|
||
if (saveToFile) {
|
||
const walletPath = path.join(__dirname, '../.wallet.json')
|
||
fs.writeFileSync(
|
||
walletPath,
|
||
JSON.stringify(
|
||
{
|
||
address: wallet.address,
|
||
privateKey: wallet.privateKey,
|
||
mnemonic: wallet.mnemonic.phrase,
|
||
createdAt: new Date().toISOString(),
|
||
warning: 'DELETE THIS FILE AFTER COPYING TO .env.local!',
|
||
},
|
||
null,
|
||
2
|
||
)
|
||
)
|
||
console.log(`\nâ ď¸ Wallet saved to ${walletPath}`)
|
||
console.log(' DELETE THIS FILE after copying to .env.local!')
|
||
}
|
||
|
||
console.log('\nâ
Done!')
|