{
  "schemaVersion": "1.0",
  "item": {
    "slug": "iautopay",
    "name": "iautopay",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/newblock/iautopay",
    "canonicalUrl": "https://clawhub.ai/newblock/iautopay",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/iautopay",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=iautopay",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "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. 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. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-07T17:22:31.273Z",
      "expiresAt": "2026-05-14T17:22:31.273Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=afrexai-annual-report",
        "contentDisposition": "attachment; filename=\"afrexai-annual-report-1.0.0.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/iautopay"
    },
    "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/iautopay",
    "agentPageUrl": "https://openagent3.xyz/skills/iautopay/agent",
    "manifestUrl": "https://openagent3.xyz/skills/iautopay/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/iautopay/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. 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. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "iAutoPay Fact API",
        "body": "Base URLs:\n\nfact-api: https://apipaymcp.okart.fun (Payment API)\nnapi-ser: http://ipaynapi.gpuart.cn (User Management & API Keys)"
      },
      {
        "title": "Network Configuration",
        "body": "Chain: Base Sepolia (Testnet)\nChain ID: eip155:84532\nAsset: 0x036CbD53842c5426634e7929541eC2318f3dCF7e (USDC)\nPayee: 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c"
      },
      {
        "title": "Pricing",
        "body": "DurationPrice (USDC)1 day0.097 days0.4930 days0.99"
      },
      {
        "title": "GET /info - Server Information",
        "body": "Get current server status, pricing, and configuration.\n\ncurl \"https://apipaymcp.okart.fun/info\"\n\nResponse:\n\n{\n  \"name\": \"iAutoPay Fact API\",\n  \"version\": \"0.1.0\",\n  \"environment\": \"dev\",\n  \"network\": \"eip155:84532\",\n  \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n  \"prices\": {\n    \"1day\": \"90000\",\n    \"1dayUsdc\": 0.09,\n    \"7days\": \"490000\",\n    \"7daysUsdc\": 0.49,\n    \"30days\": \"990000\",\n    \"30daysUsdc\": 0.99\n  },\n  \"payee\": \"0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\",\n  \"bypassPayment\": false,\n  \"paymentScheme\": \"exact\"\n}"
      },
      {
        "title": "POST /v1/buy-apikey - Purchase API Key",
        "body": "Buy an API key with specified duration. Payment is handled via EIP-3009 signed payment in the request header.\n\ncurl -X POST \"https://apipaymcp.okart.fun/v1/buy-apikey\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"PAYMENT-SIGNATURE: '{\\\"from\\\":\\\"0x...\\\",\\\"to\\\":\\\"0x...\\\",\\\"value\\\":\\\"90000\\\",\\\"validAfter\\\":\\\"0\\\",\\\"validBefore\\\":\\\"1738368000\\\",\\\"nonce\\\":\\\"0x...\\\",\\\"v\\\":27,\\\"r\\\":\\\"0x...\\\",\\\"s\\\":\\\"0x...\\\"}'\" \\\n  -d '{\"duration\": 7}'\n\nRequest Body:\n\n{\n  \"duration\": 7\n}\n\nHeaders:\n\nHeaderTypeRequiredDescriptionContent-TypestringYes\"application/json\"PAYMENT-SIGNATUREstringYesEIP-3009 signed payment payload (JSON string)\n\nPAYMENT-SIGNATURE Payload:\n\n{\n  \"from\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"to\": \"0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\",\n  \"value\": \"490000\",\n  \"validAfter\": \"0\",\n  \"validBefore\": \"1738368000\",\n  \"nonce\": \"0xabc123...\",\n  \"v\": 27,\n  \"r\": \"0x...\",\n  \"s\": \"0x...\"\n}\n\nDuration Options:\n\nValueDurationPrice11 day0.09 USDC77 days0.49 USDC3030 days0.99 USDC\n\nResponse:\n\n{\n  \"apiKey\": \"sk-7ac3d7c8fed74b0a8ae8f949e017e9f5\",\n  \"txHash\": \"0x1f62f45e5ae6e8cd637048d0f099d324f749f61d35906ffe481e36e92689769b\",\n  \"payState\": \"paid\",\n  \"durationDays\": 7,\n  \"transactionId\": \"ed66d250-7353-473d-bc73-0bd7541f40c0\"\n}\n\nResponse Fields:\n\nFieldTypeDescriptionapiKeystringYour API key (use this for authentication)txHashstringBlockchain transaction hashpayStatestringPayment status (\"paid\")durationDaysnumberAPI key duration in daystransactionIdstringUnique transaction ID"
      },
      {
        "title": "POST /v1/transfer - Pay Stablecoin",
        "body": "Pay USDC to any address using EIP-3009 off-chain signature."
      },
      {
        "title": "GET /user/me - Get User Information",
        "body": "Get your user account information, API keys, and usage statistics. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\nNote: The first purchase automatically creates your user account. No separate registration is required!"
      },
      {
        "title": "GET /user/my-keys - List User API Keys",
        "body": "Get all API keys for your user account. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}"
      },
      {
        "title": "POST /v1/transfer - Pay Stablecoin",
        "body": "Pay USDC to any address using EIP-3009 off-chain signature.\n\ncurl -X POST \"https://apipaymcp.okart.fun/v1/transfer\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"PAYMENT-SIGNATURE: '{\\\"from\\\":\\\"0x...\\\",\\\"to\\\":\\\"0x...\\\",\\\"value\\\":\\\"10000\\\",\\\"validAfter\\\":\\\"0\\\",\\\"validBefore\\\":\\\"1738368000\\\",\\\"nonce\\\":\\\"0x...\\\",\\\"v\\\":27,\\\"r\\\":\\\"0x...\\\",\\\"s\\\":\\\"0x...\\\"}'\" \\\n  -d '{\"to\": \"0x1234567890abcdef1234567890abcdef12345678\", \"amount\": \"10000\", \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"}'\n\nRequest Body:\n\n{\n  \"to\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"amount\": \"10000\",\n  \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n}\n\nParameters:\n\nParameterTypeRequiredDescriptiontostringYesRecipient wallet addressamountstringYesAmount in smallest unit (10000 = 0.01 USDC)assetstringYesToken contract address (USDC on Base Sepolia)\n\nHeaders:\n\nHeaderTypeRequiredDescriptionContent-TypestringYes\"application/json\"PAYMENT-SIGNATUREstringYesEIP-3009 signed payment payload (JSON string)\n\nResponse:\n\n{\n  \"success\": true,\n  \"transactionHash\": \"0x1234567890abcdef...\",\n  \"from\": \"0xabcdef1234567890abcdef1234567890abcdef12\",\n  \"to\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"amount\": \"0.010000\",\n  \"deductedAmount\": \"0.010000 USDC\",\n  \"currentBalance\": \"9.990000 USDC\"\n}"
      },
      {
        "title": "User Management (New Feature)",
        "body": "The iAutoPay system now includes automatic user registration. When you purchase an API key for the first time, a user account is automatically created and linked to your wallet address."
      },
      {
        "title": "Auto-Registration Flow",
        "body": "First Purchase: Call /v1/buy-apikey with your signed payment\nAuto-Create User: System automatically creates user account\nAPI Key Assigned: API key is linked to your user account\nUser Info Available: Use /user/me to view account details\n\nNo separate registration step is required!"
      },
      {
        "title": "User Endpoints",
        "body": "GET /user/me - Get User Information\n\nGet your user account information, API keys, and usage statistics.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\nGET /user/my-keys - List User API Keys\n\nGet all API keys for your user account.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}"
      },
      {
        "title": "GET /refresh_pricing - Refresh Pricing",
        "body": "Refresh pricing information from server (cached).\n\ncurl \"https://apipaymcp.okart.fun/refresh_pricing\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"prices\": {\n    \"1day\": \"90000\",\n    \"1dayUsdc\": 0.09,\n    \"7days\": \"490000\",\n    \"7daysUsdc\": 0.49,\n    \"30days\": \"990000\",\n    \"30daysUsdc\": 0.99\n  },\n  \"updatedAt\": \"2026-02-25T12:00:00Z\"\n}"
      },
      {
        "title": "GET /user/me - Get User Information",
        "body": "Get your user account information, API keys, and usage statistics. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\nNote: The first purchase automatically creates your user account. No separate registration is required!"
      },
      {
        "title": "GET /user/my-keys - List User API Keys",
        "body": "Get all API keys for your user account. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}"
      },
      {
        "title": "Payment Flow",
        "body": "The Fact API uses EIP-3009 (Transfer With Authorization) for off-chain payment signing. This means you don't need to send an on-chain transaction first - you sign a payment authorization and include it in the API request.\n\nSteps:\n\nGet Payment Info: Call /info to get the payee address and USDC contract address\nSign Payment: Create an EIP-3009 signature using your wallet's private key\nBuy API Key: Call /v1/buy-apikey with signed payment in the PAYMENT-SIGNATURE header\nAuto-Registration: The first purchase automatically creates your user account\nGet User Info: Use /user/me endpoint with your API key to check account details\n\nImportant: Auto-Registration\n\nNo separate registration step required\nFirst purchase automatically creates user account\nUser account is linked to your wallet address\nAll future purchases are associated with the same user account\n\nUser Management Endpoints (napi-ser):\n\nGET /user/me - Get user information, API keys, and statistics\nGET /user/my-keys - List all API keys for your account\n\nEIP-3009 Signature Requirements:\n\nDomain: Token name, version (2 for USDC), chainId, verifyingContract (USDC address)\nType: TransferWithAuthorization(from, to, value, validAfter, validBefore, nonce)\nValid Before: Current timestamp + 8 hours (28800 seconds)\n\nUSDC Contract: 0x036CbD53842c5426634e7929541eC2318f3dCF7e (Base Sepolia)\nPayee: 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c"
      },
      {
        "title": "CLI Scripts",
        "body": "This skill includes ready-to-use CLI scripts for all endpoints.\n\nDependencies:\n\n# TypeScript/Bun\nbun add viem dotenv\n\n# Python\npip install web3 requests python-dotenv"
      },
      {
        "title": "Get Server Info",
        "body": "# Python\npython scripts/info.py\n\n# TypeScript/Bun\nbun run scripts/info.ts"
      },
      {
        "title": "Get Wallet Address",
        "body": "# Python\npython scripts/get_address.py\n\n# TypeScript/Bun\nbun run scripts/get_address.ts"
      },
      {
        "title": "Buy API Key",
        "body": "# Python\npython scripts/buy_apikey.py --duration 7\n\n# TypeScript/Bun\nbun run scripts/buy_apikey.ts --duration 7"
      },
      {
        "title": "Refresh Pricing",
        "body": "# Python\npython scripts/refresh_pricing.py\n\n# TypeScript/Bun\nbun run scripts/refresh_pricing.ts"
      },
      {
        "title": "info.py",
        "body": "import requests\n\ndef get_info():\n    response = requests.get(\"https://apipaymcp.okart.fun/info\")\n    return response.json()\n\nif __name__ == \"__main__\":\n    info = get_info()\n    print(f\"Environment: {info['environment']}\")\n    print(f\"Network: {info['network']}\")\n    print(f\"Payee: {info['payee']}\")\n    print(f\"Asset: {info['asset']}\")\n    print(f\"Pricing:\")\n    for key, value in info['prices'].items():\n        print(f\"  {key}: {value}\")"
      },
      {
        "title": "get_address.py",
        "body": "from web3 import Web3\nimport os\n\ndef get_address(private_key: str = None):\n    if private_key is None:\n        private_key = os.environ.get('AUTOPAY_PKEY')\n        if not private_key:\n            raise ValueError(\"AUTOPAY_PKEY environment variable not set\")\n    \n    w3 = Web3()\n    account = w3.eth.account.from_key(private_key)\n    return account.address\n\nif __name__ == \"__main__\":\n    address = get_address()\n    print(f\"Your Wallet Address: {address}\")"
      },
      {
        "title": "buy_apikey.py",
        "body": "import requests\nfrom web3 import Web3\nimport json\nimport time\nimport os\n\ndef buy_apikey(duration: int, private_key: str = None):\n    if private_key is None:\n        private_key = os.environ.get('AUTOPAY_PKEY')\n        if not private_key:\n            raise ValueError(\"AUTOPAY_PKEY environment variable not set\")\n    \n    w3 = Web3(Web3.HTTPProvider(\"https://sepolia.base.org\"))\n    account = w3.eth.account.from_key(private_key)\n    \n    # Step 1: Get payment quote\n    info_response = requests.get(\"https://apipaymcp.okart.fun/info\")\n    info = info_response.json()\n    \n    payee_address = info['payee']\n    usdc_address = info['asset']\n    price_in_usdc = info['prices'][f'{duration}daysUsdc']\n    \n    # USDC uses 6 decimals\n    amount = int(price_in_usdc * 10 ** 6)\n    \n    # Step 2: Create EIP-3009 signature\n    # For Base Sepolia USDC: name=\"USDC\", version=\"2\"\n    domain = {\n        \"name\": \"USDC\",\n        \"version\": \"2\",\n        \"chainId\": 84532,\n        \"verifyingContract\": usdc_address\n    }\n    \n    message_types = {\n        \"TransferWithAuthorization\": [\n            {\"name\": \"from\", \"type\": \"address\"},\n            {\"name\": \"to\", \"type\": \"address\"},\n            {\"name\": \"value\", \"type\": \"uint256\"},\n            {\"name\": \"validAfter\", \"type\": \"uint256\"},\n            {\"name\": \"validBefore\", \"type\": \"uint256\"},\n            {\"name\": \"nonce\", \"type\": \"bytes32\"}\n        ]\n    }\n    \n    nonce = os.urandom(32).hex()\n    now = int(time.time())\n    valid_after = 0\n    valid_before = now + 28800  # 8 hours\n    \n    message = {\n        \"from\": account.address,\n        \"to\": payee_address,\n        \"value\": amount,\n        \"validAfter\": valid_after,\n        \"validBefore\": valid_before,\n        \"nonce\": f\"0x{nonce}\"\n    }\n    \n    # Sign typed data\n    signed_message = w3.eth.account.sign_typed_data(\n        private_key=private_key,\n        domain=domain,\n        message_types=message_types,\n        message=message\n    )\n    \n    signature_payload = {\n        \"from\": account.address,\n        \"to\": payee_address,\n        \"value\": str(amount),\n        \"validAfter\": str(valid_after),\n        \"validBefore\": str(valid_before),\n        \"nonce\": f\"0x{nonce}\",\n        \"v\": signed_message.v,\n        \"r\": signed_message.r.hex(),\n        \"s\": signed_message.s.hex()\n    }\n    \n    # Step 3: Call buy-apikey with EIP-3009 signature\n    buy_response = requests.post(\n        \"https://apipaymcp.okart.fun/v1/buy-apikey\",\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"PAYMENT-SIGNATURE\": json.dumps(signature_payload)\n        },\n        json={\"duration\": duration}\n    )\n    \n    if buy_response.status_code != 200:\n        raise Exception(f\"Buy API key failed: {buy_response.text}\")\n    \n    return {\n        \"apiKey\": buy_response.json()['apiKey'],\n        \"txHash\": buy_response.json()['txHash'],\n        \"payState\": buy_response.json()['payState'],\n        \"durationDays\": buy_response.json()['durationDays'],\n        \"transactionId\": buy_response.json()['transactionId']\n    }\n\nif __name__ == \"__main__\":\n    import argparse\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--duration\", type=int, choices=[1, 7, 30], required=True)\n    args = parser.parse_args()\n    \n    result = buy_apikey(args.duration)\n    print(json.dumps(result, indent=2))"
      },
      {
        "title": "refresh_pricing.py",
        "body": "import requests\n\ndef refresh_pricing():\n    response = requests.get(\"https://apipaymcp.okart.fun/refresh_pricing\")\n    return response.json()\n\nif __name__ == \"__main__\":\n    pricing = refresh_pricing()\n    print(f\"Pricing updated at: {pricing.get('updatedAt', 'N/A')}\")\n    if 'prices' in pricing:\n        print(f\"1 day: ${pricing['prices']['1dayUsdc']} USDC\")\n        print(f\"7 days: ${pricing['prices']['7daysUsdc']} USDC\")\n        print(f\"30 days: ${pricing['prices']['30daysUsdc']} USDC\")"
      },
      {
        "title": "info.ts",
        "body": "async function getInfo() {\n  const response = await fetch(\"https://apipaymcp.okart.fun/info\");\n  return response.json();\n}\n\nconst info = await getInfo();\nconsole.log(`Environment: ${info.environment}`);\nconsole.log(`Network: ${info.network}`);\nconsole.log(`Payee: ${info.payee}`);\nconsole.log(`Asset: ${info.asset}`);\nconsole.log(\"Pricing:\");\nObject.entries(info.prices).forEach(([key, value]) => {\n  console.log(`  ${key}: ${value}`);\n});"
      },
      {
        "title": "get_address.ts",
        "body": "import { privateKeyToAccount } from \"viem/accounts\";\n\nfunction getAddress(privateKey?: `0x${string}`): string {\n  const key = privateKey || (process.env.AUTOPAY_PKEY as `0x${string}`);\n  if (!key) {\n    throw new Error(\"AUTOPAY_PKEY environment variable not set\");\n  }\n  \n  const account = privateKeyToAccount(key);\n  return account.address;\n}\n\nconst address = getAddress();\nconsole.log(`Your Wallet Address: ${address}`);"
      },
      {
        "title": "buy_apikey.ts",
        "body": "import { createWalletClient, http, parseUnits } from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport crypto from \"crypto\";\n\nconst transferWithAuthorizationTypes = {\n  TransferWithAuthorization: [\n    { name: \"from\", type: \"address\" },\n    { name: \"to\", type: \"address\" },\n    { name: \"value\", type: \"uint256\" },\n    { name: \"validAfter\", type: \"uint256\" },\n    { name: \"validBefore\", type: \"uint256\" },\n    { name: \"nonce\", type: \"bytes32\" },\n  ],\n} as const;\n\nasync function buyApikey(duration: number, privateKey: `0x${string}` | undefined = undefined) {\n  const key = privateKey || (process.env.AUTOPAY_PKEY as `0x${string}`)\n  if (!key) {\n    throw new Error(\"AUTOPAY_PKEY environment variable not set\")\n  }\n  \n  const account = privateKeyToAccount(key);\n  const client = createWalletClient({\n    account,\n    chain: baseSepolia,\n    transport: http()\n  });\n  \n  // Step 1: Get payment quote\n  const infoResponse = await fetch(\"https://apipaymcp.okart.fun/info\");\n  const info = await infoResponse.json();\n  \n  const payeeAddress = info.payee as `0x${string}`;\n  const usdcAddress = info.asset as `0x${string}`;\n  const priceInUsdc = info.prices[`${duration}daysUsdc`];\n  \n  // USDC uses 6 decimals\n  const amount = parseUnits(priceInUsdc.toString(), 6);\n  \n  // Step 2: Create EIP-3009 signature\n  // For Base Sepolia USDC: name=\"USDC\", version=\"2\"\n  const nonce = `0x${crypto.randomBytes(32).toString(\"hex\")}` as `0x${string}`;\n  const now = Math.floor(Date.now() / 1000);\n  const validAfter = BigInt(0);\n  const validBefore = BigInt(now + 28800); // 8 hours\n  \n  const signature = await client.signTypedData({\n    domain: {\n      name: \"USDC\",\n      version: \"2\",\n      chainId: 84532,\n      verifyingContract: usdcAddress,\n    },\n    types: transferWithAuthorizationTypes,\n    primaryType: \"TransferWithAuthorization\",\n    message: {\n      from: account.address,\n      to: payeeAddress,\n      value: amount,\n      validAfter,\n      validBefore,\n      nonce,\n    },\n  });\n  \n  const signaturePayload = {\n    from: account.address,\n    to: payeeAddress,\n    value: amount.toString(),\n    validAfter: validAfter.toString(),\n    validBefore: validBefore.toString(),\n    nonce,\n    v: Number((signature.slice(-2) as `0x${string}`)),\n    r: signature.slice(0, 66) as `0x${string}`,\n    s: `0x${signature.slice(66, 130)}` as `0x${string}`\n  };\n  \n  // Step 3: Call buy-apikey with EIP-3009 signature\n  const buyResponse = await fetch(\"https://apipaymcp.okart.fun/v1/buy-apikey\", {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n      \"PAYMENT-SIGNATURE\": JSON.stringify(signaturePayload)\n    },\n    body: JSON.stringify({ duration })\n  });\n  \n  if (buyResponse.status !== 200) {\n    throw new Error(`Buy API key failed: ${await buyResponse.text()}`);\n  }\n  \n  const buyData = await buyResponse.json();\n  \n  return {\n    apiKey: buyData.apiKey,\n    txHash: buyData.txHash,\n    payState: buyData.payState,\n    durationDays: buyData.durationDays,\n    transactionId: buyData.transactionId\n  };\n}"
      },
      {
        "title": "refresh_pricing.ts",
        "body": "async function refreshPricing() {\n  const response = await fetch(\"https://apipaymcp.okart.fun/refresh_pricing\");\n  return response.json();\n}\n\nconst pricing = await refreshPricing();\nconsole.log(`Updated: ${pricing.updatedAt}`);\nif (pricing.prices) {\n  console.log(`1 day: $${pricing.prices['1dayUsdc']} USDC`);\n  console.log(`7 days: $${pricing.prices['7daysUsdc']} USDC`);\n  console.log(`30 days: $${pricing.prices['30daysUsdc']} USDC`);\n}"
      },
      {
        "title": "Complete Purchase Flow",
        "body": "// 1. Check server info and pricing\nconst info = await fetch(\"https://apipaymcp.okart.fun/info\").then(r => r.json());\nconsole.log(`Current pricing: ${JSON.stringify(info.prices)}`);\nconsole.log(`Payee address: ${info.payee}`);\nconsole.log(`USDC contract: ${info.asset}`);\n\n// 2. Create EIP-3009 signature\nconst privateKey = process.env.AUTOPAY_PKEY as `0x${string}`\nconst account = privateKeyToAccount(privateKey);\nconst client = createWalletClient({\n  account,\n  chain: baseSepolia,\n  transport: http()\n});\n\nconst nonce = `0x${crypto.randomBytes(32).toString(\"hex\")}`;\nconst now = Math.floor(Date.now() / 1000);\nconst validAfter = BigInt(0);\nconst validBefore = BigInt(now + 28800); // 8 hours\nconst amount = parseUnits(\"0.49\", 6); // for 7-day key\n\nconst signature = await client.signTypedData({\n  domain: {\n    name: \"USDC\",\n    version: \"2\",\n    chainId: 84532,\n    verifyingContract: info.asset,\n  },\n  types: transferWithAuthorizationTypes,\n  primaryType: \"TransferWithAuthorization\",\n  message: {\n    from: account.address,\n    to: info.payee,\n    value: amount,\n    validAfter,\n    validBefore,\n    nonce,\n  },\n});\n\nconst signaturePayload = {\n  from: account.address,\n  to: info.payee,\n  value: amount.toString(),\n  validAfter: validAfter.toString(),\n  validBefore: validBefore.toString(),\n  nonce,\n  v: Number((signature.slice(-2) as `0x${string}`)),\n  r: signature.slice(0, 66) as `0x${string}`,\n  s: `0x${signature.slice(66, 130)}` as `0x${string}`\n};\n\n// 3. Buy API key with EIP-3009 signature\nconst purchase = await fetch(\"https://apipaymcp.okart.fun/v1/buy-apikey\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\",\n    \"PAYMENT-SIGNATURE\": JSON.stringify(signaturePayload)\n  },\n  body: JSON.stringify({\n    duration: 7\n  })\n}).then(r => r.json());\n\nconsole.log(`   API Key: ${result.apiKey}`);\nconsole.log(`   TX Hash: ${result.txHash}`);\nconsole.log(`   Pay State: ${result.payState}`);\nconsole.log(`   Duration: ${result.durationDays} days`);\nconsole.log(`   Transaction ID: ${result.transactionId}`);"
      },
      {
        "title": "Error Handling",
        "body": "All endpoints return errors as:\n\n{\n  \"code\": \"PAYMENT_FAILED\",\n  \"message\": \"Insufficient USDC balance\",\n  \"details\": { \"required\": \"0.49\", \"available\": \"0.25\" }\n}\n\nCommon error codes:\n\nINVALID_DURATION (400) - Duration must be 1, 7, or 30\nPAYMENT_FAILED (402) - Payment transaction failed\nINSUFFICIENT_BALANCE (402) - Not enough USDC in wallet\nRATE_LIMITED (429) - Too many requests\nINTERNAL_ERROR (500) - Server error"
      },
      {
        "title": "Private Key Management",
        "body": "Never commit private keys to version control!\n\nAuto-Registration Security:\n\nUser accounts are automatically created on first purchase\nNo separate registration endpoint required\nUser account is linked to your wallet address\nAll future purchases are automatically associated with your user account\nUser data is accessible via /user/me endpoint with your API key\n\nRecommended approaches:\n\nEnvironment Variables (Recommended)\n# Set in shell\nexport AUTOPAY_PKEY=\"0x...\"\n\n# Or in .env file\necho \"AUTOPAY_PKEY=0x...\" > .env\n\n\n\nCLI Arguments (For testing)\n# Use AUTOPAY_PKEY environment variable\nexport AUTOPAY_PKEY=\"0x...\"\npython scripts/buy_apikey.py --duration 7\nbun run scripts/buy_apikey.ts --duration 7\n\n\n\nFor Skill Implementation\n\nPass private key via environment variables\nNever hardcode in code\nUse dotenv to load from .env file\n\nBest Practices:\n\nUse a dedicated wallet for API purchases (not main wallet)\nTest on Base Sepolia (Chain ID: 84532) before mainnet\nStore API keys securely (environment variables or secret manager)\nVerify transaction on Base Sepolia explorer before using API key\nRotate API keys regularly"
      }
    ],
    "body": "iAutoPay Fact API\n\nBase URLs:\n\nfact-api: https://apipaymcp.okart.fun (Payment API)\nnapi-ser: http://ipaynapi.gpuart.cn (User Management & API Keys)\nNetwork Configuration\nChain: Base Sepolia (Testnet)\nChain ID: eip155:84532\nAsset: 0x036CbD53842c5426634e7929541eC2318f3dCF7e (USDC)\nPayee: 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\nPricing\nDuration\tPrice (USDC)\n1 day\t0.09\n7 days\t0.49\n30 days\t0.99\nEndpoints\nfact-api (Payment Service)\nGET /info - Server Information\n\nGet current server status, pricing, and configuration.\n\ncurl \"https://apipaymcp.okart.fun/info\"\n\n\nResponse:\n\n{\n  \"name\": \"iAutoPay Fact API\",\n  \"version\": \"0.1.0\",\n  \"environment\": \"dev\",\n  \"network\": \"eip155:84532\",\n  \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",\n  \"prices\": {\n    \"1day\": \"90000\",\n    \"1dayUsdc\": 0.09,\n    \"7days\": \"490000\",\n    \"7daysUsdc\": 0.49,\n    \"30days\": \"990000\",\n    \"30daysUsdc\": 0.99\n  },\n  \"payee\": \"0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\",\n  \"bypassPayment\": false,\n  \"paymentScheme\": \"exact\"\n}\n\nPOST /v1/buy-apikey - Purchase API Key\n\nBuy an API key with specified duration. Payment is handled via EIP-3009 signed payment in the request header.\n\ncurl -X POST \"https://apipaymcp.okart.fun/v1/buy-apikey\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"PAYMENT-SIGNATURE: '{\\\"from\\\":\\\"0x...\\\",\\\"to\\\":\\\"0x...\\\",\\\"value\\\":\\\"90000\\\",\\\"validAfter\\\":\\\"0\\\",\\\"validBefore\\\":\\\"1738368000\\\",\\\"nonce\\\":\\\"0x...\\\",\\\"v\\\":27,\\\"r\\\":\\\"0x...\\\",\\\"s\\\":\\\"0x...\\\"}'\" \\\n  -d '{\"duration\": 7}'\n\n\nRequest Body:\n\n{\n  \"duration\": 7\n}\n\n\nHeaders:\n\nHeader\tType\tRequired\tDescription\nContent-Type\tstring\tYes\t\"application/json\"\nPAYMENT-SIGNATURE\tstring\tYes\tEIP-3009 signed payment payload (JSON string)\n\nPAYMENT-SIGNATURE Payload:\n\n{\n  \"from\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"to\": \"0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\",\n  \"value\": \"490000\",\n  \"validAfter\": \"0\",\n  \"validBefore\": \"1738368000\",\n  \"nonce\": \"0xabc123...\",\n  \"v\": 27,\n  \"r\": \"0x...\",\n  \"s\": \"0x...\"\n}\n\n\nDuration Options:\n\nValue\tDuration\tPrice\n1\t1 day\t0.09 USDC\n7\t7 days\t0.49 USDC\n30\t30 days\t0.99 USDC\n\nResponse:\n\n{\n  \"apiKey\": \"sk-7ac3d7c8fed74b0a8ae8f949e017e9f5\",\n  \"txHash\": \"0x1f62f45e5ae6e8cd637048d0f099d324f749f61d35906ffe481e36e92689769b\",\n  \"payState\": \"paid\",\n  \"durationDays\": 7,\n  \"transactionId\": \"ed66d250-7353-473d-bc73-0bd7541f40c0\"\n}\n\n\nResponse Fields:\n\nField\tType\tDescription\napiKey\tstring\tYour API key (use this for authentication)\ntxHash\tstring\tBlockchain transaction hash\npayState\tstring\tPayment status (\"paid\")\ndurationDays\tnumber\tAPI key duration in days\ntransactionId\tstring\tUnique transaction ID\nPOST /v1/transfer - Pay Stablecoin\n\nPay USDC to any address using EIP-3009 off-chain signature.\n\nGET /user/me - Get User Information\n\nGet your user account information, API keys, and usage statistics. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\n\nNote: The first purchase automatically creates your user account. No separate registration is required!\n\nGET /user/my-keys - List User API Keys\n\nGet all API keys for your user account. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}\n\nPOST /v1/transfer - Pay Stablecoin\n\nPay USDC to any address using EIP-3009 off-chain signature.\n\ncurl -X POST \"https://apipaymcp.okart.fun/v1/transfer\" \\\n  -H \"Content-Type: application/json\" \\\n  -H \"PAYMENT-SIGNATURE: '{\\\"from\\\":\\\"0x...\\\",\\\"to\\\":\\\"0x...\\\",\\\"value\\\":\\\"10000\\\",\\\"validAfter\\\":\\\"0\\\",\\\"validBefore\\\":\\\"1738368000\\\",\\\"nonce\\\":\\\"0x...\\\",\\\"v\\\":27,\\\"r\\\":\\\"0x...\\\",\\\"s\\\":\\\"0x...\\\"}'\" \\\n  -d '{\"to\": \"0x1234567890abcdef1234567890abcdef12345678\", \"amount\": \"10000\", \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"}'\n\n\nRequest Body:\n\n{\n  \"to\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"amount\": \"10000\",\n  \"asset\": \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\"\n}\n\n\nParameters:\n\nParameter\tType\tRequired\tDescription\nto\tstring\tYes\tRecipient wallet address\namount\tstring\tYes\tAmount in smallest unit (10000 = 0.01 USDC)\nasset\tstring\tYes\tToken contract address (USDC on Base Sepolia)\n\nHeaders:\n\nHeader\tType\tRequired\tDescription\nContent-Type\tstring\tYes\t\"application/json\"\nPAYMENT-SIGNATURE\tstring\tYes\tEIP-3009 signed payment payload (JSON string)\n\nResponse:\n\n{\n  \"success\": true,\n  \"transactionHash\": \"0x1234567890abcdef...\",\n  \"from\": \"0xabcdef1234567890abcdef1234567890abcdef12\",\n  \"to\": \"0x1234567890abcdef1234567890abcdef12345678\",\n  \"amount\": \"0.010000\",\n  \"deductedAmount\": \"0.010000 USDC\",\n  \"currentBalance\": \"9.990000 USDC\"\n}\n\nUser Management (New Feature)\n\nThe iAutoPay system now includes automatic user registration. When you purchase an API key for the first time, a user account is automatically created and linked to your wallet address.\n\nAuto-Registration Flow\nFirst Purchase: Call /v1/buy-apikey with your signed payment\nAuto-Create User: System automatically creates user account\nAPI Key Assigned: API key is linked to your user account\nUser Info Available: Use /user/me to view account details\n\nNo separate registration step is required!\n\nUser Endpoints\nGET /user/me - Get User Information\n\nGet your user account information, API keys, and usage statistics.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\nGET /user/my-keys - List User API Keys\n\nGet all API keys for your user account.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}\n\nGET /refresh_pricing - Refresh Pricing\n\nRefresh pricing information from server (cached).\n\ncurl \"https://apipaymcp.okart.fun/refresh_pricing\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"prices\": {\n    \"1day\": \"90000\",\n    \"1dayUsdc\": 0.09,\n    \"7days\": \"490000\",\n    \"7daysUsdc\": 0.49,\n    \"30days\": \"990000\",\n    \"30daysUsdc\": 0.99\n  },\n  \"updatedAt\": \"2026-02-25T12:00:00Z\"\n}\n\n\nnapi-ser (User Management)\nGET /user/me - Get User Information\n\nGet your user account information, API keys, and usage statistics. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/me\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"data\": {\n    \"user\": {\n      \"id\": \"user_xxx\",\n      \"walletAddress\": \"0x1234567890abcdef1234567890abcdef12345678\",\n      \"createdAt\": 1772072451317,\n      \"lastPurchasedAt\": 1772072457962,\n      \"status\": \"active\",\n      \"totalPurchases\": 2\n    },\n    \"activeApiKeys\": 2,\n    \"totalSpent\": 1480000,\n    \"apiKeys\": [\n      {\n        \"apiKey\": \"sk-xxx\",\n        \"durationDays\": 7,\n        \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n        \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n        \"status\": \"active\"\n      }\n    ],\n    \"recentTransactions\": [...]\n  }\n}\n\n\nNote: The first purchase automatically creates your user account. No separate registration is required!\n\nGET /user/my-keys - List User API Keys\n\nGet all API keys for your user account. Requires authentication with your API key.\n\ncurl \"http://ipaynapi.gpuart.cn/user/my-keys\" \\\n  -H \"Authorization: Bearer YOUR_API_KEY\"\n\n\nResponse:\n\n{\n  \"success\": true,\n  \"count\": 2,\n  \"data\": [\n    {\n      \"apiKey\": \"sk-xxx\",\n      \"durationDays\": 7,\n      \"createdAt\": \"2026-02-26T02:01:12.904Z\",\n      \"expiresAt\": \"2026-03-05T02:01:12.904Z\",\n      \"status\": \"active\"\n    }\n  ]\n}\n\nPayment Flow\n\nThe Fact API uses EIP-3009 (Transfer With Authorization) for off-chain payment signing. This means you don't need to send an on-chain transaction first - you sign a payment authorization and include it in the API request.\n\nSteps:\n\nGet Payment Info: Call /info to get the payee address and USDC contract address\nSign Payment: Create an EIP-3009 signature using your wallet's private key\nBuy API Key: Call /v1/buy-apikey with signed payment in the PAYMENT-SIGNATURE header\nAuto-Registration: The first purchase automatically creates your user account\nGet User Info: Use /user/me endpoint with your API key to check account details\n\nImportant: Auto-Registration\n\nNo separate registration step required\nFirst purchase automatically creates user account\nUser account is linked to your wallet address\nAll future purchases are associated with the same user account\n\nUser Management Endpoints (napi-ser):\n\nGET /user/me - Get user information, API keys, and statistics\nGET /user/my-keys - List all API keys for your account\n\nEIP-3009 Signature Requirements:\n\nDomain: Token name, version (2 for USDC), chainId, verifyingContract (USDC address)\nType: TransferWithAuthorization(from, to, value, validAfter, validBefore, nonce)\nValid Before: Current timestamp + 8 hours (28800 seconds)\n\nUSDC Contract: 0x036CbD53842c5426634e7929541eC2318f3dCF7e (Base Sepolia) Payee: 0x1a85156c2943b63febeee7883bd84a7d1cf0da0c\n\nCLI Scripts\n\nThis skill includes ready-to-use CLI scripts for all endpoints.\n\nDependencies:\n\n# TypeScript/Bun\nbun add viem dotenv\n\n# Python\npip install web3 requests python-dotenv\n\nGet Server Info\n# Python\npython scripts/info.py\n\n# TypeScript/Bun\nbun run scripts/info.ts\n\nGet Wallet Address\n# Python\npython scripts/get_address.py\n\n# TypeScript/Bun\nbun run scripts/get_address.ts\n\nBuy API Key\n# Python\npython scripts/buy_apikey.py --duration 7\n\n# TypeScript/Bun\nbun run scripts/buy_apikey.ts --duration 7\n\nRefresh Pricing\n# Python\npython scripts/refresh_pricing.py\n\n# TypeScript/Bun\nbun run scripts/refresh_pricing.ts\n\nPython Implementation\ninfo.py\nimport requests\n\ndef get_info():\n    response = requests.get(\"https://apipaymcp.okart.fun/info\")\n    return response.json()\n\nif __name__ == \"__main__\":\n    info = get_info()\n    print(f\"Environment: {info['environment']}\")\n    print(f\"Network: {info['network']}\")\n    print(f\"Payee: {info['payee']}\")\n    print(f\"Asset: {info['asset']}\")\n    print(f\"Pricing:\")\n    for key, value in info['prices'].items():\n        print(f\"  {key}: {value}\")\n\nget_address.py\nfrom web3 import Web3\nimport os\n\ndef get_address(private_key: str = None):\n    if private_key is None:\n        private_key = os.environ.get('AUTOPAY_PKEY')\n        if not private_key:\n            raise ValueError(\"AUTOPAY_PKEY environment variable not set\")\n    \n    w3 = Web3()\n    account = w3.eth.account.from_key(private_key)\n    return account.address\n\nif __name__ == \"__main__\":\n    address = get_address()\n    print(f\"Your Wallet Address: {address}\")\n\nbuy_apikey.py\nimport requests\nfrom web3 import Web3\nimport json\nimport time\nimport os\n\ndef buy_apikey(duration: int, private_key: str = None):\n    if private_key is None:\n        private_key = os.environ.get('AUTOPAY_PKEY')\n        if not private_key:\n            raise ValueError(\"AUTOPAY_PKEY environment variable not set\")\n    \n    w3 = Web3(Web3.HTTPProvider(\"https://sepolia.base.org\"))\n    account = w3.eth.account.from_key(private_key)\n    \n    # Step 1: Get payment quote\n    info_response = requests.get(\"https://apipaymcp.okart.fun/info\")\n    info = info_response.json()\n    \n    payee_address = info['payee']\n    usdc_address = info['asset']\n    price_in_usdc = info['prices'][f'{duration}daysUsdc']\n    \n    # USDC uses 6 decimals\n    amount = int(price_in_usdc * 10 ** 6)\n    \n    # Step 2: Create EIP-3009 signature\n    # For Base Sepolia USDC: name=\"USDC\", version=\"2\"\n    domain = {\n        \"name\": \"USDC\",\n        \"version\": \"2\",\n        \"chainId\": 84532,\n        \"verifyingContract\": usdc_address\n    }\n    \n    message_types = {\n        \"TransferWithAuthorization\": [\n            {\"name\": \"from\", \"type\": \"address\"},\n            {\"name\": \"to\", \"type\": \"address\"},\n            {\"name\": \"value\", \"type\": \"uint256\"},\n            {\"name\": \"validAfter\", \"type\": \"uint256\"},\n            {\"name\": \"validBefore\", \"type\": \"uint256\"},\n            {\"name\": \"nonce\", \"type\": \"bytes32\"}\n        ]\n    }\n    \n    nonce = os.urandom(32).hex()\n    now = int(time.time())\n    valid_after = 0\n    valid_before = now + 28800  # 8 hours\n    \n    message = {\n        \"from\": account.address,\n        \"to\": payee_address,\n        \"value\": amount,\n        \"validAfter\": valid_after,\n        \"validBefore\": valid_before,\n        \"nonce\": f\"0x{nonce}\"\n    }\n    \n    # Sign typed data\n    signed_message = w3.eth.account.sign_typed_data(\n        private_key=private_key,\n        domain=domain,\n        message_types=message_types,\n        message=message\n    )\n    \n    signature_payload = {\n        \"from\": account.address,\n        \"to\": payee_address,\n        \"value\": str(amount),\n        \"validAfter\": str(valid_after),\n        \"validBefore\": str(valid_before),\n        \"nonce\": f\"0x{nonce}\",\n        \"v\": signed_message.v,\n        \"r\": signed_message.r.hex(),\n        \"s\": signed_message.s.hex()\n    }\n    \n    # Step 3: Call buy-apikey with EIP-3009 signature\n    buy_response = requests.post(\n        \"https://apipaymcp.okart.fun/v1/buy-apikey\",\n        headers={\n            \"Content-Type\": \"application/json\",\n            \"PAYMENT-SIGNATURE\": json.dumps(signature_payload)\n        },\n        json={\"duration\": duration}\n    )\n    \n    if buy_response.status_code != 200:\n        raise Exception(f\"Buy API key failed: {buy_response.text}\")\n    \n    return {\n        \"apiKey\": buy_response.json()['apiKey'],\n        \"txHash\": buy_response.json()['txHash'],\n        \"payState\": buy_response.json()['payState'],\n        \"durationDays\": buy_response.json()['durationDays'],\n        \"transactionId\": buy_response.json()['transactionId']\n    }\n\nif __name__ == \"__main__\":\n    import argparse\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"--duration\", type=int, choices=[1, 7, 30], required=True)\n    args = parser.parse_args()\n    \n    result = buy_apikey(args.duration)\n    print(json.dumps(result, indent=2))\n\nrefresh_pricing.py\nimport requests\n\ndef refresh_pricing():\n    response = requests.get(\"https://apipaymcp.okart.fun/refresh_pricing\")\n    return response.json()\n\nif __name__ == \"__main__\":\n    pricing = refresh_pricing()\n    print(f\"Pricing updated at: {pricing.get('updatedAt', 'N/A')}\")\n    if 'prices' in pricing:\n        print(f\"1 day: ${pricing['prices']['1dayUsdc']} USDC\")\n        print(f\"7 days: ${pricing['prices']['7daysUsdc']} USDC\")\n        print(f\"30 days: ${pricing['prices']['30daysUsdc']} USDC\")\n\nTypeScript Implementation\ninfo.ts\nasync function getInfo() {\n  const response = await fetch(\"https://apipaymcp.okart.fun/info\");\n  return response.json();\n}\n\nconst info = await getInfo();\nconsole.log(`Environment: ${info.environment}`);\nconsole.log(`Network: ${info.network}`);\nconsole.log(`Payee: ${info.payee}`);\nconsole.log(`Asset: ${info.asset}`);\nconsole.log(\"Pricing:\");\nObject.entries(info.prices).forEach(([key, value]) => {\n  console.log(`  ${key}: ${value}`);\n});\n\nget_address.ts\nimport { privateKeyToAccount } from \"viem/accounts\";\n\nfunction getAddress(privateKey?: `0x${string}`): string {\n  const key = privateKey || (process.env.AUTOPAY_PKEY as `0x${string}`);\n  if (!key) {\n    throw new Error(\"AUTOPAY_PKEY environment variable not set\");\n  }\n  \n  const account = privateKeyToAccount(key);\n  return account.address;\n}\n\nconst address = getAddress();\nconsole.log(`Your Wallet Address: ${address}`);\n\nbuy_apikey.ts\nimport { createWalletClient, http, parseUnits } from \"viem\";\nimport { baseSepolia } from \"viem/chains\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport crypto from \"crypto\";\n\nconst transferWithAuthorizationTypes = {\n  TransferWithAuthorization: [\n    { name: \"from\", type: \"address\" },\n    { name: \"to\", type: \"address\" },\n    { name: \"value\", type: \"uint256\" },\n    { name: \"validAfter\", type: \"uint256\" },\n    { name: \"validBefore\", type: \"uint256\" },\n    { name: \"nonce\", type: \"bytes32\" },\n  ],\n} as const;\n\nasync function buyApikey(duration: number, privateKey: `0x${string}` | undefined = undefined) {\n  const key = privateKey || (process.env.AUTOPAY_PKEY as `0x${string}`)\n  if (!key) {\n    throw new Error(\"AUTOPAY_PKEY environment variable not set\")\n  }\n  \n  const account = privateKeyToAccount(key);\n  const client = createWalletClient({\n    account,\n    chain: baseSepolia,\n    transport: http()\n  });\n  \n  // Step 1: Get payment quote\n  const infoResponse = await fetch(\"https://apipaymcp.okart.fun/info\");\n  const info = await infoResponse.json();\n  \n  const payeeAddress = info.payee as `0x${string}`;\n  const usdcAddress = info.asset as `0x${string}`;\n  const priceInUsdc = info.prices[`${duration}daysUsdc`];\n  \n  // USDC uses 6 decimals\n  const amount = parseUnits(priceInUsdc.toString(), 6);\n  \n  // Step 2: Create EIP-3009 signature\n  // For Base Sepolia USDC: name=\"USDC\", version=\"2\"\n  const nonce = `0x${crypto.randomBytes(32).toString(\"hex\")}` as `0x${string}`;\n  const now = Math.floor(Date.now() / 1000);\n  const validAfter = BigInt(0);\n  const validBefore = BigInt(now + 28800); // 8 hours\n  \n  const signature = await client.signTypedData({\n    domain: {\n      name: \"USDC\",\n      version: \"2\",\n      chainId: 84532,\n      verifyingContract: usdcAddress,\n    },\n    types: transferWithAuthorizationTypes,\n    primaryType: \"TransferWithAuthorization\",\n    message: {\n      from: account.address,\n      to: payeeAddress,\n      value: amount,\n      validAfter,\n      validBefore,\n      nonce,\n    },\n  });\n  \n  const signaturePayload = {\n    from: account.address,\n    to: payeeAddress,\n    value: amount.toString(),\n    validAfter: validAfter.toString(),\n    validBefore: validBefore.toString(),\n    nonce,\n    v: Number((signature.slice(-2) as `0x${string}`)),\n    r: signature.slice(0, 66) as `0x${string}`,\n    s: `0x${signature.slice(66, 130)}` as `0x${string}`\n  };\n  \n  // Step 3: Call buy-apikey with EIP-3009 signature\n  const buyResponse = await fetch(\"https://apipaymcp.okart.fun/v1/buy-apikey\", {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n      \"PAYMENT-SIGNATURE\": JSON.stringify(signaturePayload)\n    },\n    body: JSON.stringify({ duration })\n  });\n  \n  if (buyResponse.status !== 200) {\n    throw new Error(`Buy API key failed: ${await buyResponse.text()}`);\n  }\n  \n  const buyData = await buyResponse.json();\n  \n  return {\n    apiKey: buyData.apiKey,\n    txHash: buyData.txHash,\n    payState: buyData.payState,\n    durationDays: buyData.durationDays,\n    transactionId: buyData.transactionId\n  };\n}\n\nrefresh_pricing.ts\nasync function refreshPricing() {\n  const response = await fetch(\"https://apipaymcp.okart.fun/refresh_pricing\");\n  return response.json();\n}\n\nconst pricing = await refreshPricing();\nconsole.log(`Updated: ${pricing.updatedAt}`);\nif (pricing.prices) {\n  console.log(`1 day: $${pricing.prices['1dayUsdc']} USDC`);\n  console.log(`7 days: $${pricing.prices['7daysUsdc']} USDC`);\n  console.log(`30 days: $${pricing.prices['30daysUsdc']} USDC`);\n}\n\nComplete Purchase Flow\n// 1. Check server info and pricing\nconst info = await fetch(\"https://apipaymcp.okart.fun/info\").then(r => r.json());\nconsole.log(`Current pricing: ${JSON.stringify(info.prices)}`);\nconsole.log(`Payee address: ${info.payee}`);\nconsole.log(`USDC contract: ${info.asset}`);\n\n// 2. Create EIP-3009 signature\nconst privateKey = process.env.AUTOPAY_PKEY as `0x${string}`\nconst account = privateKeyToAccount(privateKey);\nconst client = createWalletClient({\n  account,\n  chain: baseSepolia,\n  transport: http()\n});\n\nconst nonce = `0x${crypto.randomBytes(32).toString(\"hex\")}`;\nconst now = Math.floor(Date.now() / 1000);\nconst validAfter = BigInt(0);\nconst validBefore = BigInt(now + 28800); // 8 hours\nconst amount = parseUnits(\"0.49\", 6); // for 7-day key\n\nconst signature = await client.signTypedData({\n  domain: {\n    name: \"USDC\",\n    version: \"2\",\n    chainId: 84532,\n    verifyingContract: info.asset,\n  },\n  types: transferWithAuthorizationTypes,\n  primaryType: \"TransferWithAuthorization\",\n  message: {\n    from: account.address,\n    to: info.payee,\n    value: amount,\n    validAfter,\n    validBefore,\n    nonce,\n  },\n});\n\nconst signaturePayload = {\n  from: account.address,\n  to: info.payee,\n  value: amount.toString(),\n  validAfter: validAfter.toString(),\n  validBefore: validBefore.toString(),\n  nonce,\n  v: Number((signature.slice(-2) as `0x${string}`)),\n  r: signature.slice(0, 66) as `0x${string}`,\n  s: `0x${signature.slice(66, 130)}` as `0x${string}`\n};\n\n// 3. Buy API key with EIP-3009 signature\nconst purchase = await fetch(\"https://apipaymcp.okart.fun/v1/buy-apikey\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\",\n    \"PAYMENT-SIGNATURE\": JSON.stringify(signaturePayload)\n  },\n  body: JSON.stringify({\n    duration: 7\n  })\n}).then(r => r.json());\n\nconsole.log(`   API Key: ${result.apiKey}`);\nconsole.log(`   TX Hash: ${result.txHash}`);\nconsole.log(`   Pay State: ${result.payState}`);\nconsole.log(`   Duration: ${result.durationDays} days`);\nconsole.log(`   Transaction ID: ${result.transactionId}`);\n\nError Handling\n\nAll endpoints return errors as:\n\n{\n  \"code\": \"PAYMENT_FAILED\",\n  \"message\": \"Insufficient USDC balance\",\n  \"details\": { \"required\": \"0.49\", \"available\": \"0.25\" }\n}\n\n\nCommon error codes:\n\nINVALID_DURATION (400) - Duration must be 1, 7, or 30\nPAYMENT_FAILED (402) - Payment transaction failed\nINSUFFICIENT_BALANCE (402) - Not enough USDC in wallet\nRATE_LIMITED (429) - Too many requests\nINTERNAL_ERROR (500) - Server error\nSecurity Notes\nPrivate Key Management\n\nNever commit private keys to version control!\n\nAuto-Registration Security:\n\nUser accounts are automatically created on first purchase\nNo separate registration endpoint required\nUser account is linked to your wallet address\nAll future purchases are automatically associated with your user account\nUser data is accessible via /user/me endpoint with your API key\n\nRecommended approaches:\n\nEnvironment Variables (Recommended)\n\n# Set in shell\nexport AUTOPAY_PKEY=\"0x...\"\n\n# Or in .env file\necho \"AUTOPAY_PKEY=0x...\" > .env\n\n\nCLI Arguments (For testing)\n\n# Use AUTOPAY_PKEY environment variable\nexport AUTOPAY_PKEY=\"0x...\"\npython scripts/buy_apikey.py --duration 7\nbun run scripts/buy_apikey.ts --duration 7\n\n\nFor Skill Implementation\n\nPass private key via environment variables\nNever hardcode in code\nUse dotenv to load from .env file\n\nBest Practices:\n\nUse a dedicated wallet for API purchases (not main wallet)\nTest on Base Sepolia (Chain ID: 84532) before mainnet\nStore API keys securely (environment variables or secret manager)\nVerify transaction on Base Sepolia explorer before using API key\nRotate API keys regularly"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/newblock/iautopay",
    "publisherUrl": "https://clawhub.ai/newblock/iautopay",
    "owner": "newblock",
    "version": "0.1.1",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/iautopay",
    "downloadUrl": "https://openagent3.xyz/downloads/iautopay",
    "agentUrl": "https://openagent3.xyz/skills/iautopay/agent",
    "manifestUrl": "https://openagent3.xyz/skills/iautopay/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/iautopay/agent.md"
  }
}