generar_secreto_transaccion
Generate cryptographic transaction secrets for private payments on Starknet using claiming keys and recipient addresses.
Instructions
Generate a transaction secret for private payments. Creates a cryptographic secret using a claiming key and recipient address.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| claiming_key | Yes | Claiming key for the transaction | |
| recipient_address | Yes | Starknet address of the recipient (must start with 0x) |
Implementation Reference
- src/tools/generar-secreto.js:8-28 (handler)Core handler function that validates input parameters using Zod schema, checks Starknet address validity, generates transaction secret using txSecret from @mistcash/crypto, and returns structured response.export async function generarSecretoTransaccion(params) { // Validate parameters const validated = GenerarSecretoTransaccionSchema.parse(params); // Additional validation if (!isValidStarknetAddress(validated.recipient_address)) { throw new Error(`Invalid recipient address format: ${validated.recipient_address}`); } try { // Generate transaction secret using MIST.cash crypto const secret = txSecret(validated.claiming_key, validated.recipient_address); return { success: true, secret, claiming_key: validated.claiming_key, recipient_address: validated.recipient_address }; } catch (error) { throw new Error(`Failed to generate transaction secret: ${error.message}`); } }
- src/utils/validation.js:11-14 (schema)Zod validation schema for tool inputs: requires claiming_key (non-empty string) and recipient_address (valid Starknet address).export const GenerarSecretoTransaccionSchema = z.object({ claiming_key: z.string().min(1, 'Claiming key is required'), recipient_address: StarknetAddressSchema });
- src/index.ts:46-62 (registration)Tool registration in MCP server's ListTools handler, defining name, description, and JSON schema for inputs.name: 'generar_secreto_transaccion', description: 'Generate a transaction secret for private payments. Creates a cryptographic secret using a claiming key and recipient address.', inputSchema: { type: 'object', properties: { claiming_key: { type: 'string', description: 'Claiming key for the transaction', }, recipient_address: { type: 'string', description: 'Starknet address of the recipient (must start with 0x)', }, }, required: ['claiming_key', 'recipient_address'], }, },
- src/index.ts:166-175 (registration)Dispatch handler in MCP server's CallToolRequestSchema switch statement, invoking the generarSecretoTransaccion function with arguments and formatting response.case 'generar_secreto_transaccion': return { content: [ { type: 'text', text: JSON.stringify(await generarSecretoTransaccion(args), null, 2), }, ], };
- src/index.ts:18-18 (registration)Import statement bringing the handler function into the main server file.import { generarSecretoTransaccion } from './tools/generar-secreto.js';