{"id":48648408,"url":"https://github.com/circlefin/arc-nanopayments","last_synced_at":"2026-04-10T08:16:54.912Z","repository":{"id":349170121,"uuid":"1201237798","full_name":"circlefin/arc-nanopayments","owner":"circlefin","description":"This sample app demonstrates gasless USDC nanopayments using Circle Nanopayments on Arc.","archived":false,"fork":false,"pushed_at":"2026-04-04T14:33:52.000Z","size":556,"stargazers_count":0,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-04T16:54:57.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/circlefin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-04T11:59:51.000Z","updated_at":"2026-04-04T14:32:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/circlefin/arc-nanopayments","commit_stats":null,"previous_names":["circlefin/arc-nanopayments"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/circlefin/arc-nanopayments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circlefin%2Farc-nanopayments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circlefin%2Farc-nanopayments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circlefin%2Farc-nanopayments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circlefin%2Farc-nanopayments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/circlefin","download_url":"https://codeload.github.com/circlefin/arc-nanopayments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circlefin%2Farc-nanopayments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31634330,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-10T08:16:54.221Z","updated_at":"2026-04-10T08:16:54.904Z","avatar_url":"https://github.com/circlefin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arc Nanopayments Demo\n\nDemonstrate gasless USDC nanopayments using [Circle Nanopayments](https://www.circle.com/nanopayments) on Arc. A **LangChain agent** acts as the buyer, autonomously paying for paywalled resources, while a **Next.js web app** acts as the seller, exposing x402-protected endpoints and providing a seller dashboard to monitor payments and withdraw earnings.\n\nCircle Gateway batches many signed offchain authorizations into a single onchain settlement, enabling economically viable sub-cent payments.\n\n\u003cimg alt=\"Arc Nanopayments Demo dashboard\" src=\"public/screenshot.png\" /\u003e\n\n## Table of Contents\n\n- [Prerequisites](#prerequisites)\n- [Getting Started](#getting-started)\n- [How It Works](#how-it-works)\n- [Paywalled Endpoints](#paywalled-endpoints)\n- [Seller Dashboard](#seller-dashboard)\n- [Environment Variables](#environment-variables)\n- [Demo Credentials](#demo-credentials)\n\n## Prerequisites\n\n- **Node.js v22+** — Install via [nvm](https://github.com/nvm-sh/nvm)\n- **Supabase CLI** — Install via `npm install -g supabase` or see [Supabase CLI docs](https://supabase.com/docs/guides/cli/getting-started)\n- **Docker Desktop** (only if using the local Supabase path) — [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)\n- *(Optional)* An **[OpenAI API key](https://platform.openai.com/api-keys)** — enables the LLM-driven payment agent. Without it, the agent runs in mock mode with scripted tool calls.\n\n## Getting Started\n\n1. Clone the repository and install dependencies:\n\n   ```bash\n   git clone https://github.com/akelani-circle/arc-nanopayments-demo.git\n   cd arc-nanopayments-demo\n   npm install\n   ```\n\n2. Set up environment variables:\n\n   ```bash\n   cp .env.example .env.local\n   ```\n\n   Then edit `.env.local` and fill in all required values (see [Environment Variables](#environment-variables) section below).\n\n3. Generate seller and buyer wallets:\n\n   ```bash\n   npm run generate-wallets\n   ```\n\n   This creates two EVM wallets (seller and buyer) and writes the addresses and private keys to `.env.local`. Follow the on-screen instructions to fund the buyer wallet with testnet USDC via the [Circle faucet](https://faucet.circle.com/).\n\n4. Set up the database — Choose one of the two paths below:\n\n   \u003cdetails\u003e\n   \u003csummary\u003e\u003cstrong\u003ePath 1: Local Supabase (Docker)\u003c/strong\u003e\u003c/summary\u003e\n\n   Requires Docker Desktop installed and running.\n\n   ```bash\n   npx supabase start\n   npx supabase migration up\n   ```\n\n   The output of `npx supabase start` will display the Supabase URL and API keys needed for your `.env.local`.\n\n   \u003c/details\u003e\n\n   \u003cdetails\u003e\n   \u003csummary\u003e\u003cstrong\u003ePath 2: Remote Supabase (Cloud)\u003c/strong\u003e\u003c/summary\u003e\n\n   Requires a [Supabase](https://supabase.com/) account and project.\n\n   ```bash\n   npx supabase link --project-ref \u003cyour-project-ref\u003e\n   npx supabase db push\n   ```\n\n   Retrieve your project URL and API keys from the Supabase dashboard under **Settings \u003e API**.\n\n   \u003c/details\u003e\n\n5. Start the development server:\n\n   ```bash\n   npm run dev\n   ```\n\n   The app will be available at `http://localhost:3000`.\n\n6. Run the AI payment agent:\n\n   ```bash\n   npm run agent\n   ```\n\n   The agent uses the buyer wallet to purchase resources from the x402-protected premium endpoints, paying with USDC on the Arc Testnet. If `OPENAI_API_KEY` is set, the agent uses the LLM to decide which tools to call; otherwise it falls back to a scripted mock run. You can optionally pass a custom query:\n\n   ```bash\n   npm run agent -- \"Buy me a quote at http://localhost:3000/api/premium/quote\"\n   ```\n\n   To set a USDC spending limit, use the `--limit` flag. The agent will pause when the limit is reached and prompt for additional allowance:\n\n   ```bash\n   npm run agent -- --limit 0.5\n   ```\n\n## How It Works\n\n- Built with [Next.js](https://nextjs.org/) App Router and [Supabase](https://supabase.com/)\n- Uses the [x402 protocol](https://www.x402.org/) for HTTP 402 nanopayments with USDC on the [Arc Network](https://arc.circle.com/)\n- Uses [Circle's x402 batching SDK](https://www.npmjs.com/package/@circle-fin/x402-batching) (`GatewayClient`) for gasless payment facilitation\n- Includes an AI payment agent built with [LangChain](https://js.langchain.com/) and [Deep Agents](https://www.npmjs.com/package/deepagents) that can check balances, deposit USDC into Gateway, verify endpoint support, and autonomously pay for x402-protected resources\n- Seller dashboard with real-time payment monitoring, Gateway balance display, and cross-chain withdrawal support\n- Payment events and withdrawals are persisted to Supabase with real-time subscriptions\n- Styled with [Tailwind CSS](https://tailwindcss.com) and components from [shadcn/ui](https://ui.shadcn.com/)\n\n## Paywalled Endpoints\n\nThe seller exposes several x402-protected API routes at different price points:\n\n| Endpoint | Method | Price (USDC) | Description |\n| --- | --- | --- | --- |\n| `/api/premium/quote` | GET | $0.001 | Returns a premium inspirational quote |\n| `/api/premium/dataset` | GET | $0.01 | Returns a small JSON analytics dataset |\n| `/api/premium/compute` | POST | $0.0003 | Performs text analysis on submitted content |\n| `/api/premium/agent-task` | GET | $0.03 | Returns a clue/step for a treasure hunt task |\n\nEach endpoint returns `402 Payment Required` for unpaid requests. The buyer agent automatically signs the authorization and retries with the payment signature to receive the content.\n\n## Seller Dashboard\n\nThe dashboard at `/dashboard` provides:\n\n- **Gateway Balance** — Top-bar badge showing the seller's available Gateway balance, with a detail dialog for total, withdrawing, withdrawable, and wallet USDC balances\n- **Payments Table** — Real-time list of incoming nanopayments with filtering and sorting, linked to [Arc Testnet Explorer](https://testnet.arcscan.app)\n- **Withdraw Dialog** — Withdraw available USDC from Gateway to a wallet address on any supported testnet chain (Arc Testnet, Base Sepolia, Ethereum Sepolia, Arbitrum Sepolia, Optimism Sepolia, Avalanche Fuji, Polygon Amoy)\n\n## Environment Variables\n\nCopy `.env.example` to `.env.local` and fill in the required values:\n\n```bash\n# Supabase\nNEXT_PUBLIC_SUPABASE_URL=your-project-url\nNEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-publishable-or-anon-key\nSUPABASE_SERVICE_ROLE_KEY=your-service-role-key\n\n# x402 / Circle Nanopayments\nSELLER_ADDRESS=0xYourWalletAddress\nSELLER_PRIVATE_KEY=0xYourSellerPrivateKey\n\n# Buyer wallet (for the payment agent)\nBUYER_ADDRESS=0xYourBuyerWalletAddress\nBUYER_PRIVATE_KEY=0xYourBuyerPrivateKey\n\n# AI Payment Agent (optional — omit to run in mock mode)\n# OPENAI_API_KEY=your-openai-api-key\n```\n\n| Variable | Scope | Purpose |\n| --- | --- | --- |\n| `NEXT_PUBLIC_SUPABASE_URL` | Public | Supabase project URL. |\n| `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` | Public | Supabase anonymous / publishable key. |\n| `SUPABASE_SERVICE_ROLE_KEY` | Server-side | Supabase service-role key, used to record payment events and withdrawals. |\n| `SELLER_ADDRESS` | Server-side | EVM wallet address for receiving USDC payments. |\n| `SELLER_PRIVATE_KEY` | Server-side | Seller wallet private key, used for Gateway balance queries and withdrawals. |\n| `BUYER_ADDRESS` | Agent | Buyer wallet address for making payments. |\n| `BUYER_PRIVATE_KEY` | Agent | Buyer wallet private key for signing payment authorizations. |\n| `OPENAI_API_KEY` | Agent | *(Optional)* OpenAI API key. If omitted, the agent runs in mock mode with scripted tool calls. |\n\n\u003e **Tip:** Run `npm run generate-wallets` to auto-generate the `SELLER_ADDRESS`, `SELLER_PRIVATE_KEY`, `BUYER_ADDRESS`, and `BUYER_PRIVATE_KEY` values.\n\n## Demo Credentials\n\nThe app uses a hardcoded demo account for local development:\n\n| Email | Password |\n| --- | --- |\n| `admin@example.com` | `123456` |\n\n## Security \u0026 Usage Model\n\nThis sample application:\n- Assumes testnet usage only\n- Handles secrets via environment variables\n- Is not intended for production use without modification\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirclefin%2Farc-nanopayments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcirclefin%2Farc-nanopayments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirclefin%2Farc-nanopayments/lists"}