{
  "schemaVersion": "1.0",
  "item": {
    "slug": "x402-enhanced",
    "name": "x402 (official examples)",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/notorious-d-e-v/x402-enhanced",
    "canonicalUrl": "https://clawhub.ai/notorious-d-e-v/x402-enhanced",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/x402-enhanced",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=x402-enhanced",
    "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/x402-enhanced"
    },
    "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/x402-enhanced",
    "agentPageUrl": "https://openagent3.xyz/skills/x402-enhanced/agent",
    "manifestUrl": "https://openagent3.xyz/skills/x402-enhanced/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/x402-enhanced/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": "x402 Payment Protocol",
        "body": "x402 is an open, internet-native payment standard built around the HTTP 402 Payment Required status code. It enables programmatic payments between clients and servers without accounts, sessions, or credential management.\n\nKey Benefits:\n\nZero protocol fees (only blockchain network fees)\nZero friction (no accounts or KYC required)\nInstant settlement via stablecoins\nWorks with AI agents and automated systems\n\nDocumentation: https://docs.x402.org | GitHub: https://github.com/coinbase/x402"
      },
      {
        "title": "How x402 Works",
        "body": "Client requests a resource from a server\nServer responds with 402 Payment Required + payment instructions\nClient signs and submits a payment payload\nServer verifies payment, optionally via a facilitator\nServer returns the requested resource"
      },
      {
        "title": "For Buyers (Clients)",
        "body": "# EVM wallet private key (Ethereum/Base/Polygon)\nEVM_PRIVATE_KEY=0x...\n\n# Solana wallet private key (base58 encoded)\nSVM_PRIVATE_KEY=...\n\n# Target server URL\nRESOURCE_SERVER_URL=http://localhost:4021\nENDPOINT_PATH=/weather"
      },
      {
        "title": "For Sellers (Servers)",
        "body": "# Your EVM wallet address to receive payments\nEVM_ADDRESS=0x...\n\n# Your Solana wallet address to receive payments\nSVM_ADDRESS=...\n\n# Facilitator URL (see list below)\nFACILITATOR_URL=https://x402.org/facilitator"
      },
      {
        "title": "Network Identifiers (CAIP-2)",
        "body": "NetworkCAIP-2 IDDescriptionBaseBase Mainneteip155:8453Base L2 mainnetBase Sepoliaeip155:84532Base L2 testnetSolanaSolana Mainnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpSolana mainnetSolana Devnetsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1Solana testnetPolygonPolygon Mainneteip155:137Polygon PoS mainnetPolygon Amoyeip155:80002Polygon testnetAvalancheAvalanche C-Chaineip155:43114Avalanche mainnetAvalanche Fujieip155:43113Avalanche testnetSeiSei Mainneteip155:1329Sei EVM mainnetSei Testneteip155:713715Sei EVM testnetX LayerX Layer Mainneteip155:196OKX L2 mainnetX Layer Testneteip155:1952OKX L2 testnetSKALESKALE Baseeip155:1187947933SKALE mainnetSKALE Base Sepoliaeip155:324705682SKALE testnet"
      },
      {
        "title": "Facilitators",
        "body": "Facilitators handle payment verification and blockchain settlement. Choose one:\n\nNameURLNotesx402.orghttps://x402.org/facilitatorDefault, testnet onlyCoinbasehttps://api.cdp.coinbase.com/platform/v2/x402ProductionPayAIhttps://facilitator.payai.networkProductionCorbitshttps://facilitator.corbits.devProductionx402rshttps://facilitator.x402.rsProductionDexterhttps://x402.dexter.cashProductionHeuristhttps://facilitator.heurist.xyzProductionKobaruhttps://gateway.kobaru.ioProductionMogamihttps://facilitator.mogami.techProductionNeverminedhttps://api.live.nevermined.app/api/v1/ProductionOpenfacilitatorhttps://pay.openfacilitator.ioProductionSolpayhttps://x402.solpay.cashProductionPrimerhttps://x402.primer.systemsProductionxEchohttps://facilitator.xechoai.xyzProduction"
      },
      {
        "title": "TypeScript with fetch",
        "body": "Install dependencies:\n\nnpm install @x402/fetch @x402/evm @x402/svm viem @solana/kit @scure/base dotenv\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { x402Client, wrapFetchWithPayment, x402HTTPClient } from \"@x402/fetch\";\nimport { registerExactEvmScheme } from \"@x402/evm/exact/client\";\nimport { registerExactSvmScheme } from \"@x402/svm/exact/client\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createKeyPairSignerFromBytes } from \"@solana/kit\";\nimport { base58 } from \"@scure/base\";\n\nconfig();\n\nconst evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;\nconst svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;\nconst url = `${process.env.RESOURCE_SERVER_URL}${process.env.ENDPOINT_PATH}`;\n\nasync function main(): Promise<void> {\n  const evmSigner = privateKeyToAccount(evmPrivateKey);\n  const svmSigner = await createKeyPairSignerFromBytes(base58.decode(svmPrivateKey));\n\n  const client = new x402Client();\n  registerExactEvmScheme(client, { signer: evmSigner });\n  registerExactSvmScheme(client, { signer: svmSigner });\n\n  const fetchWithPayment = wrapFetchWithPayment(fetch, client);\n\n  const response = await fetchWithPayment(url, { method: \"GET\" });\n  const body = await response.json();\n  console.log(\"Response:\", body);\n\n  if (response.ok) {\n    const paymentResponse = new x402HTTPClient(client).getPaymentSettleResponse(\n      name => response.headers.get(name)\n    );\n    console.log(\"Payment:\", JSON.stringify(paymentResponse, null, 2));\n  }\n}\n\nmain().catch(console.error);"
      },
      {
        "title": "TypeScript with axios",
        "body": "Install dependencies:\n\nnpm install @x402/axios @x402/evm @x402/svm axios viem @solana/kit @scure/base dotenv\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { x402Client, wrapAxiosWithPayment, x402HTTPClient } from \"@x402/axios\";\nimport { registerExactEvmScheme } from \"@x402/evm/exact/client\";\nimport { registerExactSvmScheme } from \"@x402/svm/exact/client\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createKeyPairSignerFromBytes } from \"@solana/kit\";\nimport { base58 } from \"@scure/base\";\nimport axios from \"axios\";\n\nconfig();\n\nconst evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;\nconst svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;\nconst url = `${process.env.RESOURCE_SERVER_URL}${process.env.ENDPOINT_PATH}`;\n\nasync function main(): Promise<void> {\n  const evmSigner = privateKeyToAccount(evmPrivateKey);\n  const svmSigner = await createKeyPairSignerFromBytes(base58.decode(svmPrivateKey));\n\n  const client = new x402Client();\n  registerExactEvmScheme(client, { signer: evmSigner });\n  registerExactSvmScheme(client, { signer: svmSigner });\n\n  const api = wrapAxiosWithPayment(axios.create(), client);\n\n  const response = await api.get(url);\n  console.log(\"Response:\", response.data);\n\n  if (response.status < 400) {\n    const paymentResponse = new x402HTTPClient(client).getPaymentSettleResponse(\n      name => response.headers[name.toLowerCase()]\n    );\n    console.log(\"Payment:\", paymentResponse);\n  }\n}\n\nmain().catch(console.error);"
      },
      {
        "title": "Python with httpx (async)",
        "body": "Install dependencies:\n\npip install \"x402[httpx,evm,svm]\" python-dotenv\n\nCode:\n\nimport asyncio\nimport os\nfrom dotenv import load_dotenv\nfrom eth_account import Account\n\nfrom x402 import x402Client\nfrom x402.http import x402HTTPClient\nfrom x402.http.clients import x402HttpxClient\nfrom x402.mechanisms.evm import EthAccountSigner\nfrom x402.mechanisms.evm.exact.register import register_exact_evm_client\nfrom x402.mechanisms.svm import KeypairSigner\nfrom x402.mechanisms.svm.exact.register import register_exact_svm_client\n\nload_dotenv()\n\nasync def main() -> None:\n    evm_private_key = os.getenv(\"EVM_PRIVATE_KEY\")\n    svm_private_key = os.getenv(\"SVM_PRIVATE_KEY\")\n    base_url = os.getenv(\"RESOURCE_SERVER_URL\")\n    endpoint_path = os.getenv(\"ENDPOINT_PATH\")\n\n    client = x402Client()\n\n    if evm_private_key:\n        account = Account.from_key(evm_private_key)\n        register_exact_evm_client(client, EthAccountSigner(account))\n\n    if svm_private_key:\n        svm_signer = KeypairSigner.from_base58(svm_private_key)\n        register_exact_svm_client(client, svm_signer)\n\n    http_client = x402HTTPClient(client)\n    url = f\"{base_url}{endpoint_path}\"\n\n    async with x402HttpxClient(client) as http:\n        response = await http.get(url)\n        await response.aread()\n        print(f\"Response: {response.text}\")\n\n        if response.is_success:\n            try:\n                settle_response = http_client.get_payment_settle_response(\n                    lambda name: response.headers.get(name)\n                )\n                print(f\"Payment: {settle_response.model_dump_json(indent=2)}\")\n            except ValueError:\n                print(\"No payment response header found\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())"
      },
      {
        "title": "Python with requests (sync)",
        "body": "Install dependencies:\n\npip install \"x402[requests,evm,svm]\" python-dotenv\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom eth_account import Account\n\nfrom x402 import x402ClientSync\nfrom x402.http import x402HTTPClientSync\nfrom x402.http.clients import x402_requests\nfrom x402.mechanisms.evm import EthAccountSigner\nfrom x402.mechanisms.evm.exact.register import register_exact_evm_client\nfrom x402.mechanisms.svm import KeypairSigner\nfrom x402.mechanisms.svm.exact.register import register_exact_svm_client\n\nload_dotenv()\n\ndef main() -> None:\n    evm_private_key = os.getenv(\"EVM_PRIVATE_KEY\")\n    svm_private_key = os.getenv(\"SVM_PRIVATE_KEY\")\n    base_url = os.getenv(\"RESOURCE_SERVER_URL\")\n    endpoint_path = os.getenv(\"ENDPOINT_PATH\")\n\n    client = x402ClientSync()\n\n    if evm_private_key:\n        account = Account.from_key(evm_private_key)\n        register_exact_evm_client(client, EthAccountSigner(account))\n\n    if svm_private_key:\n        svm_signer = KeypairSigner.from_base58(svm_private_key)\n        register_exact_svm_client(client, svm_signer)\n\n    http_client = x402HTTPClientSync(client)\n    url = f\"{base_url}{endpoint_path}\"\n\n    with x402_requests(client) as session:\n        response = session.get(url)\n        print(f\"Response: {response.text}\")\n\n        if response.ok:\n            try:\n                settle_response = http_client.get_payment_settle_response(\n                    lambda name: response.headers.get(name)\n                )\n                print(f\"Payment: {settle_response.model_dump_json(indent=2)}\")\n            except ValueError:\n                print(\"No payment response header found\")\n\nif __name__ == \"__main__\":\n    main()"
      },
      {
        "title": "Go with net/http",
        "body": "Install dependencies:\n\ngo get github.com/coinbase/x402/go\ngo get github.com/joho/godotenv\n\nCode:\n\npackage main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\tx402 \"github.com/coinbase/x402/go\"\n\t\"github.com/joho/godotenv\"\n)\n\nfunc main() {\n\tgodotenv.Load()\n\n\tevmPrivateKey := os.Getenv(\"EVM_PRIVATE_KEY\")\n\tsvmPrivateKey := os.Getenv(\"SVM_PRIVATE_KEY\")\n\turl := os.Getenv(\"SERVER_URL\")\n\tif url == \"\" {\n\t\turl = \"http://localhost:4021/weather\"\n\t}\n\n\t// Create x402 client with EVM and SVM support\n\tclient, err := x402.NewClientBuilder().\n\t\tWithEvmSigner(evmPrivateKey).\n\t\tWithSvmSigner(svmPrivateKey).\n\t\tBuild()\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to create client: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\t// Wrap HTTP client with payment handling\n\thttpClient := client.WrapHTTPClient(&http.Client{Timeout: 30 * time.Second})\n\n\tctx := context.Background()\n\treq, _ := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\tfmt.Printf(\"Request failed: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tdefer resp.Body.Close()\n\n\tvar responseData interface{}\n\tjson.NewDecoder(resp.Body).Decode(&responseData)\n\tprettyJSON, _ := json.MarshalIndent(responseData, \"\", \"  \")\n\tfmt.Printf(\"Response: %s\\n\", string(prettyJSON))\n}"
      },
      {
        "title": "TypeScript with Express",
        "body": "Install dependencies:\n\nnpm install express @x402/express @x402/core @x402/evm @x402/svm dotenv\n\nCode:\n\nimport { config } from \"dotenv\";\nimport express from \"express\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/express\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { ExactSvmScheme } from \"@x402/svm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\n\nconfig();\n\nconst evmAddress = process.env.EVM_ADDRESS as `0x${string}`;\nconst svmAddress = process.env.SVM_ADDRESS;\nconst facilitatorUrl = process.env.FACILITATOR_URL || \"https://x402.org/facilitator\";\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });\nconst app = express();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /weather\": {\n        accepts: [\n          { scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress },\n          { scheme: \"exact\", price: \"$0.001\", network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", payTo: svmAddress },\n        ],\n        description: \"Weather data\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient)\n      .register(\"eip155:84532\", new ExactEvmScheme())\n      .register(\"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", new ExactSvmScheme()),\n  ),\n);\n\napp.get(\"/weather\", (req, res) => {\n  res.send({ report: { weather: \"sunny\", temperature: 70 } });\n});\n\napp.listen(4021, () => console.log(\"Server listening at http://localhost:4021\"));"
      },
      {
        "title": "TypeScript with Hono",
        "body": "Install dependencies:\n\nnpm install hono @hono/node-server @x402/hono @x402/core @x402/evm @x402/svm dotenv\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/hono\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { ExactSvmScheme } from \"@x402/svm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\nimport { Hono } from \"hono\";\nimport { serve } from \"@hono/node-server\";\n\nconfig();\n\nconst evmAddress = process.env.EVM_ADDRESS as `0x${string}`;\nconst svmAddress = process.env.SVM_ADDRESS;\nconst facilitatorUrl = process.env.FACILITATOR_URL || \"https://x402.org/facilitator\";\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });\nconst app = new Hono();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /weather\": {\n        accepts: [\n          { scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress },\n          { scheme: \"exact\", price: \"$0.001\", network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", payTo: svmAddress },\n        ],\n        description: \"Weather data\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient)\n      .register(\"eip155:84532\", new ExactEvmScheme())\n      .register(\"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", new ExactSvmScheme()),\n  ),\n);\n\napp.get(\"/weather\", c => c.json({ report: { weather: \"sunny\", temperature: 70 } }));\n\nserve({ fetch: app.fetch, port: 4021 });\nconsole.log(\"Server listening at http://localhost:4021\");"
      },
      {
        "title": "Python with FastAPI",
        "body": "Install dependencies:\n\npip install \"x402[fastapi,evm,svm]\" python-dotenv uvicorn\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom fastapi import FastAPI\n\nfrom x402.http import FacilitatorConfig, HTTPFacilitatorClient, PaymentOption\nfrom x402.http.middleware.fastapi import PaymentMiddlewareASGI\nfrom x402.http.types import RouteConfig\nfrom x402.mechanisms.evm.exact import ExactEvmServerScheme\nfrom x402.mechanisms.svm.exact import ExactSvmServerScheme\nfrom x402.schemas import Network\nfrom x402.server import x402ResourceServer\n\nload_dotenv()\n\nEVM_ADDRESS = os.getenv(\"EVM_ADDRESS\")\nSVM_ADDRESS = os.getenv(\"SVM_ADDRESS\")\nEVM_NETWORK: Network = \"eip155:84532\"\nSVM_NETWORK: Network = \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\"\nFACILITATOR_URL = os.getenv(\"FACILITATOR_URL\", \"https://x402.org/facilitator\")\n\napp = FastAPI()\n\nfacilitator = HTTPFacilitatorClient(FacilitatorConfig(url=FACILITATOR_URL))\nserver = x402ResourceServer(facilitator)\nserver.register(EVM_NETWORK, ExactEvmServerScheme())\nserver.register(SVM_NETWORK, ExactSvmServerScheme())\n\nroutes = {\n    \"GET /weather\": RouteConfig(\n        accepts=[\n            PaymentOption(scheme=\"exact\", pay_to=EVM_ADDRESS, price=\"$0.01\", network=EVM_NETWORK),\n            PaymentOption(scheme=\"exact\", pay_to=SVM_ADDRESS, price=\"$0.01\", network=SVM_NETWORK),\n        ],\n        mime_type=\"application/json\",\n        description=\"Weather report\",\n    ),\n}\n\napp.add_middleware(PaymentMiddlewareASGI, routes=routes, server=server)\n\n@app.get(\"/health\")\nasync def health_check():\n    return {\"status\": \"ok\"}\n\n@app.get(\"/weather\")\nasync def get_weather():\n    return {\"report\": {\"weather\": \"sunny\", \"temperature\": 70}}\n\nif __name__ == \"__main__\":\n    import uvicorn\n    uvicorn.run(app, host=\"0.0.0.0\", port=4021)"
      },
      {
        "title": "Python with Flask",
        "body": "Install dependencies:\n\npip install \"x402[flask,evm,svm]\" python-dotenv\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom flask import Flask, jsonify\n\nfrom x402.http import FacilitatorConfig, HTTPFacilitatorClientSync, PaymentOption\nfrom x402.http.middleware.flask import payment_middleware\nfrom x402.http.types import RouteConfig\nfrom x402.mechanisms.evm.exact import ExactEvmServerScheme\nfrom x402.mechanisms.svm.exact import ExactSvmServerScheme\nfrom x402.schemas import Network\nfrom x402.server import x402ResourceServerSync\n\nload_dotenv()\n\nEVM_ADDRESS = os.getenv(\"EVM_ADDRESS\")\nSVM_ADDRESS = os.getenv(\"SVM_ADDRESS\")\nEVM_NETWORK: Network = \"eip155:84532\"\nSVM_NETWORK: Network = \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\"\nFACILITATOR_URL = os.getenv(\"FACILITATOR_URL\", \"https://x402.org/facilitator\")\n\napp = Flask(__name__)\n\nfacilitator = HTTPFacilitatorClientSync(FacilitatorConfig(url=FACILITATOR_URL))\nserver = x402ResourceServerSync(facilitator)\nserver.register(EVM_NETWORK, ExactEvmServerScheme())\nserver.register(SVM_NETWORK, ExactSvmServerScheme())\n\nroutes = {\n    \"GET /weather\": RouteConfig(\n        accepts=[\n            PaymentOption(scheme=\"exact\", pay_to=EVM_ADDRESS, price=\"$0.01\", network=EVM_NETWORK),\n            PaymentOption(scheme=\"exact\", pay_to=SVM_ADDRESS, price=\"$0.01\", network=SVM_NETWORK),\n        ],\n        mime_type=\"application/json\",\n        description=\"Weather report\",\n    ),\n}\n\npayment_middleware(app, routes=routes, server=server)\n\n@app.route(\"/health\")\ndef health_check():\n    return jsonify({\"status\": \"ok\"})\n\n@app.route(\"/weather\")\ndef get_weather():\n    return jsonify({\"report\": {\"weather\": \"sunny\", \"temperature\": 70}})\n\nif __name__ == \"__main__\":\n    app.run(host=\"0.0.0.0\", port=4021)"
      },
      {
        "title": "Go with Gin",
        "body": "Install dependencies:\n\ngo get github.com/coinbase/x402/go\ngo get github.com/gin-gonic/gin\ngo get github.com/joho/godotenv\n\nCode:\n\npackage main\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\tx402 \"github.com/coinbase/x402/go\"\n\tx402http \"github.com/coinbase/x402/go/http\"\n\tginmw \"github.com/coinbase/x402/go/http/gin\"\n\tevm \"github.com/coinbase/x402/go/mechanisms/evm/exact/server\"\n\tsvm \"github.com/coinbase/x402/go/mechanisms/svm/exact/server\"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/joho/godotenv\"\n)\n\nfunc main() {\n\tgodotenv.Load()\n\n\tevmAddress := os.Getenv(\"EVM_PAYEE_ADDRESS\")\n\tsvmAddress := os.Getenv(\"SVM_PAYEE_ADDRESS\")\n\tfacilitatorURL := os.Getenv(\"FACILITATOR_URL\")\n\n\tr := gin.Default()\n\n\tfacilitatorClient := x402http.NewHTTPFacilitatorClient(&x402http.FacilitatorConfig{\n\t\tURL: facilitatorURL,\n\t})\n\n\troutes := x402http.RoutesConfig{\n\t\t\"GET /weather\": {\n\t\t\tAccepts: x402http.PaymentOptions{\n\t\t\t\t{Scheme: \"exact\", Price: \"$0.001\", Network: \"eip155:84532\", PayTo: evmAddress},\n\t\t\t\t{Scheme: \"exact\", Price: \"$0.001\", Network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", PayTo: svmAddress},\n\t\t\t},\n\t\t\tDescription: \"Get weather data\",\n\t\t\tMimeType:    \"application/json\",\n\t\t},\n\t}\n\n\tr.Use(ginmw.X402Payment(ginmw.Config{\n\t\tRoutes:      routes,\n\t\tFacilitator: facilitatorClient,\n\t\tSchemes: []ginmw.SchemeConfig{\n\t\t\t{Network: \"eip155:84532\", Server: evm.NewExactEvmScheme()},\n\t\t\t{Network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", Server: svm.NewExactSvmScheme()},\n\t\t},\n\t\tTimeout: 30 * time.Second,\n\t}))\n\n\tr.GET(\"/weather\", func(c *gin.Context) {\n\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\t\"weather\":     \"sunny\",\n\t\t\t\"temperature\": 70,\n\t\t\t\"timestamp\":   time.Now().Format(time.RFC3339),\n\t\t})\n\t})\n\n\tr.GET(\"/health\", func(c *gin.Context) {\n\t\tc.JSON(http.StatusOK, gin.H{\"status\": \"ok\"})\n\t})\n\n\tr.Run(\":4021\")\n}"
      },
      {
        "title": "Paywall UI (Server Middleware)",
        "body": "The @x402/paywall package provides a pre-built paywall UI that displays when users hit a 402 Payment Required response. It handles wallet connection (MetaMask, Coinbase Wallet, Phantom, etc.), USDC balance checking, and payment submission.\n\nImportant: This package is designed for server-side use only. It generates a complete, self-contained HTML page (~1.9MB) with embedded React, wagmi, and wallet adapters that the server returns when a 402 response is triggered. It is not a standalone React component library and cannot be imported into an existing React application.\n\nLooking for React components instead?\n\nFor Solana React apps: Use @payai/x402-solana-react - drop-in paywall components with themes\nFor custom EVM/Solana React: Build with wagmi + viem (EVM) or @solana/wallet-adapter-react (Solana)\nMulti-chain SDKs: @dexterai/x402, x402-solana\n\nSee the Custom React Frontend Integration section below for details."
      },
      {
        "title": "Installation (Server-Side)",
        "body": "npm install @x402/paywall\n\nBundle sizes by import:\n\nImportSizeNetworks@x402/paywall3.5MBEVM + Solana@x402/paywall/evm3.4MBEVM only@x402/paywall/svm1.0MBSolana only"
      },
      {
        "title": "EVM Only",
        "body": "import { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withConfig({\n    appName: \"My App\",\n    appLogo: \"/logo.png\",\n    testnet: true,\n  })\n  .build();"
      },
      {
        "title": "Solana Only",
        "body": "import { createPaywall } from \"@x402/paywall\";\nimport { svmPaywall } from \"@x402/paywall/svm\";\n\nconst paywall = createPaywall()\n  .withNetwork(svmPaywall)\n  .withConfig({\n    appName: \"My Solana App\",\n    testnet: true,\n  })\n  .build();"
      },
      {
        "title": "Multi-Network",
        "body": "import { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\nimport { svmPaywall } from \"@x402/paywall/svm\";\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)  // First-match priority\n  .withNetwork(svmPaywall)  // Fallback option\n  .withConfig({\n    appName: \"Multi-chain App\",\n    testnet: true,\n  })\n  .build();"
      },
      {
        "title": "Configuration Options",
        "body": "interface PaywallConfig {\n  appName?: string;    // App name shown in wallet connection\n  appLogo?: string;    // App logo URL\n  currentUrl?: string; // URL of protected resource\n  testnet?: boolean;   // Use testnet (default: true)\n}"
      },
      {
        "title": "Integration with Express",
        "body": "import express from \"express\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/express\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\nimport { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\n\nconst app = express();\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: \"https://x402.org/facilitator\" });\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withConfig({ appName: \"My API\", testnet: true })\n  .build();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /premium\": {\n        accepts: [{ scheme: \"exact\", price: \"$0.01\", network: \"eip155:84532\", payTo: \"0x...\" }],\n        description: \"Premium content\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient).register(\"eip155:84532\", new ExactEvmScheme()),\n    undefined,  // paywallConfig (using custom paywall instead)\n    paywall,    // custom paywall provider\n  ),\n);\n\napp.get(\"/premium\", (req, res) => res.json({ content: \"Premium data\" }));\napp.listen(4021);"
      },
      {
        "title": "Auto-Detection (Simple Usage)",
        "body": "If you pass a paywallConfig object instead of a custom paywall, the middleware will automatically use @x402/paywall if installed:\n\napp.use(\n  paymentMiddleware(\n    routes,\n    server,\n    { appName: \"My App\", testnet: true },  // paywallConfig - auto-detects @x402/paywall\n  ),\n);"
      },
      {
        "title": "How First-Match Selection Works",
        "body": "When the server returns multiple payment options, the paywall selects the first one that has a registered handler:\n\n// Server returns:\n{ \"accepts\": [\n  { \"network\": \"solana:5eykt...\", ... },  // First option\n  { \"network\": \"eip155:8453\", ... }       // Second option\n]}\n\n// If both handlers registered, Solana is selected (first in accepts)\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withNetwork(svmPaywall)\n  .build();"
      },
      {
        "title": "Simple USD Pricing",
        "body": "{ scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress }"
      },
      {
        "title": "Custom Token Amount (ERC-20)",
        "body": "{\n  scheme: \"exact\",\n  price: {\n    amount: \"10000\",  // atomic units ($0.01 USDC = 10000 because USDC has 6 decimals)\n    asset: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",  // USDC on Base Sepolia\n    extra: { name: \"USDC\", version: \"2\" }  // EIP-712 params\n  },\n  network: \"eip155:84532\",\n  payTo: evmAddress\n}"
      },
      {
        "title": "Testing",
        "body": "For testing, use:\n\nNetwork: eip155:84532 (Base Sepolia) or solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 (Solana Devnet)\nFacilitator: https://x402.org/facilitator (testnet only)\nFaucets: Get testnet USDC from Base Sepolia faucet\n\nFor production, switch to mainnet networks and a production facilitator."
      }
    ],
    "body": "x402 Payment Protocol\n\nx402 is an open, internet-native payment standard built around the HTTP 402 Payment Required status code. It enables programmatic payments between clients and servers without accounts, sessions, or credential management.\n\nKey Benefits:\n\nZero protocol fees (only blockchain network fees)\nZero friction (no accounts or KYC required)\nInstant settlement via stablecoins\nWorks with AI agents and automated systems\n\nDocumentation: https://docs.x402.org | GitHub: https://github.com/coinbase/x402\n\nHow x402 Works\nClient requests a resource from a server\nServer responds with 402 Payment Required + payment instructions\nClient signs and submits a payment payload\nServer verifies payment, optionally via a facilitator\nServer returns the requested resource\nEnvironment Variables\nFor Buyers (Clients)\n# EVM wallet private key (Ethereum/Base/Polygon)\nEVM_PRIVATE_KEY=0x...\n\n# Solana wallet private key (base58 encoded)\nSVM_PRIVATE_KEY=...\n\n# Target server URL\nRESOURCE_SERVER_URL=http://localhost:4021\nENDPOINT_PATH=/weather\n\nFor Sellers (Servers)\n# Your EVM wallet address to receive payments\nEVM_ADDRESS=0x...\n\n# Your Solana wallet address to receive payments\nSVM_ADDRESS=...\n\n# Facilitator URL (see list below)\nFACILITATOR_URL=https://x402.org/facilitator\n\nNetwork Identifiers (CAIP-2)\nNetwork\tCAIP-2 ID\tDescription\nBase\t\t\nBase Mainnet\teip155:8453\tBase L2 mainnet\nBase Sepolia\teip155:84532\tBase L2 testnet\nSolana\t\t\nSolana Mainnet\tsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\tSolana mainnet\nSolana Devnet\tsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\tSolana testnet\nPolygon\t\t\nPolygon Mainnet\teip155:137\tPolygon PoS mainnet\nPolygon Amoy\teip155:80002\tPolygon testnet\nAvalanche\t\t\nAvalanche C-Chain\teip155:43114\tAvalanche mainnet\nAvalanche Fuji\teip155:43113\tAvalanche testnet\nSei\t\t\nSei Mainnet\teip155:1329\tSei EVM mainnet\nSei Testnet\teip155:713715\tSei EVM testnet\nX Layer\t\t\nX Layer Mainnet\teip155:196\tOKX L2 mainnet\nX Layer Testnet\teip155:1952\tOKX L2 testnet\nSKALE\t\t\nSKALE Base\teip155:1187947933\tSKALE mainnet\nSKALE Base Sepolia\teip155:324705682\tSKALE testnet\nFacilitators\n\nFacilitators handle payment verification and blockchain settlement. Choose one:\n\nName\tURL\tNotes\nx402.org\thttps://x402.org/facilitator\tDefault, testnet only\nCoinbase\thttps://api.cdp.coinbase.com/platform/v2/x402\tProduction\nPayAI\thttps://facilitator.payai.network\tProduction\nCorbits\thttps://facilitator.corbits.dev\tProduction\nx402rs\thttps://facilitator.x402.rs\tProduction\nDexter\thttps://x402.dexter.cash\tProduction\nHeurist\thttps://facilitator.heurist.xyz\tProduction\nKobaru\thttps://gateway.kobaru.io\tProduction\nMogami\thttps://facilitator.mogami.tech\tProduction\nNevermined\thttps://api.live.nevermined.app/api/v1/\tProduction\nOpenfacilitator\thttps://pay.openfacilitator.io\tProduction\nSolpay\thttps://x402.solpay.cash\tProduction\nPrimer\thttps://x402.primer.systems\tProduction\nxEcho\thttps://facilitator.xechoai.xyz\tProduction\nBuyer Examples (Client)\nTypeScript with fetch\n\nInstall dependencies:\n\nnpm install @x402/fetch @x402/evm @x402/svm viem @solana/kit @scure/base dotenv\n\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { x402Client, wrapFetchWithPayment, x402HTTPClient } from \"@x402/fetch\";\nimport { registerExactEvmScheme } from \"@x402/evm/exact/client\";\nimport { registerExactSvmScheme } from \"@x402/svm/exact/client\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createKeyPairSignerFromBytes } from \"@solana/kit\";\nimport { base58 } from \"@scure/base\";\n\nconfig();\n\nconst evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;\nconst svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;\nconst url = `${process.env.RESOURCE_SERVER_URL}${process.env.ENDPOINT_PATH}`;\n\nasync function main(): Promise<void> {\n  const evmSigner = privateKeyToAccount(evmPrivateKey);\n  const svmSigner = await createKeyPairSignerFromBytes(base58.decode(svmPrivateKey));\n\n  const client = new x402Client();\n  registerExactEvmScheme(client, { signer: evmSigner });\n  registerExactSvmScheme(client, { signer: svmSigner });\n\n  const fetchWithPayment = wrapFetchWithPayment(fetch, client);\n\n  const response = await fetchWithPayment(url, { method: \"GET\" });\n  const body = await response.json();\n  console.log(\"Response:\", body);\n\n  if (response.ok) {\n    const paymentResponse = new x402HTTPClient(client).getPaymentSettleResponse(\n      name => response.headers.get(name)\n    );\n    console.log(\"Payment:\", JSON.stringify(paymentResponse, null, 2));\n  }\n}\n\nmain().catch(console.error);\n\nTypeScript with axios\n\nInstall dependencies:\n\nnpm install @x402/axios @x402/evm @x402/svm axios viem @solana/kit @scure/base dotenv\n\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { x402Client, wrapAxiosWithPayment, x402HTTPClient } from \"@x402/axios\";\nimport { registerExactEvmScheme } from \"@x402/evm/exact/client\";\nimport { registerExactSvmScheme } from \"@x402/svm/exact/client\";\nimport { privateKeyToAccount } from \"viem/accounts\";\nimport { createKeyPairSignerFromBytes } from \"@solana/kit\";\nimport { base58 } from \"@scure/base\";\nimport axios from \"axios\";\n\nconfig();\n\nconst evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;\nconst svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;\nconst url = `${process.env.RESOURCE_SERVER_URL}${process.env.ENDPOINT_PATH}`;\n\nasync function main(): Promise<void> {\n  const evmSigner = privateKeyToAccount(evmPrivateKey);\n  const svmSigner = await createKeyPairSignerFromBytes(base58.decode(svmPrivateKey));\n\n  const client = new x402Client();\n  registerExactEvmScheme(client, { signer: evmSigner });\n  registerExactSvmScheme(client, { signer: svmSigner });\n\n  const api = wrapAxiosWithPayment(axios.create(), client);\n\n  const response = await api.get(url);\n  console.log(\"Response:\", response.data);\n\n  if (response.status < 400) {\n    const paymentResponse = new x402HTTPClient(client).getPaymentSettleResponse(\n      name => response.headers[name.toLowerCase()]\n    );\n    console.log(\"Payment:\", paymentResponse);\n  }\n}\n\nmain().catch(console.error);\n\nPython with httpx (async)\n\nInstall dependencies:\n\npip install \"x402[httpx,evm,svm]\" python-dotenv\n\n\nCode:\n\nimport asyncio\nimport os\nfrom dotenv import load_dotenv\nfrom eth_account import Account\n\nfrom x402 import x402Client\nfrom x402.http import x402HTTPClient\nfrom x402.http.clients import x402HttpxClient\nfrom x402.mechanisms.evm import EthAccountSigner\nfrom x402.mechanisms.evm.exact.register import register_exact_evm_client\nfrom x402.mechanisms.svm import KeypairSigner\nfrom x402.mechanisms.svm.exact.register import register_exact_svm_client\n\nload_dotenv()\n\nasync def main() -> None:\n    evm_private_key = os.getenv(\"EVM_PRIVATE_KEY\")\n    svm_private_key = os.getenv(\"SVM_PRIVATE_KEY\")\n    base_url = os.getenv(\"RESOURCE_SERVER_URL\")\n    endpoint_path = os.getenv(\"ENDPOINT_PATH\")\n\n    client = x402Client()\n\n    if evm_private_key:\n        account = Account.from_key(evm_private_key)\n        register_exact_evm_client(client, EthAccountSigner(account))\n\n    if svm_private_key:\n        svm_signer = KeypairSigner.from_base58(svm_private_key)\n        register_exact_svm_client(client, svm_signer)\n\n    http_client = x402HTTPClient(client)\n    url = f\"{base_url}{endpoint_path}\"\n\n    async with x402HttpxClient(client) as http:\n        response = await http.get(url)\n        await response.aread()\n        print(f\"Response: {response.text}\")\n\n        if response.is_success:\n            try:\n                settle_response = http_client.get_payment_settle_response(\n                    lambda name: response.headers.get(name)\n                )\n                print(f\"Payment: {settle_response.model_dump_json(indent=2)}\")\n            except ValueError:\n                print(\"No payment response header found\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\nPython with requests (sync)\n\nInstall dependencies:\n\npip install \"x402[requests,evm,svm]\" python-dotenv\n\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom eth_account import Account\n\nfrom x402 import x402ClientSync\nfrom x402.http import x402HTTPClientSync\nfrom x402.http.clients import x402_requests\nfrom x402.mechanisms.evm import EthAccountSigner\nfrom x402.mechanisms.evm.exact.register import register_exact_evm_client\nfrom x402.mechanisms.svm import KeypairSigner\nfrom x402.mechanisms.svm.exact.register import register_exact_svm_client\n\nload_dotenv()\n\ndef main() -> None:\n    evm_private_key = os.getenv(\"EVM_PRIVATE_KEY\")\n    svm_private_key = os.getenv(\"SVM_PRIVATE_KEY\")\n    base_url = os.getenv(\"RESOURCE_SERVER_URL\")\n    endpoint_path = os.getenv(\"ENDPOINT_PATH\")\n\n    client = x402ClientSync()\n\n    if evm_private_key:\n        account = Account.from_key(evm_private_key)\n        register_exact_evm_client(client, EthAccountSigner(account))\n\n    if svm_private_key:\n        svm_signer = KeypairSigner.from_base58(svm_private_key)\n        register_exact_svm_client(client, svm_signer)\n\n    http_client = x402HTTPClientSync(client)\n    url = f\"{base_url}{endpoint_path}\"\n\n    with x402_requests(client) as session:\n        response = session.get(url)\n        print(f\"Response: {response.text}\")\n\n        if response.ok:\n            try:\n                settle_response = http_client.get_payment_settle_response(\n                    lambda name: response.headers.get(name)\n                )\n                print(f\"Payment: {settle_response.model_dump_json(indent=2)}\")\n            except ValueError:\n                print(\"No payment response header found\")\n\nif __name__ == \"__main__\":\n    main()\n\nGo with net/http\n\nInstall dependencies:\n\ngo get github.com/coinbase/x402/go\ngo get github.com/joho/godotenv\n\n\nCode:\n\npackage main\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\tx402 \"github.com/coinbase/x402/go\"\n\t\"github.com/joho/godotenv\"\n)\n\nfunc main() {\n\tgodotenv.Load()\n\n\tevmPrivateKey := os.Getenv(\"EVM_PRIVATE_KEY\")\n\tsvmPrivateKey := os.Getenv(\"SVM_PRIVATE_KEY\")\n\turl := os.Getenv(\"SERVER_URL\")\n\tif url == \"\" {\n\t\turl = \"http://localhost:4021/weather\"\n\t}\n\n\t// Create x402 client with EVM and SVM support\n\tclient, err := x402.NewClientBuilder().\n\t\tWithEvmSigner(evmPrivateKey).\n\t\tWithSvmSigner(svmPrivateKey).\n\t\tBuild()\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to create client: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\n\t// Wrap HTTP client with payment handling\n\thttpClient := client.WrapHTTPClient(&http.Client{Timeout: 30 * time.Second})\n\n\tctx := context.Background()\n\treq, _ := http.NewRequestWithContext(ctx, \"GET\", url, nil)\n\tresp, err := httpClient.Do(req)\n\tif err != nil {\n\t\tfmt.Printf(\"Request failed: %v\\n\", err)\n\t\tos.Exit(1)\n\t}\n\tdefer resp.Body.Close()\n\n\tvar responseData interface{}\n\tjson.NewDecoder(resp.Body).Decode(&responseData)\n\tprettyJSON, _ := json.MarshalIndent(responseData, \"\", \"  \")\n\tfmt.Printf(\"Response: %s\\n\", string(prettyJSON))\n}\n\nSeller Examples (Server)\nTypeScript with Express\n\nInstall dependencies:\n\nnpm install express @x402/express @x402/core @x402/evm @x402/svm dotenv\n\n\nCode:\n\nimport { config } from \"dotenv\";\nimport express from \"express\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/express\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { ExactSvmScheme } from \"@x402/svm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\n\nconfig();\n\nconst evmAddress = process.env.EVM_ADDRESS as `0x${string}`;\nconst svmAddress = process.env.SVM_ADDRESS;\nconst facilitatorUrl = process.env.FACILITATOR_URL || \"https://x402.org/facilitator\";\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });\nconst app = express();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /weather\": {\n        accepts: [\n          { scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress },\n          { scheme: \"exact\", price: \"$0.001\", network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", payTo: svmAddress },\n        ],\n        description: \"Weather data\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient)\n      .register(\"eip155:84532\", new ExactEvmScheme())\n      .register(\"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", new ExactSvmScheme()),\n  ),\n);\n\napp.get(\"/weather\", (req, res) => {\n  res.send({ report: { weather: \"sunny\", temperature: 70 } });\n});\n\napp.listen(4021, () => console.log(\"Server listening at http://localhost:4021\"));\n\nTypeScript with Hono\n\nInstall dependencies:\n\nnpm install hono @hono/node-server @x402/hono @x402/core @x402/evm @x402/svm dotenv\n\n\nCode:\n\nimport { config } from \"dotenv\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/hono\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { ExactSvmScheme } from \"@x402/svm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\nimport { Hono } from \"hono\";\nimport { serve } from \"@hono/node-server\";\n\nconfig();\n\nconst evmAddress = process.env.EVM_ADDRESS as `0x${string}`;\nconst svmAddress = process.env.SVM_ADDRESS;\nconst facilitatorUrl = process.env.FACILITATOR_URL || \"https://x402.org/facilitator\";\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: facilitatorUrl });\nconst app = new Hono();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /weather\": {\n        accepts: [\n          { scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress },\n          { scheme: \"exact\", price: \"$0.001\", network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", payTo: svmAddress },\n        ],\n        description: \"Weather data\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient)\n      .register(\"eip155:84532\", new ExactEvmScheme())\n      .register(\"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", new ExactSvmScheme()),\n  ),\n);\n\napp.get(\"/weather\", c => c.json({ report: { weather: \"sunny\", temperature: 70 } }));\n\nserve({ fetch: app.fetch, port: 4021 });\nconsole.log(\"Server listening at http://localhost:4021\");\n\nPython with FastAPI\n\nInstall dependencies:\n\npip install \"x402[fastapi,evm,svm]\" python-dotenv uvicorn\n\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom fastapi import FastAPI\n\nfrom x402.http import FacilitatorConfig, HTTPFacilitatorClient, PaymentOption\nfrom x402.http.middleware.fastapi import PaymentMiddlewareASGI\nfrom x402.http.types import RouteConfig\nfrom x402.mechanisms.evm.exact import ExactEvmServerScheme\nfrom x402.mechanisms.svm.exact import ExactSvmServerScheme\nfrom x402.schemas import Network\nfrom x402.server import x402ResourceServer\n\nload_dotenv()\n\nEVM_ADDRESS = os.getenv(\"EVM_ADDRESS\")\nSVM_ADDRESS = os.getenv(\"SVM_ADDRESS\")\nEVM_NETWORK: Network = \"eip155:84532\"\nSVM_NETWORK: Network = \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\"\nFACILITATOR_URL = os.getenv(\"FACILITATOR_URL\", \"https://x402.org/facilitator\")\n\napp = FastAPI()\n\nfacilitator = HTTPFacilitatorClient(FacilitatorConfig(url=FACILITATOR_URL))\nserver = x402ResourceServer(facilitator)\nserver.register(EVM_NETWORK, ExactEvmServerScheme())\nserver.register(SVM_NETWORK, ExactSvmServerScheme())\n\nroutes = {\n    \"GET /weather\": RouteConfig(\n        accepts=[\n            PaymentOption(scheme=\"exact\", pay_to=EVM_ADDRESS, price=\"$0.01\", network=EVM_NETWORK),\n            PaymentOption(scheme=\"exact\", pay_to=SVM_ADDRESS, price=\"$0.01\", network=SVM_NETWORK),\n        ],\n        mime_type=\"application/json\",\n        description=\"Weather report\",\n    ),\n}\n\napp.add_middleware(PaymentMiddlewareASGI, routes=routes, server=server)\n\n@app.get(\"/health\")\nasync def health_check():\n    return {\"status\": \"ok\"}\n\n@app.get(\"/weather\")\nasync def get_weather():\n    return {\"report\": {\"weather\": \"sunny\", \"temperature\": 70}}\n\nif __name__ == \"__main__\":\n    import uvicorn\n    uvicorn.run(app, host=\"0.0.0.0\", port=4021)\n\nPython with Flask\n\nInstall dependencies:\n\npip install \"x402[flask,evm,svm]\" python-dotenv\n\n\nCode:\n\nimport os\nfrom dotenv import load_dotenv\nfrom flask import Flask, jsonify\n\nfrom x402.http import FacilitatorConfig, HTTPFacilitatorClientSync, PaymentOption\nfrom x402.http.middleware.flask import payment_middleware\nfrom x402.http.types import RouteConfig\nfrom x402.mechanisms.evm.exact import ExactEvmServerScheme\nfrom x402.mechanisms.svm.exact import ExactSvmServerScheme\nfrom x402.schemas import Network\nfrom x402.server import x402ResourceServerSync\n\nload_dotenv()\n\nEVM_ADDRESS = os.getenv(\"EVM_ADDRESS\")\nSVM_ADDRESS = os.getenv(\"SVM_ADDRESS\")\nEVM_NETWORK: Network = \"eip155:84532\"\nSVM_NETWORK: Network = \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\"\nFACILITATOR_URL = os.getenv(\"FACILITATOR_URL\", \"https://x402.org/facilitator\")\n\napp = Flask(__name__)\n\nfacilitator = HTTPFacilitatorClientSync(FacilitatorConfig(url=FACILITATOR_URL))\nserver = x402ResourceServerSync(facilitator)\nserver.register(EVM_NETWORK, ExactEvmServerScheme())\nserver.register(SVM_NETWORK, ExactSvmServerScheme())\n\nroutes = {\n    \"GET /weather\": RouteConfig(\n        accepts=[\n            PaymentOption(scheme=\"exact\", pay_to=EVM_ADDRESS, price=\"$0.01\", network=EVM_NETWORK),\n            PaymentOption(scheme=\"exact\", pay_to=SVM_ADDRESS, price=\"$0.01\", network=SVM_NETWORK),\n        ],\n        mime_type=\"application/json\",\n        description=\"Weather report\",\n    ),\n}\n\npayment_middleware(app, routes=routes, server=server)\n\n@app.route(\"/health\")\ndef health_check():\n    return jsonify({\"status\": \"ok\"})\n\n@app.route(\"/weather\")\ndef get_weather():\n    return jsonify({\"report\": {\"weather\": \"sunny\", \"temperature\": 70}})\n\nif __name__ == \"__main__\":\n    app.run(host=\"0.0.0.0\", port=4021)\n\nGo with Gin\n\nInstall dependencies:\n\ngo get github.com/coinbase/x402/go\ngo get github.com/gin-gonic/gin\ngo get github.com/joho/godotenv\n\n\nCode:\n\npackage main\n\nimport (\n\t\"net/http\"\n\t\"os\"\n\t\"time\"\n\n\tx402 \"github.com/coinbase/x402/go\"\n\tx402http \"github.com/coinbase/x402/go/http\"\n\tginmw \"github.com/coinbase/x402/go/http/gin\"\n\tevm \"github.com/coinbase/x402/go/mechanisms/evm/exact/server\"\n\tsvm \"github.com/coinbase/x402/go/mechanisms/svm/exact/server\"\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/joho/godotenv\"\n)\n\nfunc main() {\n\tgodotenv.Load()\n\n\tevmAddress := os.Getenv(\"EVM_PAYEE_ADDRESS\")\n\tsvmAddress := os.Getenv(\"SVM_PAYEE_ADDRESS\")\n\tfacilitatorURL := os.Getenv(\"FACILITATOR_URL\")\n\n\tr := gin.Default()\n\n\tfacilitatorClient := x402http.NewHTTPFacilitatorClient(&x402http.FacilitatorConfig{\n\t\tURL: facilitatorURL,\n\t})\n\n\troutes := x402http.RoutesConfig{\n\t\t\"GET /weather\": {\n\t\t\tAccepts: x402http.PaymentOptions{\n\t\t\t\t{Scheme: \"exact\", Price: \"$0.001\", Network: \"eip155:84532\", PayTo: evmAddress},\n\t\t\t\t{Scheme: \"exact\", Price: \"$0.001\", Network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", PayTo: svmAddress},\n\t\t\t},\n\t\t\tDescription: \"Get weather data\",\n\t\t\tMimeType:    \"application/json\",\n\t\t},\n\t}\n\n\tr.Use(ginmw.X402Payment(ginmw.Config{\n\t\tRoutes:      routes,\n\t\tFacilitator: facilitatorClient,\n\t\tSchemes: []ginmw.SchemeConfig{\n\t\t\t{Network: \"eip155:84532\", Server: evm.NewExactEvmScheme()},\n\t\t\t{Network: \"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1\", Server: svm.NewExactSvmScheme()},\n\t\t},\n\t\tTimeout: 30 * time.Second,\n\t}))\n\n\tr.GET(\"/weather\", func(c *gin.Context) {\n\t\tc.JSON(http.StatusOK, gin.H{\n\t\t\t\"weather\":     \"sunny\",\n\t\t\t\"temperature\": 70,\n\t\t\t\"timestamp\":   time.Now().Format(time.RFC3339),\n\t\t})\n\t})\n\n\tr.GET(\"/health\", func(c *gin.Context) {\n\t\tc.JSON(http.StatusOK, gin.H{\"status\": \"ok\"})\n\t})\n\n\tr.Run(\":4021\")\n}\n\nPaywall UI (Server Middleware)\n\nThe @x402/paywall package provides a pre-built paywall UI that displays when users hit a 402 Payment Required response. It handles wallet connection (MetaMask, Coinbase Wallet, Phantom, etc.), USDC balance checking, and payment submission.\n\nImportant: This package is designed for server-side use only. It generates a complete, self-contained HTML page (~1.9MB) with embedded React, wagmi, and wallet adapters that the server returns when a 402 response is triggered. It is not a standalone React component library and cannot be imported into an existing React application.\n\nLooking for React components instead?\n\nFor Solana React apps: Use @payai/x402-solana-react - drop-in paywall components with themes\nFor custom EVM/Solana React: Build with wagmi + viem (EVM) or @solana/wallet-adapter-react (Solana)\nMulti-chain SDKs: @dexterai/x402, x402-solana\n\nSee the Custom React Frontend Integration section below for details.\n\nInstallation (Server-Side)\nnpm install @x402/paywall\n\n\nBundle sizes by import:\n\nImport\tSize\tNetworks\n@x402/paywall\t3.5MB\tEVM + Solana\n@x402/paywall/evm\t3.4MB\tEVM only\n@x402/paywall/svm\t1.0MB\tSolana only\nUsage (Server Middleware)\nEVM Only\nimport { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withConfig({\n    appName: \"My App\",\n    appLogo: \"/logo.png\",\n    testnet: true,\n  })\n  .build();\n\nSolana Only\nimport { createPaywall } from \"@x402/paywall\";\nimport { svmPaywall } from \"@x402/paywall/svm\";\n\nconst paywall = createPaywall()\n  .withNetwork(svmPaywall)\n  .withConfig({\n    appName: \"My Solana App\",\n    testnet: true,\n  })\n  .build();\n\nMulti-Network\nimport { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\nimport { svmPaywall } from \"@x402/paywall/svm\";\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)  // First-match priority\n  .withNetwork(svmPaywall)  // Fallback option\n  .withConfig({\n    appName: \"Multi-chain App\",\n    testnet: true,\n  })\n  .build();\n\nConfiguration Options\ninterface PaywallConfig {\n  appName?: string;    // App name shown in wallet connection\n  appLogo?: string;    // App logo URL\n  currentUrl?: string; // URL of protected resource\n  testnet?: boolean;   // Use testnet (default: true)\n}\n\nIntegration with Express\nimport express from \"express\";\nimport { paymentMiddleware, x402ResourceServer } from \"@x402/express\";\nimport { ExactEvmScheme } from \"@x402/evm/exact/server\";\nimport { HTTPFacilitatorClient } from \"@x402/core/server\";\nimport { createPaywall } from \"@x402/paywall\";\nimport { evmPaywall } from \"@x402/paywall/evm\";\n\nconst app = express();\n\nconst facilitatorClient = new HTTPFacilitatorClient({ url: \"https://x402.org/facilitator\" });\n\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withConfig({ appName: \"My API\", testnet: true })\n  .build();\n\napp.use(\n  paymentMiddleware(\n    {\n      \"GET /premium\": {\n        accepts: [{ scheme: \"exact\", price: \"$0.01\", network: \"eip155:84532\", payTo: \"0x...\" }],\n        description: \"Premium content\",\n        mimeType: \"application/json\",\n      },\n    },\n    new x402ResourceServer(facilitatorClient).register(\"eip155:84532\", new ExactEvmScheme()),\n    undefined,  // paywallConfig (using custom paywall instead)\n    paywall,    // custom paywall provider\n  ),\n);\n\napp.get(\"/premium\", (req, res) => res.json({ content: \"Premium data\" }));\napp.listen(4021);\n\nAuto-Detection (Simple Usage)\n\nIf you pass a paywallConfig object instead of a custom paywall, the middleware will automatically use @x402/paywall if installed:\n\napp.use(\n  paymentMiddleware(\n    routes,\n    server,\n    { appName: \"My App\", testnet: true },  // paywallConfig - auto-detects @x402/paywall\n  ),\n);\n\nHow First-Match Selection Works\n\nWhen the server returns multiple payment options, the paywall selects the first one that has a registered handler:\n\n// Server returns:\n{ \"accepts\": [\n  { \"network\": \"solana:5eykt...\", ... },  // First option\n  { \"network\": \"eip155:8453\", ... }       // Second option\n]}\n\n// If both handlers registered, Solana is selected (first in accepts)\nconst paywall = createPaywall()\n  .withNetwork(evmPaywall)\n  .withNetwork(svmPaywall)\n  .build();\n\nPricing Configuration\nSimple USD Pricing\n{ scheme: \"exact\", price: \"$0.001\", network: \"eip155:84532\", payTo: evmAddress }\n\nCustom Token Amount (ERC-20)\n{\n  scheme: \"exact\",\n  price: {\n    amount: \"10000\",  // atomic units ($0.01 USDC = 10000 because USDC has 6 decimals)\n    asset: \"0x036CbD53842c5426634e7929541eC2318f3dCF7e\",  // USDC on Base Sepolia\n    extra: { name: \"USDC\", version: \"2\" }  // EIP-712 params\n  },\n  network: \"eip155:84532\",\n  payTo: evmAddress\n}\n\nTesting\n\nFor testing, use:\n\nNetwork: eip155:84532 (Base Sepolia) or solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 (Solana Devnet)\nFacilitator: https://x402.org/facilitator (testnet only)\nFaucets: Get testnet USDC from Base Sepolia faucet\n\nFor production, switch to mainnet networks and a production facilitator."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/notorious-d-e-v/x402-enhanced",
    "publisherUrl": "https://clawhub.ai/notorious-d-e-v/x402-enhanced",
    "owner": "notorious-d-e-v",
    "version": "1.0.1",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/x402-enhanced",
    "downloadUrl": "https://openagent3.xyz/downloads/x402-enhanced",
    "agentUrl": "https://openagent3.xyz/skills/x402-enhanced/agent",
    "manifestUrl": "https://openagent3.xyz/skills/x402-enhanced/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/x402-enhanced/agent.md"
  }
}