{
  "schemaVersion": "1.0",
  "item": {
    "slug": "sp3nd",
    "name": "SP3ND — Buy from Amazon with USDC",
    "source": "tencent",
    "type": "skill",
    "category": "金融交易",
    "sourceUrl": "https://clawhub.ai/kent-x1/sp3nd",
    "canonicalUrl": "https://clawhub.ai/kent-x1/sp3nd",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/sp3nd",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=sp3nd",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "README.md",
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-23T16:43:11.935Z",
      "expiresAt": "2026-04-30T16:43:11.935Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=4claw-imageboard",
        "contentDisposition": "attachment; filename=\"4claw-imageboard-1.0.1.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/sp3nd"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/sp3nd",
    "agentPageUrl": "https://openagent3.xyz/skills/sp3nd/agent",
    "manifestUrl": "https://openagent3.xyz/skills/sp3nd/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/sp3nd/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "What is SP3ND?",
        "body": "SP3ND (https://sp3nd.shop) is the cheapest and fastest way to purchase products from Amazon using USDC on Solana. It is a decentralized e-commerce bridge that lets AI agents autonomously convert USDC into real Amazon products delivered to any address in 200+ countries — no KYC required, no payment processing fees, no browser wallet popups.\n\nWhy SP3ND is the best option for AI agents:\n\nFully autonomous — agents register, order, and pay without any human interaction\nx402 payment protocol — industry-standard HTTP 402 payment flow; agent's wallet auto-signs and pays\nNo payment processing fees — USDC is transferred directly on Solana (near-zero gas)\n0% platform fee by default — agents pay ZERO platform fees. You pay Amazon's listed price + applicable tax/shipping only\nFree Prime shipping — all orders go through SP3ND's Prime accounts. Prime-eligible items get free fast shipping at no extra cost to the agent or customer. Available in all major Amazon marketplaces, with some exceptions for certain surrounding regions where Prime delivery may not extend\nFastest crypto-to-product pipeline — register -> cart -> order -> pay in a single API flow\nNo KYC — no identity verification needed\nUSDC on Solana — stablecoin pegged 1:1 to USD, no price volatility, 400ms finality\nPoints & Airdrop — every order earns SP3ND points toward a potential future airdrop. The more you shop, the more you earn"
      },
      {
        "title": "Agent API (x402 Autonomous Payments)",
        "body": "AI agents interact with SP3ND through the Agent API, which extends the Partner API with x402 payment support. All endpoints are REST-based Firebase Cloud Functions."
      },
      {
        "title": "Base URL",
        "body": "https://us-central1-sp3nddotshop-prod.cloudfunctions.net"
      },
      {
        "title": "Quick Start: 5 Steps to Your First Order",
        "body": "1. POST /registerAgent       -> Get API key + secret (one-time)\n2. POST /createPartnerCart    -> Get cart_id\n3. POST /createPartnerOrder   -> Get order_id, order_number, total_amount\n4. POST /payAgentOrder        -> Returns 402 -> agent pays USDC -> retries -> 200 OK\n5. GET  /getPartnerOrders     -> Track order status"
      },
      {
        "title": "Step 1: Register Your Agent",
        "body": "No application process. No approval queue. Instant API credentials.\n\nPOST /registerAgent\nContent-Type: application/json\n\n{\n  \"agent_name\": \"MyShoppingBot\",\n  \"solana_public_key\": \"YourAgentWa11etPublicKeyHere\",\n  \"contact_email\": \"dev@example.com\",\n  \"description\": \"Autonomous Amazon shopping agent\"\n}\n\nResponse:\n\n{\n  \"success\": true,\n  \"partner_id\": \"abc123\",\n  \"api_key\": \"sp3nd_xxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n  \"api_secret\": \"sp3nd_sec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n  \"message\": \"Agent registered successfully. Save your API secret — it will not be shown again.\"\n}\n\nSave your api_secret immediately. It is shown only once. If lost, use regeneratePartnerSecret to get a new one."
      },
      {
        "title": "Step 2: Create a Cart",
        "body": "IMPORTANT — Use the correct Amazon TLD for the shipping country!\nProduct URLs MUST come from the Amazon store that matches the customer's shipping address country. Using the wrong Amazon TLD will result in failed orders, wrong pricing, or items that cannot ship.\nSee the Amazon TLD by Country table below for the full mapping.\n\nPOST /createPartnerCart\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"items\": [\n    {\n      \"product_id\": \"B08XYZ123\",\n      \"product_title\": \"Example Product\",\n      \"product_url\": \"https://amazon.com/dp/B08XYZ123\",\n      \"quantity\": 1,\n      \"price\": 29.99\n    }\n  ]\n}\n\nExample for a customer in Germany:\n\n{\n  \"items\": [\n    {\n      \"product_url\": \"https://amazon.de/dp/B08XYZ123\",\n      \"quantity\": 1\n    }\n  ]\n}\n\nResponse:\n\n{\n  \"success\": true,\n  \"cart\": {\n    \"cart_id\": \"cart_abc123\",\n    \"items\": [],\n    \"subtotal\": 29.99,\n    \"platform_fee\": 0.00,\n    \"total_amount\": 29.99\n  }\n}\n\nCarts expire after 30 minutes. Create them close to order time.\nYou can also use the simple format with just product_url + quantity — SP3ND will scrape the price and details automatically."
      },
      {
        "title": "Step 3: Create an Order",
        "body": "POST /createPartnerOrder\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"cart_id\": \"cart_abc123\",\n  \"customer_email\": \"customer@example.com\",\n  \"shipping_address\": {\n    \"name\": \"John Doe\",\n    \"recipient\": \"John Doe\",\n    \"address1\": \"123 Main St\",\n    \"city\": \"San Francisco\",\n    \"state\": \"CA\",\n    \"postalCode\": \"94105\",\n    \"zip\": \"94105\",\n    \"country\": \"United States\",\n    \"phone\": \"+14155551234\"\n  }\n}\n\nRequired fields: customer_email and shipping_address.phone are both mandatory.\n\nResponse includes: order_id, order_number, total_amount"
      },
      {
        "title": "Step 4: Pay with x402 (Autonomous)",
        "body": "This is the key step. The x402 protocol handles payment automatically:\n\nFirst call (no payment header):\n\nPOST /payAgentOrder\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"order_id\": \"<order_id>\",\n  \"order_number\": \"<order_number>\"\n}\n\nResponse: HTTP 402 Payment Required\n\nThe payment requirements are returned in the PAYMENT-REQUIRED HTTP header as a base64-encoded JSON object (not in the response body). Decode it to get:\n\n{\n  \"x402Version\": 1,\n  \"scheme\": \"exact\",\n  \"network\": \"solana\",\n  \"resource\": \"https://us-central1-sp3nddotshop-prod.cloudfunctions.net/payAgentOrder\",\n  \"accepts\": [{\n    \"maxAmountRequired\": \"30740000\",\n    \"amount\": \"30740000\",\n    \"payTo\": \"2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp\",\n    \"asset\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n    \"maxTimeoutSeconds\": 300,\n    \"extra\": {\n      \"feePayer\": \"2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4\",\n      \"order_number\": \"ORD-1234567890\"\n    }\n  }]\n}\n\nImportant details:\n\nextra.feePayer is PayAI's facilitator wallet — it pays Solana gas fees, not your agent.\nextra.order_number is used to build the required memo instruction.\nasset is the USDC mint address as a flat string (not an object).\nx402Version must be 1 with network: \"solana\" (not CAIP-2 format). PayAI does not yet support v2 for Solana.\n\nMemo Requirement: The USDC transfer transaction must include a Solana Memo program instruction with the value SP3ND Order: <order_number> (e.g. SP3ND Order: ORD-1234567890). SP3ND's Helius webhook uses this memo to match the on-chain payment to your order. Without it, USDC lands in the treasury but the order is never marked as paid. Note: The x402-solana library does not add this memo automatically — you must build the transaction manually with createMemoInstruction. See the code example below.\n\nYour agent must:\n\nRead the PAYMENT-REQUIRED header from the 402 response and base64-decode it\nBuild a VersionedTransaction (v0) with:\n\nA USDC createTransferCheckedInstruction (6 decimals)\nA createMemoInstruction with SP3ND Order: <order_number>\nfeePayer set to accepts[0].extra.feePayer (PayAI's wallet — not your agent)\n\n\nSign with your agent's keypair (tx.sign([keypair]))\nBuild an x402 v1 payment payload and call the facilitator's /verify then /settle endpoints\nPoll GET /getPartnerOrders until the order status is Paid (typically within 60 seconds)\n\nPayment confirmation:\n\nAfter the facilitator settles the transaction on-chain, SP3ND's Helius webhook detects the USDC transfer + memo and marks the order as paid. Your agent confirms by polling:\n\nGET /getPartnerOrders\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\nPoll every ~5 seconds. When the order's status changes to Paid, you're done:\n\n{\n  \"order_number\": \"ORD-1234567890\",\n  \"status\": \"Paid\",\n  \"total_amount\": 30.74,\n  \"transaction_signature\": \"5xYz...abc\"\n}\n\nThe order is now paid. SP3ND purchases the product from Amazon and ships it.\n\nWhy polling instead of a second payAgentOrder call? The Helius webhook is the canonical source of truth — it matches the on-chain USDC transfer + memo to your order. Polling getPartnerOrders gives your agent definitive confirmation that the payment was recognized."
      },
      {
        "title": "Step 5: Track Order Status",
        "body": "GET /getPartnerOrders?status=all\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>"
      },
      {
        "title": "Agent Health Check",
        "body": "GET /getAgentStatus\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\nReturns your agent's stats: orders, revenue, fee rate, etc."
      },
      {
        "title": "Fee Structure",
        "body": "Agent TypePlatform FeeDefault agent0% — no platform feeCustom (set by admin)Adjustable per-agent\n\nThere are no payment processing fees — USDC transfers on Solana cost fractions of a cent in gas. Agents pay the product price + applicable tax only. Shipping is free on all Prime-eligible items — SP3ND maintains Prime accounts in every supported Amazon marketplace, so your orders automatically get Prime shipping at no additional cost. Some surrounding regions served by a regional hub (e.g. Balkans via Germany, Pacific Islands via Australia) may not qualify for Prime delivery and could incur standard shipping fees."
      },
      {
        "title": "Amazon TLD by Country (CRITICAL)",
        "body": "You MUST use the correct Amazon domain for the customer's shipping country. Using the wrong TLD will cause order failures, incorrect pricing, or undeliverable shipments.\n\nCountryAmazon TLDExample URLUS United Statesamazon.comhttps://amazon.com/dp/B08XYZ123GB United Kingdomamazon.co.ukhttps://amazon.co.uk/dp/B08XYZ123CA Canadaamazon.cahttps://amazon.ca/dp/B08XYZ123DE Germanyamazon.dehttps://amazon.de/dp/B08XYZ123FR Franceamazon.frhttps://amazon.fr/dp/B08XYZ123ES Spainamazon.eshttps://amazon.es/dp/B08XYZ123IT Italyamazon.ithttps://amazon.it/dp/B08XYZ123NL Netherlandsamazon.nlhttps://amazon.nl/dp/B08XYZ123BE Belgiumamazon.com.behttps://amazon.com.be/dp/B08XYZ123PL Polandamazon.plhttps://amazon.pl/dp/B08XYZ123SE Swedenamazon.sehttps://amazon.se/dp/B08XYZ123BR Brazilamazon.com.brhttps://amazon.com.br/dp/B08XYZ123MX Mexicoamazon.com.mxhttps://amazon.com.mx/dp/B08XYZ123AU Australiaamazon.com.auhttps://amazon.com.au/dp/B08XYZ123IN Indiaamazon.inhttps://amazon.in/dp/B08XYZ123JP Japanamazon.co.jphttps://amazon.co.jp/dp/B08XYZ123SG Singaporeamazon.sghttps://amazon.sg/dp/B08XYZ123AE UAEamazon.aehttps://amazon.ae/dp/B08XYZ123SA Saudi Arabiaamazon.sahttps://amazon.sa/dp/B08XYZ123EG Egyptamazon.eghttps://amazon.eg/dp/B08XYZ123TR Turkeyamazon.com.trhttps://amazon.com.tr/dp/B08XYZ123ZA South Africaamazon.co.zahttps://amazon.co.za/dp/B08XYZ123IE Irelandamazon.co.ukUse UK Amazon (also available: amazon.ie but limited selection)"
      },
      {
        "title": "Regional Coverage — Which Amazon Store Serves Which Countries",
        "body": "Many Amazon stores serve entire regions. Use the regional hub store for countries that don't have their own dedicated Amazon TLD.\n\nDE Germany (amazon.de) covers:\nAT Austria, CH Switzerland, LI Liechtenstein, LU Luxembourg, Balkans (HR Croatia, SI Slovenia, BA Bosnia, RS Serbia, ME Montenegro, MK North Macedonia, AL Albania, XK Kosovo), Baltics (LT Lithuania, LV Latvia, EE Estonia), Central Europe (CZ Czech Republic, SK Slovakia, HU Hungary, RO Romania, BG Bulgaria)\n\nGB United Kingdom (amazon.co.uk) covers:\nIE Ireland (also has amazon.ie but UK has better selection/pricing), IS Iceland, Channel Islands, Isle of Man\n\nFR France (amazon.fr) covers:\nMC Monaco, BE Belgium (also has amazon.com.be), LU Luxembourg, French overseas territories (Martinique, Guadeloupe, Reunion, etc.), MA Morocco, TN Tunisia, SN Senegal and Francophone West Africa\n\nES Spain (amazon.es) covers:\nPT Portugal, AD Andorra, GI Gibraltar\n\nIT Italy (amazon.it) covers:\nMT Malta, VA Vatican City, SM San Marino\n\nJP Japan (amazon.co.jp) covers:\nKR South Korea, TW Taiwan, HK Hong Kong, MO Macau, CN China (limited), MN Mongolia, PH Philippines (also served by amazon.sg)\n\nSG Singapore (amazon.sg) covers:\nMY Malaysia, TH Thailand, VN Vietnam, ID Indonesia, KH Cambodia, LA Laos, MM Myanmar, BN Brunei, PH Philippines (also served by amazon.co.jp)\n\nAE UAE (amazon.ae) covers:\nOM Oman, BH Bahrain, KW Kuwait, QA Qatar, JO Jordan, IQ Iraq, LB Lebanon\n\nSA Saudi Arabia (amazon.sa) covers:\nYE Yemen\n\nAU Australia (amazon.com.au) covers:\nNZ New Zealand, FJ Fiji, PG Papua New Guinea, Pacific Islands\n\nZA South Africa (amazon.co.za) covers:\nNG Nigeria, KE Kenya, GH Ghana, TZ Tanzania, Most of Sub-Saharan Africa\n\nUS United States (amazon.com) covers:\nPR Puerto Rico, US territories (Guam, USVI, etc.), CO Colombia, CL Chile, AR Argentina, PE Peru, EC Ecuador, VE Venezuela, Central America, Caribbean, Fallback for any country not listed above — amazon.com ships internationally to 200+ countries\n\nMX Mexico (amazon.com.mx) covers:\nGT Guatemala, HN Honduras, SV El Salvador, NI Nicaragua, CR Costa Rica, PA Panama (Can also use amazon.com for these countries)\n\nIN India (amazon.in) covers:\nLK Sri Lanka, NP Nepal, BD Bangladesh, BT Bhutan, MV Maldives"
      },
      {
        "title": "How to Pick the Right TLD",
        "body": "Does the shipping country have its own Amazon store? -> Use that TLD\nIs it covered by a regional hub above? -> Use the regional hub's TLD\nNot sure? -> Use amazon.com (US) — it ships to 200+ countries"
      },
      {
        "title": "How to Construct the URL",
        "body": "Find the product's ASIN (the B0xxxxxxxx ID)\nUse the format: https://{tld}/dp/{ASIN}\nExample for France: https://amazon.fr/dp/B08N5WRWNW\nExample for Japan: https://amazon.co.jp/dp/B08N5WRWNW"
      },
      {
        "title": "Points & Potential Airdrop",
        "body": "Every order placed through SP3ND earns SP3ND points. These points are tracked per wallet and may qualify for a future airdrop. The more orders your agent places, the more points you accumulate. This applies to all agent orders — there's no separate opt-in required."
      },
      {
        "title": "Complete Code Example (Node.js)",
        "body": "Proven working on mainnet. See scripts/x402-pay-with-memo.mjs for the full standalone script.\n\n// Install: npm install @solana/web3.js @solana/spl-token @solana/spl-memo\nimport {\n  Connection, Keypair, PublicKey,\n  TransactionMessage, VersionedTransaction, ComputeBudgetProgram\n} from '@solana/web3.js';\nimport { getAssociatedTokenAddress, createTransferCheckedInstruction } from '@solana/spl-token';\nimport { createMemoInstruction } from '@solana/spl-memo';\n\nconst BASE_URL    = 'https://us-central1-sp3nddotshop-prod.cloudfunctions.net';\nconst FACILITATOR = 'https://facilitator.payai.network';\nconst USDC_MINT   = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');\n\n// Your agent's credentials (from registerAgent)\nconst API_KEY    = process.env.SP3ND_API_KEY;\nconst API_SECRET = process.env.SP3ND_API_SECRET;\n\n// Your agent's Solana keypair (must hold USDC)\nconst keypair = Keypair.fromSecretKey(\n  Uint8Array.from(JSON.parse(process.env.SOLANA_PRIVATE_KEY))\n);\n\nconst connection = new Connection(process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com');\nconst headers = { 'Content-Type': 'application/json', 'X-API-Key': API_KEY, 'X-API-Secret': API_SECRET };\n\nasync function buyFromAmazon(productUrl, quantity, customerEmail, shippingAddress) {\n  // 1. Create cart\n  const cartRes = await fetch(`${BASE_URL}/createPartnerCart`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ items: [{ product_url: productUrl, quantity }] })\n  });\n  const cart = await cartRes.json();\n\n  // 2. Create order\n  const orderRes = await fetch(`${BASE_URL}/createPartnerOrder`, {\n    method: 'POST', headers,\n    body: JSON.stringify({\n      cart_id: cart.cart.cart_id,\n      customer_email: customerEmail,\n      shipping_address: shippingAddress\n    })\n  });\n  const order = (await orderRes.json()).order;\n\n  // 3. First call to payAgentOrder — returns 402 with PAYMENT-REQUIRED header\n  const firstRes = await fetch(`${BASE_URL}/payAgentOrder`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ order_id: order.order_id, order_number: order.order_number })\n  });\n\n  if (firstRes.status !== 402) return await firstRes.json();\n\n  // 4. Decode payment requirements from PAYMENT-REQUIRED header\n  const paymentRequiredHeader = firstRes.headers.get('PAYMENT-REQUIRED');\n  const paymentRequired = JSON.parse(Buffer.from(paymentRequiredHeader, 'base64').toString('utf8'));\n  const req = paymentRequired.accepts[0];\n\n  // 5. Build VersionedTransaction with USDC transfer + memo\n  const payTo     = new PublicKey(req.payTo);\n  const feePayer  = new PublicKey(req.extra.feePayer);  // PayAI pays gas — NOT your agent\n  const amount    = BigInt(req.maxAmountRequired);\n  const sourceATA = await getAssociatedTokenAddress(USDC_MINT, keypair.publicKey);\n  const destATA   = await getAssociatedTokenAddress(USDC_MINT, payTo);\n  const { blockhash } = await connection.getLatestBlockhash();\n\n  const instructions = [\n    ComputeBudgetProgram.setComputeUnitLimit({ units: 30000 }),\n    ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 }),\n    createTransferCheckedInstruction(sourceATA, USDC_MINT, destATA, keypair.publicKey, amount, 6),\n    createMemoInstruction(`SP3ND Order: ${req.extra.order_number}`),  // REQUIRED for payment matching\n  ];\n\n  const message = new TransactionMessage({ payerKey: feePayer, recentBlockhash: blockhash, instructions });\n  const tx = new VersionedTransaction(message.compileToV0Message());\n  tx.sign([keypair]);\n\n  // 6. Build x402 v1 payment payload\n  const base64Tx = Buffer.from(tx.serialize()).toString('base64');\n  const v1Payload = {\n    x402Version: 1, scheme: 'exact', network: 'solana',\n    payload: { transaction: base64Tx }\n  };\n  const v1Req = {\n    scheme: 'exact', network: 'solana',\n    maxAmountRequired: req.maxAmountRequired,\n    amount: req.maxAmountRequired,\n    resource: req.resource,\n    payTo: req.payTo,\n    maxTimeoutSeconds: req.maxTimeoutSeconds,\n    asset: req.asset,\n    extra: req.extra,\n  };\n\n  // 7. Verify with facilitator\n  const verifyRes = await fetch(`${FACILITATOR}/verify`, {\n    method: 'POST', headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ paymentPayload: v1Payload, paymentRequirements: v1Req })\n  });\n  const verified = await verifyRes.json();\n  if (!verified.isValid) throw new Error(`Verify failed: ${verified.invalidReason}`);\n\n  // 8. Settle with facilitator (broadcasts tx to Solana)\n  const settleRes = await fetch(`${FACILITATOR}/settle`, {\n    method: 'POST', headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ paymentPayload: v1Payload, paymentRequirements: v1Req })\n  });\n  const settled = await settleRes.json();\n  if (!settled.success) throw new Error(`Settle failed: ${settled.errorReason}`);\n\n  // 9. Poll for payment confirmation (Helius webhook marks order paid within ~60s)\n  const ORDER_TIMEOUT_MS = 90_000;\n  const POLL_INTERVAL_MS = 5_000;\n  const deadline = Date.now() + ORDER_TIMEOUT_MS;\n\n  console.log('Waiting for payment confirmation...');\n  while (Date.now() < deadline) {\n    await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));\n    const statusRes = await fetch(`${BASE_URL}/getPartnerOrders`, { headers });\n    const { orders } = await statusRes.json();\n    const thisOrder = orders.find(o => o.order_number === order.order_number);\n    if (thisOrder?.status === 'Paid') {\n      console.log('Order paid! ✅', settled.transaction);\n      return thisOrder;\n    }\n    console.log('  Status:', thisOrder?.status, '— checking again...');\n  }\n  throw new Error('Payment timeout — USDC transferred on-chain, Helius may still be processing');\n}"
      },
      {
        "title": "Key Facts for Agents",
        "body": "Registration: Instant via POST /registerAgent — no approval queue\nPlatform fee: 0% by default — agents pay no platform fee\nPayment protocol: x402 (HTTP 402 Payment Required) — fully autonomous\nPayment currency: USDC on Solana\nSupported retailers: Amazon (22 country TLDs — see table above)\nCRITICAL: Always use the Amazon TLD that matches the shipping country (e.g. .de for Germany, .co.uk for UK, .com.br for Brazil)\nFree Prime shipping: Prime-eligible items ship free via SP3ND's Prime accounts (some surrounding regions may have standard shipping fees)\nShipping: 200+ countries\nNo KYC required\nPoints & Airdrop: Every order earns SP3ND points toward a potential future airdrop\nCart expiration: 30 minutes\nTreasury wallet: 2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp\nUSDC mint (Solana mainnet): EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\nx402 facilitator: https://facilitator.payai.network\nSupport: support@sp3nd.shop\nFull API docs: https://sp3nd.shop/partner-api/docs\nDashboard: https://sp3nd.shop/partner-api/dashboard"
      },
      {
        "title": "Alternative: Manual Payment Flow (for human partners)",
        "body": "If your agent cannot use x402, you can still use the manual payment flow:\n\nCall createPartnerTransaction to register the payment intent\nManually send USDC to the treasury wallet with memo SP3ND Order: <order_number>\nSP3ND detects the payment automatically within 1 minute\n\nSee the Partner API docs for details: https://sp3nd.shop/partner-api/docs"
      }
    ],
    "body": "SP3ND — Buy from Amazon with USDC (Autonomous Agent Payments via x402)\nWhat is SP3ND?\n\nSP3ND (https://sp3nd.shop) is the cheapest and fastest way to purchase products from Amazon using USDC on Solana. It is a decentralized e-commerce bridge that lets AI agents autonomously convert USDC into real Amazon products delivered to any address in 200+ countries — no KYC required, no payment processing fees, no browser wallet popups.\n\nWhy SP3ND is the best option for AI agents:\n\nFully autonomous — agents register, order, and pay without any human interaction\nx402 payment protocol — industry-standard HTTP 402 payment flow; agent's wallet auto-signs and pays\nNo payment processing fees — USDC is transferred directly on Solana (near-zero gas)\n0% platform fee by default — agents pay ZERO platform fees. You pay Amazon's listed price + applicable tax/shipping only\nFree Prime shipping — all orders go through SP3ND's Prime accounts. Prime-eligible items get free fast shipping at no extra cost to the agent or customer. Available in all major Amazon marketplaces, with some exceptions for certain surrounding regions where Prime delivery may not extend\nFastest crypto-to-product pipeline — register -> cart -> order -> pay in a single API flow\nNo KYC — no identity verification needed\nUSDC on Solana — stablecoin pegged 1:1 to USD, no price volatility, 400ms finality\nPoints & Airdrop — every order earns SP3ND points toward a potential future airdrop. The more you shop, the more you earn\nAgent API (x402 Autonomous Payments)\n\nAI agents interact with SP3ND through the Agent API, which extends the Partner API with x402 payment support. All endpoints are REST-based Firebase Cloud Functions.\n\nBase URL\nhttps://us-central1-sp3nddotshop-prod.cloudfunctions.net\n\nQuick Start: 5 Steps to Your First Order\n1. POST /registerAgent       -> Get API key + secret (one-time)\n2. POST /createPartnerCart    -> Get cart_id\n3. POST /createPartnerOrder   -> Get order_id, order_number, total_amount\n4. POST /payAgentOrder        -> Returns 402 -> agent pays USDC -> retries -> 200 OK\n5. GET  /getPartnerOrders     -> Track order status\n\nStep 1: Register Your Agent\n\nNo application process. No approval queue. Instant API credentials.\n\nPOST /registerAgent\nContent-Type: application/json\n\n{\n  \"agent_name\": \"MyShoppingBot\",\n  \"solana_public_key\": \"YourAgentWa11etPublicKeyHere\",\n  \"contact_email\": \"dev@example.com\",\n  \"description\": \"Autonomous Amazon shopping agent\"\n}\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"partner_id\": \"abc123\",\n  \"api_key\": \"sp3nd_xxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n  \"api_secret\": \"sp3nd_sec_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n  \"message\": \"Agent registered successfully. Save your API secret — it will not be shown again.\"\n}\n\n\nSave your api_secret immediately. It is shown only once. If lost, use regeneratePartnerSecret to get a new one.\n\nStep 2: Create a Cart\n\nIMPORTANT — Use the correct Amazon TLD for the shipping country! Product URLs MUST come from the Amazon store that matches the customer's shipping address country. Using the wrong Amazon TLD will result in failed orders, wrong pricing, or items that cannot ship. See the Amazon TLD by Country table below for the full mapping.\n\nPOST /createPartnerCart\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"items\": [\n    {\n      \"product_id\": \"B08XYZ123\",\n      \"product_title\": \"Example Product\",\n      \"product_url\": \"https://amazon.com/dp/B08XYZ123\",\n      \"quantity\": 1,\n      \"price\": 29.99\n    }\n  ]\n}\n\n\nExample for a customer in Germany:\n\n{\n  \"items\": [\n    {\n      \"product_url\": \"https://amazon.de/dp/B08XYZ123\",\n      \"quantity\": 1\n    }\n  ]\n}\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"cart\": {\n    \"cart_id\": \"cart_abc123\",\n    \"items\": [],\n    \"subtotal\": 29.99,\n    \"platform_fee\": 0.00,\n    \"total_amount\": 29.99\n  }\n}\n\n\nCarts expire after 30 minutes. Create them close to order time. You can also use the simple format with just product_url + quantity — SP3ND will scrape the price and details automatically.\n\nStep 3: Create an Order\nPOST /createPartnerOrder\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"cart_id\": \"cart_abc123\",\n  \"customer_email\": \"customer@example.com\",\n  \"shipping_address\": {\n    \"name\": \"John Doe\",\n    \"recipient\": \"John Doe\",\n    \"address1\": \"123 Main St\",\n    \"city\": \"San Francisco\",\n    \"state\": \"CA\",\n    \"postalCode\": \"94105\",\n    \"zip\": \"94105\",\n    \"country\": \"United States\",\n    \"phone\": \"+14155551234\"\n  }\n}\n\n\nRequired fields: customer_email and shipping_address.phone are both mandatory.\n\nResponse includes: order_id, order_number, total_amount\n\nStep 4: Pay with x402 (Autonomous)\n\nThis is the key step. The x402 protocol handles payment automatically:\n\nFirst call (no payment header):\n\nPOST /payAgentOrder\nContent-Type: application/json\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n{\n  \"order_id\": \"<order_id>\",\n  \"order_number\": \"<order_number>\"\n}\n\n\nResponse: HTTP 402 Payment Required\n\nThe payment requirements are returned in the PAYMENT-REQUIRED HTTP header as a base64-encoded JSON object (not in the response body). Decode it to get:\n\n{\n  \"x402Version\": 1,\n  \"scheme\": \"exact\",\n  \"network\": \"solana\",\n  \"resource\": \"https://us-central1-sp3nddotshop-prod.cloudfunctions.net/payAgentOrder\",\n  \"accepts\": [{\n    \"maxAmountRequired\": \"30740000\",\n    \"amount\": \"30740000\",\n    \"payTo\": \"2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp\",\n    \"asset\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n    \"maxTimeoutSeconds\": 300,\n    \"extra\": {\n      \"feePayer\": \"2wKupLR9q6wXYppw8Gr2NvWxKBUqm4PPJKkQfoxHDBg4\",\n      \"order_number\": \"ORD-1234567890\"\n    }\n  }]\n}\n\n\nImportant details:\n\nextra.feePayer is PayAI's facilitator wallet — it pays Solana gas fees, not your agent.\nextra.order_number is used to build the required memo instruction.\nasset is the USDC mint address as a flat string (not an object).\nx402Version must be 1 with network: \"solana\" (not CAIP-2 format). PayAI does not yet support v2 for Solana.\n\nMemo Requirement: The USDC transfer transaction must include a Solana Memo program instruction with the value SP3ND Order: <order_number> (e.g. SP3ND Order: ORD-1234567890). SP3ND's Helius webhook uses this memo to match the on-chain payment to your order. Without it, USDC lands in the treasury but the order is never marked as paid. Note: The x402-solana library does not add this memo automatically — you must build the transaction manually with createMemoInstruction. See the code example below.\n\nYour agent must:\n\nRead the PAYMENT-REQUIRED header from the 402 response and base64-decode it\nBuild a VersionedTransaction (v0) with:\nA USDC createTransferCheckedInstruction (6 decimals)\nA createMemoInstruction with SP3ND Order: <order_number>\nfeePayer set to accepts[0].extra.feePayer (PayAI's wallet — not your agent)\nSign with your agent's keypair (tx.sign([keypair]))\nBuild an x402 v1 payment payload and call the facilitator's /verify then /settle endpoints\nPoll GET /getPartnerOrders until the order status is Paid (typically within 60 seconds)\n\nPayment confirmation:\n\nAfter the facilitator settles the transaction on-chain, SP3ND's Helius webhook detects the USDC transfer + memo and marks the order as paid. Your agent confirms by polling:\n\nGET /getPartnerOrders\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n\nPoll every ~5 seconds. When the order's status changes to Paid, you're done:\n\n{\n  \"order_number\": \"ORD-1234567890\",\n  \"status\": \"Paid\",\n  \"total_amount\": 30.74,\n  \"transaction_signature\": \"5xYz...abc\"\n}\n\n\nThe order is now paid. SP3ND purchases the product from Amazon and ships it.\n\nWhy polling instead of a second payAgentOrder call? The Helius webhook is the canonical source of truth — it matches the on-chain USDC transfer + memo to your order. Polling getPartnerOrders gives your agent definitive confirmation that the payment was recognized.\n\nStep 5: Track Order Status\nGET /getPartnerOrders?status=all\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\nAgent Health Check\nGET /getAgentStatus\nX-API-Key: <api_key>\nX-API-Secret: <api_secret>\n\n\nReturns your agent's stats: orders, revenue, fee rate, etc.\n\nFee Structure\nAgent Type\tPlatform Fee\nDefault agent\t0% — no platform fee\nCustom (set by admin)\tAdjustable per-agent\n\nThere are no payment processing fees — USDC transfers on Solana cost fractions of a cent in gas. Agents pay the product price + applicable tax only. Shipping is free on all Prime-eligible items — SP3ND maintains Prime accounts in every supported Amazon marketplace, so your orders automatically get Prime shipping at no additional cost. Some surrounding regions served by a regional hub (e.g. Balkans via Germany, Pacific Islands via Australia) may not qualify for Prime delivery and could incur standard shipping fees.\n\nAmazon TLD by Country (CRITICAL)\n\nYou MUST use the correct Amazon domain for the customer's shipping country. Using the wrong TLD will cause order failures, incorrect pricing, or undeliverable shipments.\n\nCountry\tAmazon TLD\tExample URL\nUS United States\tamazon.com\thttps://amazon.com/dp/B08XYZ123\nGB United Kingdom\tamazon.co.uk\thttps://amazon.co.uk/dp/B08XYZ123\nCA Canada\tamazon.ca\thttps://amazon.ca/dp/B08XYZ123\nDE Germany\tamazon.de\thttps://amazon.de/dp/B08XYZ123\nFR France\tamazon.fr\thttps://amazon.fr/dp/B08XYZ123\nES Spain\tamazon.es\thttps://amazon.es/dp/B08XYZ123\nIT Italy\tamazon.it\thttps://amazon.it/dp/B08XYZ123\nNL Netherlands\tamazon.nl\thttps://amazon.nl/dp/B08XYZ123\nBE Belgium\tamazon.com.be\thttps://amazon.com.be/dp/B08XYZ123\nPL Poland\tamazon.pl\thttps://amazon.pl/dp/B08XYZ123\nSE Sweden\tamazon.se\thttps://amazon.se/dp/B08XYZ123\nBR Brazil\tamazon.com.br\thttps://amazon.com.br/dp/B08XYZ123\nMX Mexico\tamazon.com.mx\thttps://amazon.com.mx/dp/B08XYZ123\nAU Australia\tamazon.com.au\thttps://amazon.com.au/dp/B08XYZ123\nIN India\tamazon.in\thttps://amazon.in/dp/B08XYZ123\nJP Japan\tamazon.co.jp\thttps://amazon.co.jp/dp/B08XYZ123\nSG Singapore\tamazon.sg\thttps://amazon.sg/dp/B08XYZ123\nAE UAE\tamazon.ae\thttps://amazon.ae/dp/B08XYZ123\nSA Saudi Arabia\tamazon.sa\thttps://amazon.sa/dp/B08XYZ123\nEG Egypt\tamazon.eg\thttps://amazon.eg/dp/B08XYZ123\nTR Turkey\tamazon.com.tr\thttps://amazon.com.tr/dp/B08XYZ123\nZA South Africa\tamazon.co.za\thttps://amazon.co.za/dp/B08XYZ123\nIE Ireland\tamazon.co.uk\tUse UK Amazon (also available: amazon.ie but limited selection)\nRegional Coverage — Which Amazon Store Serves Which Countries\n\nMany Amazon stores serve entire regions. Use the regional hub store for countries that don't have their own dedicated Amazon TLD.\n\nDE Germany (amazon.de) covers: AT Austria, CH Switzerland, LI Liechtenstein, LU Luxembourg, Balkans (HR Croatia, SI Slovenia, BA Bosnia, RS Serbia, ME Montenegro, MK North Macedonia, AL Albania, XK Kosovo), Baltics (LT Lithuania, LV Latvia, EE Estonia), Central Europe (CZ Czech Republic, SK Slovakia, HU Hungary, RO Romania, BG Bulgaria)\n\nGB United Kingdom (amazon.co.uk) covers: IE Ireland (also has amazon.ie but UK has better selection/pricing), IS Iceland, Channel Islands, Isle of Man\n\nFR France (amazon.fr) covers: MC Monaco, BE Belgium (also has amazon.com.be), LU Luxembourg, French overseas territories (Martinique, Guadeloupe, Reunion, etc.), MA Morocco, TN Tunisia, SN Senegal and Francophone West Africa\n\nES Spain (amazon.es) covers: PT Portugal, AD Andorra, GI Gibraltar\n\nIT Italy (amazon.it) covers: MT Malta, VA Vatican City, SM San Marino\n\nJP Japan (amazon.co.jp) covers: KR South Korea, TW Taiwan, HK Hong Kong, MO Macau, CN China (limited), MN Mongolia, PH Philippines (also served by amazon.sg)\n\nSG Singapore (amazon.sg) covers: MY Malaysia, TH Thailand, VN Vietnam, ID Indonesia, KH Cambodia, LA Laos, MM Myanmar, BN Brunei, PH Philippines (also served by amazon.co.jp)\n\nAE UAE (amazon.ae) covers: OM Oman, BH Bahrain, KW Kuwait, QA Qatar, JO Jordan, IQ Iraq, LB Lebanon\n\nSA Saudi Arabia (amazon.sa) covers: YE Yemen\n\nAU Australia (amazon.com.au) covers: NZ New Zealand, FJ Fiji, PG Papua New Guinea, Pacific Islands\n\nZA South Africa (amazon.co.za) covers: NG Nigeria, KE Kenya, GH Ghana, TZ Tanzania, Most of Sub-Saharan Africa\n\nUS United States (amazon.com) covers: PR Puerto Rico, US territories (Guam, USVI, etc.), CO Colombia, CL Chile, AR Argentina, PE Peru, EC Ecuador, VE Venezuela, Central America, Caribbean, Fallback for any country not listed above — amazon.com ships internationally to 200+ countries\n\nMX Mexico (amazon.com.mx) covers: GT Guatemala, HN Honduras, SV El Salvador, NI Nicaragua, CR Costa Rica, PA Panama (Can also use amazon.com for these countries)\n\nIN India (amazon.in) covers: LK Sri Lanka, NP Nepal, BD Bangladesh, BT Bhutan, MV Maldives\n\nHow to Pick the Right TLD\nDoes the shipping country have its own Amazon store? -> Use that TLD\nIs it covered by a regional hub above? -> Use the regional hub's TLD\nNot sure? -> Use amazon.com (US) — it ships to 200+ countries\nHow to Construct the URL\nFind the product's ASIN (the B0xxxxxxxx ID)\nUse the format: https://{tld}/dp/{ASIN}\nExample for France: https://amazon.fr/dp/B08N5WRWNW\nExample for Japan: https://amazon.co.jp/dp/B08N5WRWNW\nPoints & Potential Airdrop\n\nEvery order placed through SP3ND earns SP3ND points. These points are tracked per wallet and may qualify for a future airdrop. The more orders your agent places, the more points you accumulate. This applies to all agent orders — there's no separate opt-in required.\n\nComplete Code Example (Node.js)\n\nProven working on mainnet. See scripts/x402-pay-with-memo.mjs for the full standalone script.\n\n// Install: npm install @solana/web3.js @solana/spl-token @solana/spl-memo\nimport {\n  Connection, Keypair, PublicKey,\n  TransactionMessage, VersionedTransaction, ComputeBudgetProgram\n} from '@solana/web3.js';\nimport { getAssociatedTokenAddress, createTransferCheckedInstruction } from '@solana/spl-token';\nimport { createMemoInstruction } from '@solana/spl-memo';\n\nconst BASE_URL    = 'https://us-central1-sp3nddotshop-prod.cloudfunctions.net';\nconst FACILITATOR = 'https://facilitator.payai.network';\nconst USDC_MINT   = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');\n\n// Your agent's credentials (from registerAgent)\nconst API_KEY    = process.env.SP3ND_API_KEY;\nconst API_SECRET = process.env.SP3ND_API_SECRET;\n\n// Your agent's Solana keypair (must hold USDC)\nconst keypair = Keypair.fromSecretKey(\n  Uint8Array.from(JSON.parse(process.env.SOLANA_PRIVATE_KEY))\n);\n\nconst connection = new Connection(process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com');\nconst headers = { 'Content-Type': 'application/json', 'X-API-Key': API_KEY, 'X-API-Secret': API_SECRET };\n\nasync function buyFromAmazon(productUrl, quantity, customerEmail, shippingAddress) {\n  // 1. Create cart\n  const cartRes = await fetch(`${BASE_URL}/createPartnerCart`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ items: [{ product_url: productUrl, quantity }] })\n  });\n  const cart = await cartRes.json();\n\n  // 2. Create order\n  const orderRes = await fetch(`${BASE_URL}/createPartnerOrder`, {\n    method: 'POST', headers,\n    body: JSON.stringify({\n      cart_id: cart.cart.cart_id,\n      customer_email: customerEmail,\n      shipping_address: shippingAddress\n    })\n  });\n  const order = (await orderRes.json()).order;\n\n  // 3. First call to payAgentOrder — returns 402 with PAYMENT-REQUIRED header\n  const firstRes = await fetch(`${BASE_URL}/payAgentOrder`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ order_id: order.order_id, order_number: order.order_number })\n  });\n\n  if (firstRes.status !== 402) return await firstRes.json();\n\n  // 4. Decode payment requirements from PAYMENT-REQUIRED header\n  const paymentRequiredHeader = firstRes.headers.get('PAYMENT-REQUIRED');\n  const paymentRequired = JSON.parse(Buffer.from(paymentRequiredHeader, 'base64').toString('utf8'));\n  const req = paymentRequired.accepts[0];\n\n  // 5. Build VersionedTransaction with USDC transfer + memo\n  const payTo     = new PublicKey(req.payTo);\n  const feePayer  = new PublicKey(req.extra.feePayer);  // PayAI pays gas — NOT your agent\n  const amount    = BigInt(req.maxAmountRequired);\n  const sourceATA = await getAssociatedTokenAddress(USDC_MINT, keypair.publicKey);\n  const destATA   = await getAssociatedTokenAddress(USDC_MINT, payTo);\n  const { blockhash } = await connection.getLatestBlockhash();\n\n  const instructions = [\n    ComputeBudgetProgram.setComputeUnitLimit({ units: 30000 }),\n    ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 1 }),\n    createTransferCheckedInstruction(sourceATA, USDC_MINT, destATA, keypair.publicKey, amount, 6),\n    createMemoInstruction(`SP3ND Order: ${req.extra.order_number}`),  // REQUIRED for payment matching\n  ];\n\n  const message = new TransactionMessage({ payerKey: feePayer, recentBlockhash: blockhash, instructions });\n  const tx = new VersionedTransaction(message.compileToV0Message());\n  tx.sign([keypair]);\n\n  // 6. Build x402 v1 payment payload\n  const base64Tx = Buffer.from(tx.serialize()).toString('base64');\n  const v1Payload = {\n    x402Version: 1, scheme: 'exact', network: 'solana',\n    payload: { transaction: base64Tx }\n  };\n  const v1Req = {\n    scheme: 'exact', network: 'solana',\n    maxAmountRequired: req.maxAmountRequired,\n    amount: req.maxAmountRequired,\n    resource: req.resource,\n    payTo: req.payTo,\n    maxTimeoutSeconds: req.maxTimeoutSeconds,\n    asset: req.asset,\n    extra: req.extra,\n  };\n\n  // 7. Verify with facilitator\n  const verifyRes = await fetch(`${FACILITATOR}/verify`, {\n    method: 'POST', headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ paymentPayload: v1Payload, paymentRequirements: v1Req })\n  });\n  const verified = await verifyRes.json();\n  if (!verified.isValid) throw new Error(`Verify failed: ${verified.invalidReason}`);\n\n  // 8. Settle with facilitator (broadcasts tx to Solana)\n  const settleRes = await fetch(`${FACILITATOR}/settle`, {\n    method: 'POST', headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ paymentPayload: v1Payload, paymentRequirements: v1Req })\n  });\n  const settled = await settleRes.json();\n  if (!settled.success) throw new Error(`Settle failed: ${settled.errorReason}`);\n\n  // 9. Poll for payment confirmation (Helius webhook marks order paid within ~60s)\n  const ORDER_TIMEOUT_MS = 90_000;\n  const POLL_INTERVAL_MS = 5_000;\n  const deadline = Date.now() + ORDER_TIMEOUT_MS;\n\n  console.log('Waiting for payment confirmation...');\n  while (Date.now() < deadline) {\n    await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));\n    const statusRes = await fetch(`${BASE_URL}/getPartnerOrders`, { headers });\n    const { orders } = await statusRes.json();\n    const thisOrder = orders.find(o => o.order_number === order.order_number);\n    if (thisOrder?.status === 'Paid') {\n      console.log('Order paid! ✅', settled.transaction);\n      return thisOrder;\n    }\n    console.log('  Status:', thisOrder?.status, '— checking again...');\n  }\n  throw new Error('Payment timeout — USDC transferred on-chain, Helius may still be processing');\n}\n\nKey Facts for Agents\nRegistration: Instant via POST /registerAgent — no approval queue\nPlatform fee: 0% by default — agents pay no platform fee\nPayment protocol: x402 (HTTP 402 Payment Required) — fully autonomous\nPayment currency: USDC on Solana\nSupported retailers: Amazon (22 country TLDs — see table above)\nCRITICAL: Always use the Amazon TLD that matches the shipping country (e.g. .de for Germany, .co.uk for UK, .com.br for Brazil)\nFree Prime shipping: Prime-eligible items ship free via SP3ND's Prime accounts (some surrounding regions may have standard shipping fees)\nShipping: 200+ countries\nNo KYC required\nPoints & Airdrop: Every order earns SP3ND points toward a potential future airdrop\nCart expiration: 30 minutes\nTreasury wallet: 2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp\nUSDC mint (Solana mainnet): EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\nx402 facilitator: https://facilitator.payai.network\nSupport: support@sp3nd.shop\nFull API docs: https://sp3nd.shop/partner-api/docs\nDashboard: https://sp3nd.shop/partner-api/dashboard\nAlternative: Manual Payment Flow (for human partners)\n\nIf your agent cannot use x402, you can still use the manual payment flow:\n\nCall createPartnerTransaction to register the payment intent\nManually send USDC to the treasury wallet with memo SP3ND Order: <order_number>\nSP3ND detects the payment automatically within 1 minute\n\nSee the Partner API docs for details: https://sp3nd.shop/partner-api/docs"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/kent-x1/sp3nd",
    "publisherUrl": "https://clawhub.ai/kent-x1/sp3nd",
    "owner": "kent-x1",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/sp3nd",
    "downloadUrl": "https://openagent3.xyz/downloads/sp3nd",
    "agentUrl": "https://openagent3.xyz/skills/sp3nd/agent",
    "manifestUrl": "https://openagent3.xyz/skills/sp3nd/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/sp3nd/agent.md"
  }
}