Skip to main content
Glama

register_loyalty_program

Register deployed tokens as loyalty programs in the database to manage on-chain rewards, track balances, and handle marketplace offers on Base L2.

Instructions

Register a deployed token as a loyalty program in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesProgram name
symbolYesToken symbol
token_addressYesDeployed token contract address (0x...)
expiration_daysNoDuration in days (default: 365)

Implementation Reference

  • Registration of the register_loyalty_program tool within the MCP server.
    mcpServer.tool("register_loyalty_program", {
      description: "Register a deployed token as a loyalty program in the database",
      inputSchema: { type: "object" as const, properties: { name: { type: "string", description: "Program name" }, symbol: { type: "string", description: "Token symbol" }, token_address: { type: "string", description: "Deployed token contract address (0x...)" }, expiration_days: { type: "number", description: "Duration in days (default: 365)" } }, required: ["name", "symbol", "token_address"] },
  • Handler function for register_loyalty_program, which inserts the program into the database.
    handler: async ({ name, symbol, token_address, expiration_days }: any) => {
      const err = authGuard(["mint", "create_program"]);
      if (err) return T(err);
      if (!/^0x[a-fA-F0-9]{40}$/.test(token_address)) return T('{"error":"Invalid token_address"}');
      const d = db();
      const { data: existing } = await d.from("loyalty_programs").select("id").eq("token_address", token_address.toLowerCase()).single();
      if (existing) return T('{"error":"Program already registered"}');
      const days = expiration_days || 365;
      const expDate = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toISOString();
      const { data: program, error } = await d.from("loyalty_programs").insert({ name: name.trim(), symbol: symbol.toUpperCase().trim(), token_address: token_address.toLowerCase(), merchant_address: agent.ownerAddress, status: "inactive", expiration_date: expDate }).select("id,name,symbol,token_address,status,expiration_date,created_at").single();
      if (error) return T(JSON.stringify({ error: error.message }));
      return T(JSON.stringify({ program, message: "Program registered as inactive. Call activate_loyalty_program next." }));
    },

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