Skip to main content
Glama

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
NameRequiredDescriptionDefault
token_addressYesToken contract address (0x...)
toYesRecipient wallet (0x...)
amountYesTokens 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 } }));
    },
  • 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 } }));
      },
    });

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/aspekt19/unboxed-loyalty-spark'

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