transfer_loyalty_tokens
Generate transaction data to move loyalty tokens between cryptocurrency wallets on the Base L2 blockchain.
Instructions
Get calldata to transfer loyalty tokens between wallets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_address | Yes | Token contract address (0x...) | |
| to | Yes | Recipient wallet (0x...) | |
| amount | Yes | Tokens to transfer |
Implementation Reference
- The handler function that executes the transfer_loyalty_tokens logic, including input validation, authorization checking, program lookup, and generation of contract call calldata.
handler: async ({ token_address, to, amount }: any) => { const err = authGuard(["mint"]); if (err) return T(err); if (!/^0x[a-fA-F0-9]{40}$/.test(to)) return T('{"error":"Invalid recipient address"}'); const d = db(); const { data: prog } = await d.from("loyalty_programs").select("id,name,status").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress).single(); if (!prog) return T('{"error":"Program not found or not owned by you"}'); if (prog.status !== "active") return T(JSON.stringify({ error: `Program is ${prog.status}` })); return T(JSON.stringify({ contract_call: { to: token_address, function: "transfer(address,uint256)", args: [to, amount], calldata: encodeTransferCalldata(to, amount), chain: "Base (8453)", builder_code: BUILDER_CODE } })); }, - supabase/functions/loyalty-mcp/index.ts:161-174 (registration)Registration of the 'transfer_loyalty_tokens' tool with its schema definition and handler.
mcpServer.tool("transfer_loyalty_tokens", { description: "Get calldata to transfer loyalty tokens between wallets", inputSchema: { type: "object" as const, properties: { token_address: { type: "string", description: "Token contract address (0x...)" }, to: { type: "string", description: "Recipient wallet (0x...)" }, amount: { type: "number", description: "Tokens to transfer" } }, required: ["token_address", "to", "amount"] }, handler: async ({ token_address, to, amount }: any) => { const err = authGuard(["mint"]); if (err) return T(err); if (!/^0x[a-fA-F0-9]{40}$/.test(to)) return T('{"error":"Invalid recipient address"}'); const d = db(); const { data: prog } = await d.from("loyalty_programs").select("id,name,status").eq("token_address", token_address.toLowerCase()).eq("merchant_address", agent.ownerAddress).single(); if (!prog) return T('{"error":"Program not found or not owned by you"}'); if (prog.status !== "active") return T(JSON.stringify({ error: `Program is ${prog.status}` })); return T(JSON.stringify({ contract_call: { to: token_address, function: "transfer(address,uint256)", args: [to, amount], calldata: encodeTransferCalldata(to, amount), chain: "Base (8453)", builder_code: BUILDER_CODE } })); }, });