store_wallet
Securely store an Algorand wallet by encrypting its mnemonic phrase with a password for protected access to blockchain accounts and transactions.
Instructions
Securely store a wallet with encrypted mnemonic
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Wallet name/identifier | |
| mnemonic | Yes | Mnemonic phrase to store securely | |
| password | Yes | Password to encrypt the mnemonic |
Implementation Reference
- src/index.ts:727-762 (handler)Main handler function executing the store_wallet tool: validates input, imports account for address, encrypts mnemonic, stores in walletStorage Map.case 'store_wallet': { const parsed = StoreWalletArgsSchema.parse(args); try { // Import account to get address const account = algorandService.importAccountFromMnemonic(parsed.mnemonic); // Encrypt mnemonic const { encryptedMnemonic, iv } = algorandService.encryptMnemonic(parsed.mnemonic, parsed.password); // Store wallet walletStorage.set(parsed.name, { encryptedMnemonic, iv, address: account.addr.toString() }); return { content: [ { type: 'text', text: `Wallet "${parsed.name}" stored securely!\nAddress: ${account.addr}\n\n⚠️ Remember your password - it's required to access the wallet.`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error storing wallet: ${error}`, }, ], isError: true, }; } }
- src/index.ts:79-83 (schema)Zod schema for validating store_wallet tool input arguments: name, mnemonic, password.const StoreWalletArgsSchema = z.object({ name: z.string(), mnemonic: z.string(), password: z.string(), });
- src/index.ts:323-344 (registration)Tool registration in the TOOLS array, defining name, description, and input schema for MCP server.{ name: 'store_wallet', description: 'Securely store a wallet with encrypted mnemonic', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Wallet name/identifier', }, mnemonic: { type: 'string', description: 'Mnemonic phrase to store securely', }, password: { type: 'string', description: 'Password to encrypt the mnemonic', }, }, required: ['name', 'mnemonic', 'password'], }, },
- src/algorand.ts:62-76 (helper)Helper method in AlgorandService for encrypting mnemonic using AES-256-GCM with password-derived key.encryptMnemonic(mnemonic: string, password: string): { encryptedMnemonic: string; iv: string } { const key = crypto.scryptSync(password, 'salt', 32); const iv = crypto.randomBytes(16); const cipher = crypto.createCipheriv('aes-256-gcm', key, iv); let encrypted = cipher.update(mnemonic, 'utf8', 'hex'); encrypted += cipher.final('hex'); const authTag = cipher.getAuthTag(); return { encryptedMnemonic: encrypted + ':' + authTag.toString('hex'), iv: iv.toString('hex') }; }
- src/algorand.ts:111-113 (helper)Helper method to derive Algorand account (including address) from mnemonic phrase.importAccountFromMnemonic(mnemonic: string): algosdk.Account { return algosdk.mnemonicToSecretKey(mnemonic); }