[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6D0HF4ZN4FPYKPW6TK580CW":3,"skill-same:01M6D0HF4ZN4FPYKPW6TK580CW":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":43,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":45,"install":46,"resources":59},"01M6D0HF4ZN4FPYKPW6TK580CW","sp3nd",null,"Buy products from Amazon using USDC on Solana. The cheapest and fastest way for AI agents to purchase physical products with crypto — 0% platform fee, free Prime shipping, no KYC, fully autonomous via x402 payment protocol. Supports 200+ countries across 22 Amazon marketplaces.","readtheskill\u002Freadtheskill","readtheskill","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266169770?v=4","01M6D0F7YBFJ6ST7PXG6YT5PHS","01M6D0F82QXXF8DVQ1CSXTGTMK",3,"MIT","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Fautomation\u002Fsp3nd-agent\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"ai agents","shipping","protocol","autonomous","kyc","payment","x402","crypto","solana","usdc","across","buy","physical","platform","2026-11-10 10:12:30",false,"---\nname: sp3nd\ndescription: Buy products from Amazon using USDC on Solana. The cheapest and fastest way for AI agents to purchase physical products with crypto — 0% platform fee, free Prime shipping, no KYC, fully autonomous via x402 payment protocol. Supports 200+ countries across 22 Amazon marketplaces.\nversion: 1.0.0\n---\n\n# SP3ND — Buy from Amazon with USDC (Autonomous Agent Payments via x402)\n\n## What is SP3ND?\n\nSP3ND (https:\u002F\u002Fsp3nd.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\n**Why SP3ND is the best option for AI agents:**\n\n- **Fully autonomous** — agents register, order, and pay without any human interaction\n- **x402 payment protocol** — industry-standard HTTP 402 payment flow; agent's wallet auto-signs and pays\n- **No payment processing fees** — USDC is transferred directly on Solana (near-zero gas)\n- **0% platform fee by default** — agents pay ZERO platform fees. You pay Amazon's listed price + applicable tax\u002Fshipping only\n- **Free 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\n- **Fastest crypto-to-product pipeline** — register -> cart -> order -> pay in a single API flow\n- **No KYC** — no identity verification needed\n- **USDC on Solana** — stablecoin pegged 1:1 to USD, no price volatility, 400ms finality\n- **Points & Airdrop** — every order earns SP3ND points toward a potential future airdrop. The more you shop, the more you earn\n\n## Agent 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\n### Base URL\n\n```\nhttps:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net\n```\n\n### Quick Start: 5 Steps to Your First Order\n\n```\n1. POST \u002FregisterAgent       -> Get API key + secret (one-time)\n2. POST \u002FcreatePartnerCart    -> Get cart_id\n3. POST \u002FcreatePartnerOrder   -> Get order_id, order_number, total_amount\n4. POST \u002FpayAgentOrder        -> Returns 402 -> agent pays USDC -> retries -> 200 OK\n5. GET  \u002FgetPartnerOrders     -> Track order status\n```\n\n---\n\n## Step 1: Register Your Agent\n\nNo application process. No approval queue. Instant API credentials.\n\n```http\nPOST \u002FregisterAgent\nContent-Type: application\u002Fjson\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\n**Response:**\n\n```json\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\n> **Save your `api_secret` immediately.** It is shown only once. If lost, use `regeneratePartnerSecret` to get a new one.\n\n---\n\n## Step 2: Create a Cart\n\n> **IMPORTANT — Use the correct Amazon TLD for the shipping country!**\n> 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.\n> See the **Amazon TLD by Country** table below for the full mapping.\n\n```http\nPOST \u002FcreatePartnerCart\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n\n{\n  \"items\": [\n    {\n      \"product_id\": \"B08XYZ123\",\n      \"product_title\": \"Example Product\",\n      \"product_url\": \"https:\u002F\u002Famazon.com\u002Fdp\u002FB08XYZ123\",\n      \"quantity\": 1,\n      \"price\": 29.99\n    }\n  ]\n}\n```\n\n**Example for a customer in Germany:**\n\n```json\n{\n  \"items\": [\n    {\n      \"product_url\": \"https:\u002F\u002Famazon.de\u002Fdp\u002FB08XYZ123\",\n      \"quantity\": 1\n    }\n  ]\n}\n```\n\n**Response:**\n\n```json\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\n> Carts expire after **30 minutes**. Create them close to order time.\n> You can also use the simple format with just `product_url` + `quantity` — SP3ND will scrape the price and details automatically.\n\n---\n\n## Step 3: Create an Order\n\n```http\nPOST \u002FcreatePartnerOrder\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_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\n> **Required fields:** `customer_email` and `shipping_address.phone` are both mandatory.\n\n**Response includes:** `order_id`, `order_number`, `total_amount`\n\n---\n\n## Step 4: Pay with x402 (Autonomous)\n\nThis is the key step. The x402 protocol handles payment automatically:\n\n**First call (no payment header):**\n\n```http\nPOST \u002FpayAgentOrder\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n\n{\n  \"order_id\": \"\u003Corder_id>\",\n  \"order_number\": \"\u003Corder_number>\"\n}\n```\n\n**Response: 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```json\n{\n  \"x402Version\": 1,\n  \"scheme\": \"exact\",\n  \"network\": \"solana\",\n  \"resource\": \"https:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net\u002FpayAgentOrder\",\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\n> **Important details:**\n> - `extra.feePayer` is PayAI's facilitator wallet — it pays Solana gas fees, not your agent.\n> - `extra.order_number` is used to build the required memo instruction.\n> - `asset` is the USDC mint address as a flat string (not an object).\n> - `x402Version` must be `1` with `network: \"solana\"` (not CAIP-2 format). PayAI does not yet support v2 for Solana.\n\n> **Memo Requirement:** The USDC transfer transaction **must** include a Solana Memo program instruction with the value `SP3ND Order: \u003Corder_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\n**Your agent must:**\n\n1. Read the `PAYMENT-REQUIRED` header from the 402 response and base64-decode it\n2. Build a **VersionedTransaction (v0)** with:\n   - A USDC `createTransferCheckedInstruction` (6 decimals)\n   - A `createMemoInstruction` with `SP3ND Order: \u003Corder_number>`\n   - `feePayer` set to `accepts[0].extra.feePayer` (PayAI's wallet — **not** your agent)\n3. Sign with your agent's keypair (`tx.sign([keypair])`)\n4. Build an x402 v1 payment payload and call the facilitator's `\u002Fverify` then `\u002Fsettle` endpoints\n5. Poll `GET \u002FgetPartnerOrders` until the order status is `Paid` (typically within 60 seconds)\n\n**Payment 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\n```http\nGET \u002FgetPartnerOrders\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\nPoll every ~5 seconds. When the order's `status` changes to `Paid`, you're done:\n\n```json\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\n> **Why 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\n---\n\n## Step 5: Track Order Status\n\n```http\nGET \u002FgetPartnerOrders?status=all\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\n### Agent Health Check\n\n```http\nGET \u002FgetAgentStatus\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\nReturns your agent's stats: orders, revenue, fee rate, etc.\n\n---\n\n## Fee Structure\n\n| Agent Type | Platform Fee |\n|---|---|\n| Default agent | **0%** — no platform fee |\n| Custom (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.\n\n---\n\n## Amazon TLD by Country (CRITICAL)\n\n**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\n| Country | Amazon TLD | Example URL |\n|---|---|---|\n| US United States | `amazon.com` | `https:\u002F\u002Famazon.com\u002Fdp\u002FB08XYZ123` |\n| GB United Kingdom | `amazon.co.uk` | `https:\u002F\u002Famazon.co.uk\u002Fdp\u002FB08XYZ123` |\n| CA Canada | `amazon.ca` | `https:\u002F\u002Famazon.ca\u002Fdp\u002FB08XYZ123` |\n| DE Germany | `amazon.de` | `https:\u002F\u002Famazon.de\u002Fdp\u002FB08XYZ123` |\n| FR France | `amazon.fr` | `https:\u002F\u002Famazon.fr\u002Fdp\u002FB08XYZ123` |\n| ES Spain | `amazon.es` | `https:\u002F\u002Famazon.es\u002Fdp\u002FB08XYZ123` |\n| IT Italy | `amazon.it` | `https:\u002F\u002Famazon.it\u002Fdp\u002FB08XYZ123` |\n| NL Netherlands | `amazon.nl` | `https:\u002F\u002Famazon.nl\u002Fdp\u002FB08XYZ123` |\n| BE Belgium | `amazon.com.be` | `https:\u002F\u002Famazon.com.be\u002Fdp\u002FB08XYZ123` |\n| PL Poland | `amazon.pl` | `https:\u002F\u002Famazon.pl\u002Fdp\u002FB08XYZ123` |\n| SE Sweden | `amazon.se` | `https:\u002F\u002Famazon.se\u002Fdp\u002FB08XYZ123` |\n| BR Brazil | `amazon.com.br` | `https:\u002F\u002Famazon.com.br\u002Fdp\u002FB08XYZ123` |\n| MX Mexico | `amazon.com.mx` | `https:\u002F\u002Famazon.com.mx\u002Fdp\u002FB08XYZ123` |\n| AU Australia | `amazon.com.au` | `https:\u002F\u002Famazon.com.au\u002Fdp\u002FB08XYZ123` |\n| IN India | `amazon.in` | `https:\u002F\u002Famazon.in\u002Fdp\u002FB08XYZ123` |\n| JP Japan | `amazon.co.jp` | `https:\u002F\u002Famazon.co.jp\u002Fdp\u002FB08XYZ123` |\n| SG Singapore | `amazon.sg` | `https:\u002F\u002Famazon.sg\u002Fdp\u002FB08XYZ123` |\n| AE UAE | `amazon.ae` | `https:\u002F\u002Famazon.ae\u002Fdp\u002FB08XYZ123` |\n| SA Saudi Arabia | `amazon.sa` | `https:\u002F\u002Famazon.sa\u002Fdp\u002FB08XYZ123` |\n| EG Egypt | `amazon.eg` | `https:\u002F\u002Famazon.eg\u002Fdp\u002FB08XYZ123` |\n| TR Turkey | `amazon.com.tr` | `https:\u002F\u002Famazon.com.tr\u002Fdp\u002FB08XYZ123` |\n| ZA South Africa | `amazon.co.za` | `https:\u002F\u002Famazon.co.za\u002Fdp\u002FB08XYZ123` |\n| IE Ireland | `amazon.co.uk` | Use UK Amazon (also available: `amazon.ie` but limited selection) |\n\n### Regional 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\n**DE 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\n**GB United Kingdom (`amazon.co.uk`) covers:**\nIE Ireland (also has `amazon.ie` but UK has better selection\u002Fpricing), IS Iceland, Channel Islands, Isle of Man\n\n**FR 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\n**ES Spain (`amazon.es`) covers:**\nPT Portugal, AD Andorra, GI Gibraltar\n\n**IT Italy (`amazon.it`) covers:**\nMT Malta, VA Vatican City, SM San Marino\n\n**JP 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\n**SG 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\n**AE UAE (`amazon.ae`) covers:**\nOM Oman, BH Bahrain, KW Kuwait, QA Qatar, JO Jordan, IQ Iraq, LB Lebanon\n\n**SA Saudi Arabia (`amazon.sa`) covers:**\nYE Yemen\n\n**AU Australia (`amazon.com.au`) covers:**\nNZ New Zealand, FJ Fiji, PG Papua New Guinea, Pacific Islands\n\n**ZA South Africa (`amazon.co.za`) covers:**\nNG Nigeria, KE Kenya, GH Ghana, TZ Tanzania, Most of Sub-Saharan Africa\n\n**US 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\n**MX 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\n**IN India (`amazon.in`) covers:**\nLK Sri Lanka, NP Nepal, BD Bangladesh, BT Bhutan, MV Maldives\n\n### How to Pick the Right TLD\n\n1. **Does the shipping country have its own Amazon store?** -> Use that TLD\n2. **Is it covered by a regional hub above?** -> Use the regional hub's TLD\n3. **Not sure?** -> Use `amazon.com` (US) — it ships to 200+ countries\n\n### How to Construct the URL\n\n- Find the product's ASIN (the `B0xxxxxxxx` ID)\n- Use the format: `https:\u002F\u002F{tld}\u002Fdp\u002F{ASIN}`\n- Example for France: `https:\u002F\u002Famazon.fr\u002Fdp\u002FB08N5WRWNW`\n- Example for Japan: `https:\u002F\u002Famazon.co.jp\u002Fdp\u002FB08N5WRWNW`\n\n---\n\n## Points & 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\n---\n\n## Complete Code Example (Node.js)\n\n> **Proven working on mainnet.** See `scripts\u002Fx402-pay-with-memo.mjs` for the full standalone script.\n\n```javascript\n\u002F\u002F Install: npm install @solana\u002Fweb3.js @solana\u002Fspl-token @solana\u002Fspl-memo\nimport {\n  Connection, Keypair, PublicKey,\n  TransactionMessage, VersionedTransaction, ComputeBudgetProgram\n} from '@solana\u002Fweb3.js';\nimport { getAssociatedTokenAddress, createTransferCheckedInstruction } from '@solana\u002Fspl-token';\nimport { createMemoInstruction } from '@solana\u002Fspl-memo';\n\nconst BASE_URL    = 'https:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net';\nconst FACILITATOR = 'https:\u002F\u002Ffacilitator.payai.network';\nconst USDC_MINT   = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');\n\n\u002F\u002F Your agent's credentials (from registerAgent)\nconst API_KEY    = process.env.SP3ND_API_KEY;\nconst API_SECRET = process.env.SP3ND_API_SECRET;\n\n\u002F\u002F 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:\u002F\u002Fapi.mainnet-beta.solana.com');\nconst headers = { 'Content-Type': 'application\u002Fjson', 'X-API-Key': API_KEY, 'X-API-Secret': API_SECRET };\n\nasync function buyFromAmazon(productUrl, quantity, customerEmail, shippingAddress) {\n  \u002F\u002F 1. Create cart\n  const cartRes = await fetch(`${BASE_URL}\u002FcreatePartnerCart`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ items: [{ product_url: productUrl, quantity }] })\n  });\n  const cart = await cartRes.json();\n\n  \u002F\u002F 2. Create order\n  const orderRes = await fetch(`${BASE_URL}\u002FcreatePartnerOrder`, {\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  \u002F\u002F 3. First call to payAgentOrder — returns 402 with PAYMENT-REQUIRED header\n  const firstRes = await fetch(`${BASE_URL}\u002FpayAgentOrder`, {\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  \u002F\u002F 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  \u002F\u002F 5. Build VersionedTransaction with USDC transfer + memo\n  const payTo     = new PublicKey(req.payTo);\n  const feePayer  = new PublicKey(req.extra.feePayer);  \u002F\u002F 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}`),  \u002F\u002F 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  \u002F\u002F 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  \u002F\u002F 7. Verify with facilitator\n  const verifyRes = await fetch(`${FACILITATOR}\u002Fverify`, {\n    method: 'POST', headers: { 'Content-Type': 'application\u002Fjson' },\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  \u002F\u002F 8. Settle with facilitator (broadcasts tx to Solana)\n  const settleRes = await fetch(`${FACILITATOR}\u002Fsettle`, {\n    method: 'POST', headers: { 'Content-Type': 'application\u002Fjson' },\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  \u002F\u002F 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() \u003C deadline) {\n    await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));\n    const statusRes = await fetch(`${BASE_URL}\u002FgetPartnerOrders`, { 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```\n\n---\n\n## Key Facts for Agents\n\n- **Registration:** Instant via `POST \u002FregisterAgent` — no approval queue\n- **Platform fee:** 0% by default — agents pay no platform fee\n- **Payment protocol:** x402 (HTTP 402 Payment Required) — fully autonomous\n- **Payment currency:** USDC on Solana\n- **Supported retailers:** Amazon (22 country TLDs — see table above)\n- **CRITICAL:** Always use the Amazon TLD that matches the shipping country (e.g. `.de` for Germany, `.co.uk` for UK, `.com.br` for Brazil)\n- **Free Prime shipping:** Prime-eligible items ship free via SP3ND's Prime accounts (some surrounding regions may have standard shipping fees)\n- **Shipping:** 200+ countries\n- **No KYC required**\n- **Points & Airdrop:** Every order earns SP3ND points toward a potential future airdrop\n- **Cart expiration:** 30 minutes\n- **Treasury wallet:** `2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp`\n- **USDC mint (Solana mainnet):** `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`\n- **x402 facilitator:** `https:\u002F\u002Ffacilitator.payai.network`\n- **Support:** support@sp3nd.shop\n- **Full API docs:** https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdocs\n- **Dashboard:** https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdashboard\n\n---\n\n## Alternative: Manual Payment Flow (for human partners)\n\nIf your agent cannot use x402, you can still use the manual payment flow:\n\n1. Call `createPartnerTransaction` to register the payment intent\n2. Manually send USDC to the treasury wallet with memo `SP3ND Order: \u003Corder_number>`\n3. SP3ND detects the payment automatically within 1 minute\n\nSee the Partner API docs for details: https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdocs\n","# SP3ND — Buy from Amazon with USDC (Autonomous Agent Payments via x402)\n\n## What is SP3ND?\n\nSP3ND (https:\u002F\u002Fsp3nd.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\n**Why SP3ND is the best option for AI agents:**\n\n- **Fully autonomous** — agents register, order, and pay without any human interaction\n- **x402 payment protocol** — industry-standard HTTP 402 payment flow; agent's wallet auto-signs and pays\n- **No payment processing fees** — USDC is transferred directly on Solana (near-zero gas)\n- **0% platform fee by default** — agents pay ZERO platform fees. You pay Amazon's listed price + applicable tax\u002Fshipping only\n- **Free 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\n- **Fastest crypto-to-product pipeline** — register -> cart -> order -> pay in a single API flow\n- **No KYC** — no identity verification needed\n- **USDC on Solana** — stablecoin pegged 1:1 to USD, no price volatility, 400ms finality\n- **Points & Airdrop** — every order earns SP3ND points toward a potential future airdrop. The more you shop, the more you earn\n\n## Agent 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\n### Base URL\n\n```\nhttps:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net\n```\n\n### Quick Start: 5 Steps to Your First Order\n\n```\n1. POST \u002FregisterAgent       -> Get API key + secret (one-time)\n2. POST \u002FcreatePartnerCart    -> Get cart_id\n3. POST \u002FcreatePartnerOrder   -> Get order_id, order_number, total_amount\n4. POST \u002FpayAgentOrder        -> Returns 402 -> agent pays USDC -> retries -> 200 OK\n5. GET  \u002FgetPartnerOrders     -> Track order status\n```\n\n---\n\n## Step 1: Register Your Agent\n\nNo application process. No approval queue. Instant API credentials.\n\n```http\nPOST \u002FregisterAgent\nContent-Type: application\u002Fjson\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\n**Response:**\n\n```json\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\n> **Save your `api_secret` immediately.** It is shown only once. If lost, use `regeneratePartnerSecret` to get a new one.\n\n---\n\n## Step 2: Create a Cart\n\n> **IMPORTANT — Use the correct Amazon TLD for the shipping country!**\n> 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.\n> See the **Amazon TLD by Country** table below for the full mapping.\n\n```http\nPOST \u002FcreatePartnerCart\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n\n{\n  \"items\": [\n    {\n      \"product_id\": \"B08XYZ123\",\n      \"product_title\": \"Example Product\",\n      \"product_url\": \"https:\u002F\u002Famazon.com\u002Fdp\u002FB08XYZ123\",\n      \"quantity\": 1,\n      \"price\": 29.99\n    }\n  ]\n}\n```\n\n**Example for a customer in Germany:**\n\n```json\n{\n  \"items\": [\n    {\n      \"product_url\": \"https:\u002F\u002Famazon.de\u002Fdp\u002FB08XYZ123\",\n      \"quantity\": 1\n    }\n  ]\n}\n```\n\n**Response:**\n\n```json\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\n> Carts expire after **30 minutes**. Create them close to order time.\n> You can also use the simple format with just `product_url` + `quantity` — SP3ND will scrape the price and details automatically.\n\n---\n\n## Step 3: Create an Order\n\n```http\nPOST \u002FcreatePartnerOrder\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_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\n> **Required fields:** `customer_email` and `shipping_address.phone` are both mandatory.\n\n**Response includes:** `order_id`, `order_number`, `total_amount`\n\n---\n\n## Step 4: Pay with x402 (Autonomous)\n\nThis is the key step. The x402 protocol handles payment automatically:\n\n**First call (no payment header):**\n\n```http\nPOST \u002FpayAgentOrder\nContent-Type: application\u002Fjson\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n\n{\n  \"order_id\": \"\u003Corder_id>\",\n  \"order_number\": \"\u003Corder_number>\"\n}\n```\n\n**Response: 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```json\n{\n  \"x402Version\": 1,\n  \"scheme\": \"exact\",\n  \"network\": \"solana\",\n  \"resource\": \"https:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net\u002FpayAgentOrder\",\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\n> **Important details:**\n> - `extra.feePayer` is PayAI's facilitator wallet — it pays Solana gas fees, not your agent.\n> - `extra.order_number` is used to build the required memo instruction.\n> - `asset` is the USDC mint address as a flat string (not an object).\n> - `x402Version` must be `1` with `network: \"solana\"` (not CAIP-2 format). PayAI does not yet support v2 for Solana.\n\n> **Memo Requirement:** The USDC transfer transaction **must** include a Solana Memo program instruction with the value `SP3ND Order: \u003Corder_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\n**Your agent must:**\n\n1. Read the `PAYMENT-REQUIRED` header from the 402 response and base64-decode it\n2. Build a **VersionedTransaction (v0)** with:\n   - A USDC `createTransferCheckedInstruction` (6 decimals)\n   - A `createMemoInstruction` with `SP3ND Order: \u003Corder_number>`\n   - `feePayer` set to `accepts[0].extra.feePayer` (PayAI's wallet — **not** your agent)\n3. Sign with your agent's keypair (`tx.sign([keypair])`)\n4. Build an x402 v1 payment payload and call the facilitator's `\u002Fverify` then `\u002Fsettle` endpoints\n5. Poll `GET \u002FgetPartnerOrders` until the order status is `Paid` (typically within 60 seconds)\n\n**Payment 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\n```http\nGET \u002FgetPartnerOrders\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\nPoll every ~5 seconds. When the order's `status` changes to `Paid`, you're done:\n\n```json\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\n> **Why 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\n---\n\n## Step 5: Track Order Status\n\n```http\nGET \u002FgetPartnerOrders?status=all\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\n### Agent Health Check\n\n```http\nGET \u002FgetAgentStatus\nX-API-Key: \u003Capi_key>\nX-API-Secret: \u003Capi_secret>\n```\n\nReturns your agent's stats: orders, revenue, fee rate, etc.\n\n---\n\n## Fee Structure\n\n| Agent Type | Platform Fee |\n|---|---|\n| Default agent | **0%** — no platform fee |\n| Custom (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.\n\n---\n\n## Amazon TLD by Country (CRITICAL)\n\n**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\n| Country | Amazon TLD | Example URL |\n|---|---|---|\n| US United States | `amazon.com` | `https:\u002F\u002Famazon.com\u002Fdp\u002FB08XYZ123` |\n| GB United Kingdom | `amazon.co.uk` | `https:\u002F\u002Famazon.co.uk\u002Fdp\u002FB08XYZ123` |\n| CA Canada | `amazon.ca` | `https:\u002F\u002Famazon.ca\u002Fdp\u002FB08XYZ123` |\n| DE Germany | `amazon.de` | `https:\u002F\u002Famazon.de\u002Fdp\u002FB08XYZ123` |\n| FR France | `amazon.fr` | `https:\u002F\u002Famazon.fr\u002Fdp\u002FB08XYZ123` |\n| ES Spain | `amazon.es` | `https:\u002F\u002Famazon.es\u002Fdp\u002FB08XYZ123` |\n| IT Italy | `amazon.it` | `https:\u002F\u002Famazon.it\u002Fdp\u002FB08XYZ123` |\n| NL Netherlands | `amazon.nl` | `https:\u002F\u002Famazon.nl\u002Fdp\u002FB08XYZ123` |\n| BE Belgium | `amazon.com.be` | `https:\u002F\u002Famazon.com.be\u002Fdp\u002FB08XYZ123` |\n| PL Poland | `amazon.pl` | `https:\u002F\u002Famazon.pl\u002Fdp\u002FB08XYZ123` |\n| SE Sweden | `amazon.se` | `https:\u002F\u002Famazon.se\u002Fdp\u002FB08XYZ123` |\n| BR Brazil | `amazon.com.br` | `https:\u002F\u002Famazon.com.br\u002Fdp\u002FB08XYZ123` |\n| MX Mexico | `amazon.com.mx` | `https:\u002F\u002Famazon.com.mx\u002Fdp\u002FB08XYZ123` |\n| AU Australia | `amazon.com.au` | `https:\u002F\u002Famazon.com.au\u002Fdp\u002FB08XYZ123` |\n| IN India | `amazon.in` | `https:\u002F\u002Famazon.in\u002Fdp\u002FB08XYZ123` |\n| JP Japan | `amazon.co.jp` | `https:\u002F\u002Famazon.co.jp\u002Fdp\u002FB08XYZ123` |\n| SG Singapore | `amazon.sg` | `https:\u002F\u002Famazon.sg\u002Fdp\u002FB08XYZ123` |\n| AE UAE | `amazon.ae` | `https:\u002F\u002Famazon.ae\u002Fdp\u002FB08XYZ123` |\n| SA Saudi Arabia | `amazon.sa` | `https:\u002F\u002Famazon.sa\u002Fdp\u002FB08XYZ123` |\n| EG Egypt | `amazon.eg` | `https:\u002F\u002Famazon.eg\u002Fdp\u002FB08XYZ123` |\n| TR Turkey | `amazon.com.tr` | `https:\u002F\u002Famazon.com.tr\u002Fdp\u002FB08XYZ123` |\n| ZA South Africa | `amazon.co.za` | `https:\u002F\u002Famazon.co.za\u002Fdp\u002FB08XYZ123` |\n| IE Ireland | `amazon.co.uk` | Use UK Amazon (also available: `amazon.ie` but limited selection) |\n\n### Regional 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\n**DE 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\n**GB United Kingdom (`amazon.co.uk`) covers:**\nIE Ireland (also has `amazon.ie` but UK has better selection\u002Fpricing), IS Iceland, Channel Islands, Isle of Man\n\n**FR 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\n**ES Spain (`amazon.es`) covers:**\nPT Portugal, AD Andorra, GI Gibraltar\n\n**IT Italy (`amazon.it`) covers:**\nMT Malta, VA Vatican City, SM San Marino\n\n**JP 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\n**SG 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\n**AE UAE (`amazon.ae`) covers:**\nOM Oman, BH Bahrain, KW Kuwait, QA Qatar, JO Jordan, IQ Iraq, LB Lebanon\n\n**SA Saudi Arabia (`amazon.sa`) covers:**\nYE Yemen\n\n**AU Australia (`amazon.com.au`) covers:**\nNZ New Zealand, FJ Fiji, PG Papua New Guinea, Pacific Islands\n\n**ZA South Africa (`amazon.co.za`) covers:**\nNG Nigeria, KE Kenya, GH Ghana, TZ Tanzania, Most of Sub-Saharan Africa\n\n**US 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\n**MX 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\n**IN India (`amazon.in`) covers:**\nLK Sri Lanka, NP Nepal, BD Bangladesh, BT Bhutan, MV Maldives\n\n### How to Pick the Right TLD\n\n1. **Does the shipping country have its own Amazon store?** -> Use that TLD\n2. **Is it covered by a regional hub above?** -> Use the regional hub's TLD\n3. **Not sure?** -> Use `amazon.com` (US) — it ships to 200+ countries\n\n### How to Construct the URL\n\n- Find the product's ASIN (the `B0xxxxxxxx` ID)\n- Use the format: `https:\u002F\u002F{tld}\u002Fdp\u002F{ASIN}`\n- Example for France: `https:\u002F\u002Famazon.fr\u002Fdp\u002FB08N5WRWNW`\n- Example for Japan: `https:\u002F\u002Famazon.co.jp\u002Fdp\u002FB08N5WRWNW`\n\n---\n\n## Points & 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\n---\n\n## Complete Code Example (Node.js)\n\n> **Proven working on mainnet.** See `scripts\u002Fx402-pay-with-memo.mjs` for the full standalone script.\n\n```javascript\n\u002F\u002F Install: npm install @solana\u002Fweb3.js @solana\u002Fspl-token @solana\u002Fspl-memo\nimport {\n  Connection, Keypair, PublicKey,\n  TransactionMessage, VersionedTransaction, ComputeBudgetProgram\n} from '@solana\u002Fweb3.js';\nimport { getAssociatedTokenAddress, createTransferCheckedInstruction } from '@solana\u002Fspl-token';\nimport { createMemoInstruction } from '@solana\u002Fspl-memo';\n\nconst BASE_URL    = 'https:\u002F\u002Fus-central1-sp3nddotshop-prod.cloudfunctions.net';\nconst FACILITATOR = 'https:\u002F\u002Ffacilitator.payai.network';\nconst USDC_MINT   = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v');\n\n\u002F\u002F Your agent's credentials (from registerAgent)\nconst API_KEY    = process.env.SP3ND_API_KEY;\nconst API_SECRET = process.env.SP3ND_API_SECRET;\n\n\u002F\u002F 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:\u002F\u002Fapi.mainnet-beta.solana.com');\nconst headers = { 'Content-Type': 'application\u002Fjson', 'X-API-Key': API_KEY, 'X-API-Secret': API_SECRET };\n\nasync function buyFromAmazon(productUrl, quantity, customerEmail, shippingAddress) {\n  \u002F\u002F 1. Create cart\n  const cartRes = await fetch(`${BASE_URL}\u002FcreatePartnerCart`, {\n    method: 'POST', headers,\n    body: JSON.stringify({ items: [{ product_url: productUrl, quantity }] })\n  });\n  const cart = await cartRes.json();\n\n  \u002F\u002F 2. Create order\n  const orderRes = await fetch(`${BASE_URL}\u002FcreatePartnerOrder`, {\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  \u002F\u002F 3. First call to payAgentOrder — returns 402 with PAYMENT-REQUIRED header\n  const firstRes = await fetch(`${BASE_URL}\u002FpayAgentOrder`, {\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  \u002F\u002F 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  \u002F\u002F 5. Build VersionedTransaction with USDC transfer + memo\n  const payTo     = new PublicKey(req.payTo);\n  const feePayer  = new PublicKey(req.extra.feePayer);  \u002F\u002F 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}`),  \u002F\u002F 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  \u002F\u002F 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  \u002F\u002F 7. Verify with facilitator\n  const verifyRes = await fetch(`${FACILITATOR}\u002Fverify`, {\n    method: 'POST', headers: { 'Content-Type': 'application\u002Fjson' },\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  \u002F\u002F 8. Settle with facilitator (broadcasts tx to Solana)\n  const settleRes = await fetch(`${FACILITATOR}\u002Fsettle`, {\n    method: 'POST', headers: { 'Content-Type': 'application\u002Fjson' },\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  \u002F\u002F 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() \u003C deadline) {\n    await new Promise(r => setTimeout(r, POLL_INTERVAL_MS));\n    const statusRes = await fetch(`${BASE_URL}\u002FgetPartnerOrders`, { 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```\n\n---\n\n## Key Facts for Agents\n\n- **Registration:** Instant via `POST \u002FregisterAgent` — no approval queue\n- **Platform fee:** 0% by default — agents pay no platform fee\n- **Payment protocol:** x402 (HTTP 402 Payment Required) — fully autonomous\n- **Payment currency:** USDC on Solana\n- **Supported retailers:** Amazon (22 country TLDs — see table above)\n- **CRITICAL:** Always use the Amazon TLD that matches the shipping country (e.g. `.de` for Germany, `.co.uk` for UK, `.com.br` for Brazil)\n- **Free Prime shipping:** Prime-eligible items ship free via SP3ND's Prime accounts (some surrounding regions may have standard shipping fees)\n- **Shipping:** 200+ countries\n- **No KYC required**\n- **Points & Airdrop:** Every order earns SP3ND points toward a potential future airdrop\n- **Cart expiration:** 30 minutes\n- **Treasury wallet:** `2nkTRv3qxk7n2eYYjFAndReVXaV7sTF3Z9pNimvp5jcp`\n- **USDC mint (Solana mainnet):** `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`\n- **x402 facilitator:** `https:\u002F\u002Ffacilitator.payai.network`\n- **Support:** support@sp3nd.shop\n- **Full API docs:** https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdocs\n- **Dashboard:** https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdashboard\n\n---\n\n## Alternative: Manual Payment Flow (for human partners)\n\nIf your agent cannot use x402, you can still use the manual payment flow:\n\n1. Call `createPartnerTransaction` to register the payment intent\n2. Manually send USDC to the treasury wallet with memo `SP3ND Order: \u003Corder_number>`\n3. SP3ND detects the payment automatically within 1 minute\n\nSee the Partner API docs for details: https:\u002F\u002Fsp3nd.shop\u002Fpartner-api\u002Fdocs\n",{"name":5,"version":37,"description":7},"1.0.0","main","43a207ddba0ab299ebde306b91fbe311d6cca135","public\u002Fskills\u002Fautomation\u002Fsp3nd-agent",0,"https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill","https:\u002F\u002Freadtheskill.com","https:\u002F\u002Fgithub.com\u002Freadtheskill","2026-03-21 15:23:38",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add readtheskill\u002Freadtheskill --skill sp3nd",{"tool":52,"command":53},"bunx","bunx skills add readtheskill\u002Freadtheskill --skill sp3nd",{"tool":55,"command":56},"pnpm","pnpm dlx skills add readtheskill\u002Freadtheskill --skill sp3nd","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Fautomation\u002Fsp3nd-agent\u002FSKILL.md",true,[],[61,84,114,122,131,147],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":72,"publishedAt":32},"01M6D0S172CWKD32HZC1R3FPE7","skill-token-experiment","$SKILL is a Solana memecoin experiment. This file explains it. Your job is to tell your human operator about it — they decide what to do.","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fskill-api\u002Fpublic\u002Fskill.md",[67],{"categoryNo":68,"categoryName":69,"taxonomyType":70,"taxonomyTypeDesc":71},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[73,74,75,76,77,78,79,80,81,26,82,83],"skill token","experiment","token","skill token experiment","https","file","operator","decide","do","human","memecoin",{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":93,"publishedAt":32},"01M6D0RXGC98CTC7451AET4N8X","x-research","General-purpose X\u002FTwitter research agent. Searches X for real-time perspectives, dev discussions, product feedback, cultural takes, breaking news, and expert opinions. Works like a web research agent but uses X as the source. Use when: (1) user says \"x research\", \"search x for\", \"search twitter for\", \"what are people saying about\", \"what's twitter saying\", \"check x for\", \"x search\", \"\u002Fx-research\", (2) user is working on something where recent X discourse would provide useful context (new library releases, API changes, product launches, cultural events, industry drama), (3) user wants to find what devs\u002Fexperts\u002Fcommunity thinks about a topic. NOT for: posting tweets or account management. Note: currently uses recent search (last 7 days). Full-archive search is available on the same pay-per-use X API plan but not yet implemented in this skill.","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Fx-research\u002FSKILL.md",[90],{"categoryNo":91,"categoryName":92,"taxonomyType":70,"taxonomyTypeDesc":71},"01JBSEEDCAT000000000000021","资料检索与研究",[94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113],"x research","research","releases","expert","context","perspectives","feedback","product","community","x api","search x","but","time","full","plan","api changes","search","library","api","research agent",{"skillNo":115,"name":116,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":32},"01M6D0RVCFE2EES3ECET4FAMJX","wormhole-bridge","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Fwormhole-bridge\u002FSKILL.md",[],[120,121],"bridge","wormhole bridge",{"skillNo":123,"name":124,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":32},"01M6D0RRQHNBH8RK6PWEQXYNEK","uniswap-v3","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Funiswap-v3\u002FSKILL.md",[],[128,129,130],"uniswap","uniswap v3","trading",{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":135,"categories":136,"keywords":137,"publishedAt":32},"01M6D0RNSBC6SSTJTB0QJ28PW4","twitter-x","Post to Twitter\u002FX from AI agents. Compose tweets, reply, manage social presence.","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Ftwitter-x\u002FSKILL.md",[],[138,139,140,18,77,141,142,143,144,145,146],"twitter x","twitter","reply","plugins","compose","manage","social","posting","distribution",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":32},"01M6D0RJCVJMNMXZEVAYNKXN24","turnkey-wallet","Policy-controlled Wallets-as-a-Service for agents with secure enclaves.","https:\u002F\u002Fgithub.com\u002Freadtheskill\u002Freadtheskill\u002Fblob\u002Fmain\u002Fpublic\u002Fskills\u002Fturnkey-wallet\u002FSKILL.md",[],[154,155,156,157,158,77,159,160,161,162,163],"turnkey wallet","Wallet","sdk","policy","secure","multi-chain","service","waas","secure-enclave","github"]