Skip to main content
Glama
joadataarg

MIST.cash MCP Server

by joadataarg

calcular_hash_transaccion

Calculate a unique transaction hash for MIST.cash privacy-preserving payments on Starknet using transaction parameters like recipient address, token contract, and amount.

Instructions

Calculate the unique hash of a transaction using transaction parameters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
transaction_keyYesTransaction key
recipient_addressYesStarknet address of the recipient
token_addressYesToken contract address
amountYesAmount in base units (wei)

Implementation Reference

  • The main handler function that implements the tool logic: validates input using schema, checks Starknet addresses, computes transaction hash using txHash from @mistcash/crypto, and returns structured result.
    export async function calcularHashTransaccion(params) {
        // Validate parameters
        const validated = CalcularHashTransaccionSchema.parse(params);
        // Additional validation for addresses
        if (!isValidStarknetAddress(validated.recipient_address)) {
            throw new Error(`Invalid recipient address format: ${validated.recipient_address}`);
        }
        if (!isValidStarknetAddress(validated.token_address)) {
            throw new Error(`Invalid token address format: ${validated.token_address}`);
        }
        try {
            // Compute transaction hash using MIST.cash crypto
            const hash = txHash(validated.transaction_key, validated.recipient_address, validated.token_address, validated.amount);
            return {
                success: true,
                hash,
                transaction_details: {
                    transaction_key: validated.transaction_key,
                    recipient_address: validated.recipient_address,
                    token_address: validated.token_address,
                    amount: validated.amount
                }
            };
        }
        catch (error) {
            throw new Error(`Failed to calculate transaction hash: ${error.message}`);
        }
    }
  • Zod schema defining input validation for the calcular_hash_transaccion tool parameters.
    export const CalcularHashTransaccionSchema = z.object({
        transaction_key: z.string().min(1, 'Transaction key is required'),
        recipient_address: StarknetAddressSchema,
        token_address: StarknetAddressSchema,
        amount: z.string().regex(/^\d+$/, 'Amount must be a numeric string')
    });
  • src/index.js:102-126 (registration)
    Tool registration in the ListToolsRequest handler: defines name, description, and inputSchema for the MCP tool.
        name: 'calcular_hash_transaccion',
        description: 'Calculate the unique hash of a transaction using transaction parameters.',
        inputSchema: {
            type: 'object',
            properties: {
                transaction_key: {
                    type: 'string',
                    description: 'Transaction key',
                },
                recipient_address: {
                    type: 'string',
                    description: 'Starknet address of the recipient',
                },
                token_address: {
                    type: 'string',
                    description: 'Token contract address',
                },
                amount: {
                    type: 'string',
                    description: 'Amount in base units (wei)',
                },
            },
            required: ['transaction_key', 'recipient_address', 'token_address', 'amount'],
        },
    },
  • src/index.js:177-185 (registration)
    Dispatch logic in the CallToolRequest handler: routes requests for 'calcular_hash_transaccion' to the handler function.
    case 'calcular_hash_transaccion':
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify(await calcularHashTransaccion(args), null, 2),
                },
            ],
        };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joadataarg/Mcp-mistcash'

If you have feedback or need assistance with the MCP directory API, please join our Discord server