load_wallet
Access a stored Algorand wallet by providing its name and password to retrieve the associated blockchain address for transactions.
Instructions
Load a stored wallet and return the address
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Wallet name/identifier | |
| password | Yes | Password to decrypt the mnemonic |
Implementation Reference
- src/index.ts:764-798 (handler)Main handler for the 'load_wallet' tool. Parses arguments, retrieves the stored wallet from in-memory storage, decrypts the mnemonic using AlgorandService, and returns the wallet address and decrypted mnemonic.case 'load_wallet': { const parsed = LoadWalletArgsSchema.parse(args); try { const wallet = walletStorage.get(parsed.name); if (!wallet) { throw new Error(`Wallet "${parsed.name}" not found`); } // Decrypt mnemonic const mnemonic = algorandService.decryptMnemonic( wallet.encryptedMnemonic, wallet.iv, parsed.password ); return { content: [ { type: 'text', text: `Wallet "${parsed.name}" loaded successfully!\nAddress: ${wallet.address}\nMnemonic: ${mnemonic}\n\n⚠️ Keep this mnemonic secure and private.`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error loading wallet: ${error}`, }, ], isError: true, }; } }
- src/index.ts:85-88 (schema)Zod schema defining the input parameters for the load_wallet tool: wallet name and password.const LoadWalletArgsSchema = z.object({ name: z.string(), password: z.string(), });
- src/index.ts:345-362 (registration)Registration of the 'load_wallet' tool in the TOOLS array, including name, description, and input schema definition.{ name: 'load_wallet', description: 'Load a stored wallet and return the address', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Wallet name/identifier', }, password: { type: 'string', description: 'Password to decrypt the mnemonic', }, }, required: ['name', 'password'], }, },
- src/algorand.ts:78-96 (helper)Helper method in AlgorandService used by the load_wallet handler to decrypt the stored mnemonic phrase using AES-256-GCM./** * Decrypt a mnemonic phrase */ decryptMnemonic(encryptedData: string, iv: string, password: string): string { const key = crypto.scryptSync(password, 'salt', 32); const [encrypted, authTag] = encryptedData.split(':'); if (!encrypted || !authTag) { throw new Error('Invalid encrypted data format'); } const decipher = crypto.createDecipheriv('aes-256-gcm', key, Buffer.from(iv, 'hex')); decipher.setAuthTag(Buffer.from(authTag, 'hex')); let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); return decrypted; }