Complete guide to wallet management with Neo N3 MCP Server
Create a secure wallet with encrypted private key storage:
// Using MCP Tools const result = await tools.create_wallet({ password: "secure_password_123", name: "MyWallet" }); console.log("Wallet created:", result); // Output: // { // "address": "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", // "publicKey": "03c6aa6e12638b36c....", // "encrypted": true, // "name": "MyWallet" // }
Import a wallet using WIF (Wallet Import Format) or private key:
// Import from WIF const walletFromWIF = await tools.import_wallet({ wif: "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr", password: "new_password_123", name: "ImportedWallet" }); // Import from private key const walletFromKey = await tools.import_wallet({ privateKey: "1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb", password: "secure_password", name: "ImportedFromKey" });
Get comprehensive balance information for NEO, GAS, and NEP-17 tokens:
// Get balance for specific address const balance = await tools.get_balance({ address: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj" }); console.log("Wallet balance:", balance); // Output: // { // "NEO": "100", // "GAS": "15.5234", // "tokens": { // "fWMP2dkWM": "1000.00", // Flamingo token // "d2a4cFF31": "50.25" // Other NEP-17 token // }, // "totalValueUSD": "1250.75" // }
Send NEO, GAS, or NEP-17 tokens to other addresses:
// Transfer NEO tokens const neoTransfer = await tools.transfer_neo({ fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB", amount: "10", password: "wallet_password" }); // Transfer GAS tokens const gasTransfer = await tools.transfer_gas({ fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB", amount: "5.5", password: "wallet_password" }); console.log("Transfer completed:", gasTransfer); // Output: // { // "txid": "0x1234567890abcdef...", // "gasConsumed": "0.0234567", // "confirmations": 1, // "success": true // }
Work with custom NEP-17 tokens:
// Get token information const tokenInfo = await tools.get_nep17_token_info({ contractHash: "0xd2a4cff31913016155e38e474a2c06d08be276cf" }); // Transfer NEP-17 tokens const tokenTransfer = await tools.transfer_nep17({ fromAddress: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", toAddress: "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB", contractHash: "0xd2a4cff31913016155e38e474a2c06d08be276cf", amount: "100.5", password: "wallet_password" }); console.log("Token info:", tokenInfo); // Output: // { // "symbol": "FLM", // "decimals": 8, // "totalSupply": "150000000.00000000", // "name": "Flamingo" // }
Get transaction history for wallet addresses:
// Get recent transactions const history = await tools.get_address_transactions({ address: "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", limit: 10 }); console.log("Transaction history:", history); // Output: // { // "transactions": [ // { // "txid": "0xabcdef1234567890...", // "blockHeight": 5678901, // "timestamp": 1640995200, // "type": "NEP17Transfer", // "amount": "10.00000000", // "asset": "NEO", // "from": "NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj", // "to": "NYjzhdekseMYWvYpSoAeypqMiwMuEUDhKB" // } // ] // }
A comprehensive wallet management class:
class NeoWalletManager { constructor(mcpTools) { this.tools = mcpTools; this.wallets = new Map(); } async createWallet(name, password) { try { const wallet = await this.tools.create_wallet({ name, password }); this.wallets.set(name, wallet); console.log(`✅ Wallet "${name}" created successfully`); return wallet; } catch (error) { console.error("❌ Failed to create wallet:", error); throw error; } } async getPortfolioValue(address) { const balance = await this.tools.get_balance({ address }); const prices = await this.tools.get_asset_prices(); let totalValue = 0; totalValue += parseFloat(balance.NEO || 0) * prices.NEO; totalValue += parseFloat(balance.GAS || 0) * prices.GAS; // Calculate token values for (const [token, amount] of Object.entries(balance.tokens || {})) { if (prices[token]) { totalValue += parseFloat(amount) * prices[token]; } } return { totalValueUSD: totalValue.toFixed(2), breakdown: { NEO: (parseFloat(balance.NEO || 0) * prices.NEO).toFixed(2), GAS: (parseFloat(balance.GAS || 0) * prices.GAS).toFixed(2), tokens: balance.tokens } }; } async transferWithConfirmation(from, to, asset, amount, password) { console.log(`🔄 Initiating transfer: ${amount} ${asset}`); // Estimate fees first const feeEstimate = await this.tools.estimate_transfer_fee({ fromAddress: from, toAddress: to, asset, amount }); console.log(`💰 Estimated fee: ${feeEstimate.fee} GAS`); // Execute transfer let result; if (asset === 'NEO') { result = await this.tools.transfer_neo({ fromAddress: from, toAddress: to, amount, password }); } else if (asset === 'GAS') { result = await this.tools.transfer_gas({ fromAddress: from, toAddress: to, amount, password }); } console.log(`✅ Transfer completed: ${result.txid}`); return result; } } // Usage example const walletManager = new NeoWalletManager(mcpTools); // Create and manage wallets await walletManager.createWallet("MainWallet", "secure123"); const portfolio = await walletManager.getPortfolioValue("NZNos2WqTbu5oCgyfss9kUJgBXJqhuYAaj"); console.log("Portfolio value:", portfolio);