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
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | Token contract package hash to approve | |
| amount | Yes | Raw amount to approve (in smallest unit / motes) | |
| sender_public_key | Yes | Sender hex public key | |
| spender | No | Spender contract package hash (defaults to CSPR.trade router) |
Implementation Reference
- packages/mcp/src/tools/trading.ts:63-82 (handler)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}` }] }; }, );