= {}; bot.action('view_address', async (ctx) => { try { const userId = ctx.from?.id; if (!userId) return; if (!USERS[userId]) { return ctx.sendMessage('You don\'t have a wallet. Please generate one first.', { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [Markup.button.callback('🔑 Generate Wallet', 'generate_wallet')] ]) }); } await ctx.answerCbQuery('Getting public key...'); ctx.sendMessage(`Your public key is ${USERS[userId].publicKey.toBase58()}`, { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [ Markup.button.callback('👁️ View Address', 'view_address'), Markup.button.callback('🔐 Export Private Key', 'export_private_key') ], ["> = {}; bot.action('view_address', async (ctx) => { try { const userId = ctx.from?.id; if (!userId) return; if (!USERS[userId]) { return ctx.sendMessage('You don\'t have a wallet. Please generate one first.', { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [Markup.button.callback('🔑 Generate Wallet', 'generate_wallet')] ]) }); } await ctx.answerCbQuery('Getting public key...'); ctx.sendMessage(`Your public key is ${USERS[userId].publicKey.toBase58()}`, { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [ Markup.button.callback('👁️ View Address', 'view_address'), Markup.button.callback('🔐 Export Private Key', 'export_private_key') ], ["> = {}; bot.action('view_address', async (ctx) => { try { const userId = ctx.from?.id; if (!userId) return; if (!USERS[userId]) { return ctx.sendMessage('You don\'t have a wallet. Please generate one first.', { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [Markup.button.callback('🔑 Generate Wallet', 'generate_wallet')] ]) }); } await ctx.answerCbQuery('Getting public key...'); ctx.sendMessage(`Your public key is ${USERS[userId].publicKey.toBase58()}`, { parse_mode: 'Markdown', ...Markup.inlineKeyboard([ [ Markup.button.callback('👁️ View Address', 'view_address'), Markup.button.callback('🔐 Export Private Key', 'export_private_key') ], [">
import { Keypair, PublicKey } from "@solana/web3.js";
const USERS: Record<string, Keypair> = {};
bot.action('view_address', async (ctx) => {
try {
const userId = ctx.from?.id;
if (!userId) return;
if (!USERS[userId]) {
return ctx.sendMessage('You don\\'t have a wallet. Please generate one first.', {
parse_mode: 'Markdown',
...Markup.inlineKeyboard([
[Markup.button.callback('🔑 Generate Wallet', 'generate_wallet')]
])
});
}
await ctx.answerCbQuery('Getting public key...');
ctx.sendMessage(`Your public key is ${USERS[userId].publicKey.toBase58()}`, {
parse_mode: 'Markdown',
...Markup.inlineKeyboard([
[
Markup.button.callback('👁️ View Address', 'view_address'),
Markup.button.callback('🔐 Export Private Key', 'export_private_key')
],
[
Markup.button.callback('💰 Check Balance', 'check_balance'),
Markup.button.callback('📊 Transaction History', 'tx_history')
],
[
Markup.button.callback('💸 Send SOL', 'send_sol_menu'),
Markup.button.callback('🪙 Send Token', 'send_token_menu')
]
])
});
} catch (error) {
await ctx.answerCbQuery('❌ Failed to generate wallet');
return ctx.reply('❌ An error occurred. Please try again.');
}
});