Skip to main content
Glama

build_approve_token

Create unsigned token approval transactions for the CSPR.trade DEX router to enable token swaps on the Casper Network.

Instructions

Build an unsigned token approval transaction. Spender defaults to the CSPR.trade router.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesToken contract package hash to approve
amountYesRaw amount to approve (in smallest unit / motes)
sender_public_keyYesSender hex public key
spenderNoSpender contract package hash (defaults to CSPR.trade router)

Implementation Reference

  • The 'build_approve_token' tool is defined here. It accepts token details, amount, sender, and optional spender, then calls client.buildApproval and saves the result to a deploy file.
    server.tool(
      'build_approve_token',
      'Build an unsigned token approval transaction. Spender defaults to the CSPR.trade router.',
      {
        token: z.string().describe('Token contract package hash to approve'),
        amount: z.string().describe('Raw amount to approve (in smallest unit / motes)'),
        sender_public_key: z.string().describe('Sender hex public key'),
        spender: z.string().optional().describe('Spender contract package hash (defaults to CSPR.trade router)'),
      },
      async (args) => {
        const bundle = await client.buildApproval({
          tokenContractPackageHash: args.token,
          spenderPackageHash: args.spender ?? '',
          amount: args.amount,
          senderPublicKey: args.sender_public_key,
        });
        const deployPath = await writeDeployFile(bundle.transactionJson);
        return { content: [{ type: 'text' as const, text: bundle.summary + `\n\nUnsigned transaction saved to: ${deployPath}` }] };
      },
    );

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/make-software/cspr-trade-mcp'

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