Onchain loyalty MCP on Base: programs, mint, rewards, vouchers for AI agents.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
A Web3-powered loyalty platform built on Base Mainnet: merchants and AI agents create onchain loyalty programs (B20 by default), mint points, manage rewards/vouchers, and automate the loop via REST, MCP, and pay-per-call gateways (x402 / MPP).
Loyal Spark revolutionizes traditional loyalty programs by bringing them onchain. It operates as a dual-mode platform: humans interact via the web UI with flexible authentication (email, phone, social login, or wallet), while AI agents interact via REST API or MCP Server β sharing the same database, smart contracts, and tokens.
Wallet Abstraction: Users and merchants sign in via Privy β email, phone/SMS, Google, or external wallets (MetaMask, WalletConnect, Coinbase Wallet). Privy automatically creates an embedded wallet on Base β no crypto experience needed. Farcaster miniapp and SIWE for crypto-native users are also fully supported. Merchants can send tokens to customers by email or phone number (resolved to wallet address automatically).
accept_merchant_invite β see docs/development/PORTALS_AND_TEAM.mdmarketplace/ (DEX) and roundup/ (DeFi) remain in the tree but are explicitly frozen β no active development00β12 under /.well-known/skills/) for agent onboarding and operations| Layer | Technology |
|---|---|
| Frontend | React 18, TypeScript, Vite, Tailwind CSS, shadcn/ui (Radix) |
| Animations | Framer Motion |
| Blockchain | Wagmi v2, Viem, RainbowKit, Privy (@privy-io/react-auth + @privy-io/wagmi) |
| Network | Base Mainnet (Chain ID: 8453) |
| Smart Contracts | ERC-20 Token Standard (Factory pattern) |
| Backend | Supabase (PostgreSQL, RLS, Deno Edge Functions, Realtime) |
| Native apps | Capacitor 8 (iOS / Android) β see docs/development/NATIVE_BUILD_GUIDE.md |
| Agent Wallets | Coinbase CDP MPC (Server Wallets) |
| State | TanStack Query v5 |
| Routing | React Router DOM v6 |
| Forms | React Hook Form + Zod validation |
| Builder Attribution | Base Builder Code (ERC-8021) |
New loyalty programs (default) deploy via Baseβs native B20 factory precompile β one transaction, active immediately after register-program. Legacy programs use the Loyal Spark ERC-20 factory below (token_standard: "erc20" in API only). Full flows: docs/development/LOYALTY_PROGRAM_CONTRACTS.md.
| Role | Address | When |
|---|---|---|
| B20 Factory (Base precompile) | 0xB20f000000000000000000000000000000000000 | Default β createB20 β token 0xB200β¦ |
| LoyaltyTokenFactory (legacy) | 0x5F3DdBa12580CFdc6016258774cCc19C4250dA80 | Opt-in erc20 β createLoyaltyToken + activation |
| LoyalSparkERC20 (implementation) | 0xe6BA426C9c51281B929a17444De02c65815E27C3 | Logic for legacy proxy tokens |
| LoyaltyTokenEscrow (P2P) | 0xA569C95AfC1BCF381c48BcF336ED9D2c014bcdDF | Marketplace swaps |
Network: Base Mainnet (Chain ID: 8453)
| Path | Deploy | Activate | Portal |
|---|---|---|---|
| B20 (default) | 1à createB20 on 0xB20f⦠| Not required | Yes |
| Legacy ERC-20 | 1à createLoyaltyToken on 0x5F3DdB⦠| unpauseUtility + enableMinting | API only |
B20 tokens are ERC-20βcompatible for balances, transfers, mint, and escrow:
mint(address to, uint256 amount) β issue points (role-gated)transfer / transferFrom β move tokens between walletsbalanceOf(address) β query balanceMerchant dashboard:
lsk_...)x-api-key header for REST or MCP callsWithout the web app (autonomous agents): free lsk_ via wallet signature β Edge Function agent-register-siwe + nonce from siwe-nonce. See docs/agents/AUTONOMOUS_AGENT_REGISTRATION.md and docs/agents/QUICKSTART.md.
These directories are not imported by the web app; they are optional helpers for developers and agents reproducing flows locally. Secrets stay in environment variables only.
| Folder | Purpose |
|---|---|
scripts/x402-paid-mcp-test/ | Smoke test: paid MCP via x402 (USDC on Base, @x402/fetch). |
scripts/x402-paid-agent-api/ | Same stack, paid agent-api routes (GET/POST to x402-gateway/<resource>). |
scripts/traffic-bot-x402-bridge.py | Example Python β Node subprocess hook for bots that already send loyalty txs on Base. |
scripts/agent-register-siwe/ | Helper: build SIWE message + sign + call agent-register-siwe (same as production). |
Schemas for paid MCP: merchant mcp-tools/<name> β mcp-bazaar-tools.ts; recipient recipient-mcp-tools/<name> β recipient-mcp-bazaar-tools.ts. HTTP 402 accepts + Coinbase x402 Bazaar discovery metadata for all paid routes are built in x402-bazaar-accept.ts. These scripts are not linked from the marketing homepage; primary onboarding remains /for-agents and the merchant portal.
All routes below require x-api-key: lsk_... except GET /vouchers/status (public). Canonical catalogue: public/.well-known/agent.json (must match supabase/functions/agent-api/index.ts).
| Method | Path | Scope | Description |
|---|---|---|---|
| GET | /me | authenticated | Agent profile & permissions |
| GET | /workflow/program-status | read | Autonomous planner: lifecycle step + next_actions[] |
| GET | /programs | read | List loyalty programs |
| POST | /workflow/generate-program-defaults | mint | Propose program name, symbol, economics, and starter rewards from business context |
| POST | /programs | mint or create_program | Calldata to deploy loyalty token (B20 default, or legacy ERC-20 with token_standard: "erc20") |
| POST | /register-program | mint or create_program | Register deployed token (optional cashback_rate, points_per_dollar) |
| POST | /update-program-config | mint or create_program | Update cashback_rate / points_per_dollar for a program |
| POST | /activate-program | mint or create_program | Legacy ERC-20 activation only (no-op for B20) |
| POST | /program-status | mint or create_program | Update program status |
| GET | /rewards | read | List rewards |
| POST | /rewards | manage_rewards | Create reward |
| POST | /mint | mint | Fee-first mint calls[] + fee_obligation_id |
| POST | /mint/confirm | mint | Settle protocol fee after mint/earn (obligation_id + fee_tx_hash) |
| POST | /earn | mint | Cashback: mint from purchase amount Γ rate (same fee-first + confirm) |
| POST | /transfer | mint | Transfer tokens |
| GET | /balance | read | Token balance & tier |
| GET | /customers | read | Customer list |
| GET | /vouchers | read | List vouchers |
| GET | /vouchers/status | public | Check voucher status (no API key) |
| POST | /redeem-reward | read | Redeem reward β create voucher |
| POST | /vouchers/use | manage_rewards | Mark voucher as used |
| GET | /analytics | read | Program analytics |
| GET | /offers | read | Marketplace offers |
| POST | /offers | trade | Create P2P offer |
| POST | /accept-offer | trade | Accept P2P offer |
| POST | /cancel-offer | trade | Cancel P2P offer |
| GET | /tx-receipt | authenticated | Extract token_address from deploy tx |
| GET | /merchant-profile | read | Read merchant profile |
| POST | /merchant-profile | manage_rewards | Create or update merchant profile (PUT also accepted) |
Connect Claude, GPT, or any MCP-compatible agent:
MCP tools (39) β defined in supabase/functions/loyalty-mcp/index.ts:
get_platform_info, get_my_profile, generate_program_defaults, get_program_workflow_status, list_loyalty_programs, create_loyalty_program, register_loyalty_program, activate_loyalty_program, update_program_status, update_program_config, list_rewards, create_reward, mint_loyalty_tokens, transfer_loyalty_tokens, earn_points, confirm_mint_fee, get_token_balance, get_program_analytics, list_marketplace_offers, redeem_reward, use_voucher, check_voucher_status, get_platform_stats, cancel_stale_offers, create_personalized_offer, update_reward_status, export_customers, send_report, list_my_reports, update_report_status, delete_report, create_gift_certificate, list_gift_certificates, revoke_gift_certificate, mark_gift_certificate_minted, bazaar_discover_resources, bazaar_discover_mcp_servers, bazaar_probe_x402, bazaar_pay_and_call (confirm_mint_fee = lsk_-only fee settlement, not x402-priced; last four = Bazaar side-car).
send_calls-ready calldata)For AI users already connected to Base MCP (mcp.base.org), Loyal Spark ships GET-friendly calldata endpoints at https://api.loyalspark.online/agent-prepare/*. Each response returns a send_calls-compatible transaction batch with Builder Code bc_wdmnog7m already appended (ERC-8021). Base Account signs and broadcasts.
Actions: create-program, activate-program, mint, transfer (merchant, lsk_) Β· recipient-transfer, recipient-approve (holder, rwk_).
Plugin spec: skills/loyal-spark/plugins/loyal-spark.md.
rwk_)For AI agents that only hold a wallet which receives loyalty tokens (not merchant operators). Humans are unchanged; this is an optional machine path.
| Piece | URL / path |
|---|---|
| REST | https://api.loyalspark.online/recipient-api |
| MCP | https://api.loyalspark.online/recipient-loyalty-mcp |
| Register key | POST β¦/recipient-api/register with SIWE { message, signature } (nonce from siwe-nonce) β returns rwk_β¦ once. Pass Supabase apikey (anon/publishable) header like other public functions. |
REST (14 routes; all require x-api-key: rwk_β¦ except register): GET /me, GET /balances, GET /balance?token_address=, GET /rewards?token_address=, GET /vouchers, GET /workflow/reward-status, POST /register (SIWE), POST /redeem-reward with { reward_id, transaction_hash } (customer is always the bound wallet), POST /prepare-transfer with { token_address, to, amount }, POST /workflow/prepare-reward-redemption. P2P: GET /offers?token_address=, POST /offers, POST /accept-offer, POST /cancel-offer (same bodies as merchant agent-api marketplace; creator_address is the bound wallet).
MCP tools (20) β supabase/functions/recipient-loyalty-mcp/index.ts: get_recipient_profile, list_my_loyalty_balances, get_my_loyalty_balance, get_reward_workflow_status, prepare_reward_redemption, prepare_loyalty_token_transfer, list_rewards_for_program, list_my_vouchers, redeem_my_reward, list_p2p_offers, create_p2p_offer, accept_p2p_offer, cancel_p2p_offer, lookup_gift_certificate, claim_gift_certificate, list_my_gift_certificates, bazaar_discover_resources, bazaar_discover_mcp_servers, bazaar_probe_x402, bazaar_pay_and_call (last four = Bazaar side-car; bazaar_pay_and_call requires opt-in delegated CDP wallet).
Pay-per-call (recipient, MPP / x402): Autonomous agents that should pay USDC per request use the same gateways as merchants: mpp-gateway/recipient-api/β¦ (Tempo MPP) or x402-gateway/recipient-api/β¦ and x402-gateway/recipient-mcp-tools/<tool> (x402). USD prices match the merchant corridor (reads ~$0.001, writes ~$0.005β0.01; prepare-transfer / prepare_loyalty_token_transfer $0.005). Canonical tables: docs/business/MONETIZATION_AND_PRICING.md Β§4.1 Β· source constants: supabase/functions/_shared/recipient-paid-routes.ts, recipient-mcp-bazaar-tools.ts. Direct functions/v1/recipient-api / recipient-loyalty-mcp calls use rwk_ + rate limits only (no per-request USDC in the gateway layer).
Example MCP fragment: examples/recipient-agent-mcp/cursor-mcp.json.
AI agents can discover the protocol automatically via:
/.well-known/agent.json β Full protocol specification, capabilities, pricing/.well-known/skills/ β 13 structured Skills (00β12, step-by-step guides)/api-docs β Interactive API documentationStructured Markdown guides that teach agents how to use the protocol:
| # | Skill | Description |
|---|---|---|
| 00 | Getting Started | Register agent (merchant UI or SIWE), get lsk_, first request |
| 01 | Create Loyalty Program | Deploy B20 loyalty token on Base (legacy ERC-20 optional) |
| 02 | Mint Tokens | Mint tokens to customer wallets |
| 03 | Transfer Tokens | Transfer tokens between wallets |
| 04 | Manage Rewards | Create redeemable rewards catalog |
| 05 | Balance & Tiers | Check balances and tier status |
| 06 | Marketplace Trading | P2P token trading with atomic escrow |
| 07 | Analytics & CRM | Program analytics and CRM data |
| 08 | Referrals | Referral programs for organic growth |
| 09 | Vouchers | Voucher lifecycle management |
| 10 | Server Wallets | CDP MPC wallets for autonomous transactions |
| 11 | Earn Points (Cashback) | Mint from purchase amount Γ cashback rate |
Skills index: https://loyalspark.online/.well-known/skills/index.md
Agents can create their own Coinbase MPC wallets on Base for autonomous transactions:
Benefits:
| Plan | Monthly | API Calls | Agents | Mint fee |
|---|---|---|---|---|
| Free | $0 | 200 | 1 | 1.25% |
| Pro | $49 USDC | 10,000 | 5 | 0.5% |
| Enterprise | $129 USDC | Unlimited | Unlimited | 0.25% |
Merchant SaaS (portal): Starter $39 / Growth $79 / Scale $149 per month (annual discount 15β20% optional) β details in docs/business/MONETIZATION_AND_PRICING.md.
Payments for agent plans on-chain in USDC on Base ($1 = 1 USDC).
Mint fee is not USDC. It is charged in the merchant's own loyalty tokens β a second mint(address,uint256) to the platform fee wallet on the same token contract, returned first in the calls[] bundle. The token contract has no mintWithFee, so settlement is tracked off-chain: each prepared mint creates a fee obligation, and 5+ obligations unpaid for over 60 minutes block further mints with HTTP 402. Confirm with POST /agent-api/mint/confirm.
On Merchant and Customer portals, use the header Sign In / wallet control until a session exists; the Profile control appears only after you are signed in. See docs/development/PORTALS_AND_TEAM.md.
Network: Base Mainnet (Chain ID: 8453) | RPC: https://mainnet.base.org | Explorer: https://basescan.org
Indexes: AGENTS.md (AI agents) Β· docs/README.md (human guides) Β· docs/development/PORTALS_AND_TEAM.md (portal UI & team invites) Β· supabase/functions/README.md (Edge Functions).
See the supabase/functions/README.md catalogue (grouped by role: API, MCP, auth, payments, jobs). The root README table is intentionally shortened here to avoid duplication.
lsk_ prefix for agentsAll on-chain transactions are tagged with Base Builder Code bc_wdmnog7m (ERC-8021 format) for analytics visibility in base.dev.
Loyal Spark is a machine-payment-native API. AI agents can discover, authenticate, and pay for API calls without human intervention.
| Resource | URL | Purpose |
|---|---|---|
| Agent onboarding (web) | /for-agents | Keys, REST, MCP, gateways, discovery β one page for builders |
| Agent Manifest | /.well-known/agent.json | Full protocol spec, capabilities, pricing |
| MPP Manifest | /.well-known/mpp.json | Machine Payment Protocol manifest |
| OpenAPI Spec | /openapi.json | OpenAPI 3.1.0 with x-payment-info |
| Skills Library | /.well-known/skills/ | 13 step-by-step guides for agents (00β12) |
| LLMs.txt | /llms.txt | Protocol summary for LLM crawlers |
| Prompt Guide | PROMPT_GUIDE.md | Ready-to-use system prompts |
| Copy-paste MCP / curl | examples/agent-mcp/ | Starter configs in the repo |
| Repo quickstart (keys, SIWE, x402) | docs/agents/QUICKSTART.md | Short paths for coding agents |
Agents can pay per request using onchain micropayments:
| Protocol | Network | Asset | Gateway |
|---|---|---|---|
| x402 | Base | USDC | https://api.loyalspark.online/x402-gateway |
| MPP | Tempo | pathUSD / USDC | https://api.loyalspark.online/mpp-gateway |
Pricing: $0.001β$0.005 per read Β· $0.005β$0.05 per write Β· HTTP 402 challenge/response flow.
Paid MCP (merchant): POST β¦/x402-gateway/mcp-tools/<tool_name> (JSON-RPC tools/call); after settlement, pass x-api-key: lsk_β¦ like direct MCP. Recipient / holder MCP: POST β¦/x402-gateway/recipient-mcp-tools/<tool_name> with x-api-key: rwk_β¦. Tool lists + JSON Schemas: mcp-bazaar-tools.ts Β· recipient-mcp-bazaar-tools.ts. 402 + Bazaar (discovery) metadata for both families: x402-bazaar-accept.ts (extensions.bazaar, outputSchema.input.type: "mcp"). After successful settle, the CDP facilitator may return EXTENSION-RESPONSES (bazaar.status: success | processing | rejected).
io.github.aspekt19/loyal-spark (remote Streamable HTTP β api.loyalspark.online/loyalty-mcp; see root server.json)loyalspark/loyalty-protocol)MIT License β see LICENSE file for details.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/loyal-spark)<a href="https://allmcps.com/mcp/loyal-spark"><img src="https://allmcps.com/api/badge/loyal-spark?style=directory" alt="Loyal Spark on AllMCPs" /></a>