|
1 | | -# Circle Gateway Multichain USDC |
| 1 | +# Arc Commerce |
2 | 2 |
|
3 | | -This sample app demonstrates how to integrate USDC as a payment method for purchasing credits on Arc. |
| 3 | +This project demonstrates how to integrate USDC as a payment method for purchasing credits on Arc. |
4 | 4 |
|
5 | | -### Install dependencies |
| 5 | +## Table of Contents |
6 | 6 |
|
7 | | -```bash |
8 | | -# Install dependencies |
9 | | -pnpm install |
| 7 | +- [Clone and Run Locally](#clone-and-run-locally) |
| 8 | +- [Environment Variables](#environment-variables) |
10 | 9 |
|
11 | | -# Configure environment variables |
12 | | -cp .env.example .env.local |
13 | | -``` |
| 10 | +## Clone and Run Locally |
14 | 11 |
|
15 | | -Update `.env.local`: |
| 12 | +1. **Clone and install dependencies:** |
16 | 13 |
|
17 | | -```ini |
18 | | -# Supabase |
19 | | -NEXT_PUBLIC_SUPABASE_URL=your-project-url |
20 | | -NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-publishable-or-anon-key |
| 14 | + ```bash |
| 15 | + git clone git@github.com:circlefin/arc-commerce.git |
| 16 | + cd top-up |
| 17 | + npm install |
| 18 | + ``` |
21 | 19 |
|
22 | | -# Circle |
23 | | -CIRCLE_API_KEY=your-circle-api-key |
24 | | -CIRCLE_ENTITY_SECRET=your-circle-entity-secret |
25 | | -``` |
| 20 | +2. **Set up environment variables:** |
26 | 21 |
|
27 | | -### Start Supabase |
| 22 | + ```bash |
| 23 | + cp .env.example .env.local |
| 24 | + ``` |
28 | 25 |
|
29 | | -```bash |
30 | | -pnpx supabase start |
31 | | -``` |
| 26 | + Then edit `.env.local` and fill in all required values (see [Environment Variables](#environment-variables) section below). |
32 | 27 |
|
33 | | -### Run Development Server |
| 28 | +3. **Start Supabase locally** (requires Docker): |
34 | 29 |
|
35 | | -```bash |
36 | | -pnpm run dev |
37 | | -``` |
| 30 | + ```bash |
| 31 | + npx supabase start |
| 32 | + npx supabase migration up |
| 33 | + ``` |
38 | 34 |
|
39 | | -Visit [http://localhost:3000/wallet](http://localhost:3000/wallet) |
| 35 | +4. **Start the development server:** |
40 | 36 |
|
41 | | -## How It Works |
| 37 | + ```bash |
| 38 | + npm run dev |
| 39 | + ``` |
42 | 40 |
|
43 | | -### Unified Balance |
| 41 | + The app will be available at [http://localhost:3000](http://localhost:3000/). The admin wallet will be automatically created on first startup. |
44 | 42 |
|
45 | | -When you deposit USDC to the Gateway Wallet, it becomes part of your unified balance accessible from any supported chain. The Gateway Wallet uses the same address on all chains: `0x0077777d7EBA4688BDeF3E311b846F25870A19B9` |
| 43 | +5. **Set up Circle Webhooks:** |
46 | 44 |
|
47 | | -### Deposit Flow |
| 45 | + In a separate terminal, start ngrok to expose your local server: |
48 | 46 |
|
49 | | -1. Approve Gateway Wallet to spend your USDC |
50 | | -2. Call `deposit()` to transfer USDC to Gateway |
51 | | -3. Balance becomes available across all chains after finalization |
| 47 | + ```bash |
| 48 | + ngrok http 3000 |
| 49 | + ``` |
52 | 50 |
|
53 | | -### Cross-Chain Transfer Flow |
| 51 | + Copy the HTTPS URL from ngrok (e.g., `https://your-ngrok-url.ngrok.io`) and add it to your Circle Console webhooks section: |
| 52 | + - Navigate to Circle Console → Webhooks |
| 53 | + - Add a new webhook endpoint: `https://your-ngrok-url.ngrok.io/api/circle/webhook` |
| 54 | + - Keep ngrok running while developing to receive webhook events |
54 | 55 |
|
55 | | -1. Create and sign burn intent (EIP-712) |
56 | | -2. Submit to Gateway API for attestation |
57 | | -3. Call `gatewayMint()` on destination chain |
58 | | -4. USDC minted on destination |
| 56 | +## Environment Variables |
59 | 57 |
|
60 | | -## Security Notes |
| 58 | +Copy `.env.example` to `.env.local` and fill in the required values: |
61 | 59 |
|
62 | | -- This is a **testnet demonstration** only |
63 | | -- Private keys are processed server-side and never stored |
64 | | -- Never use mainnet private keys with this application |
65 | | -- Always use HTTPS in production |
66 | | -- Consider hardware wallet integration for production use |
| 60 | +```bash |
| 61 | +# Supabase |
| 62 | +NEXT_PUBLIC_SUPABASE_URL= |
| 63 | +NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY= |
| 64 | +SUPABASE_SERVICE_ROLE_KEY= |
67 | 65 |
|
68 | | -## Resources |
| 66 | +# Circle |
| 67 | +CIRCLE_API_KEY= |
| 68 | +CIRCLE_ENTITY_SECRET= |
| 69 | +CIRCLE_BLOCKCHAIN=ARC-TESTNET |
| 70 | +CIRCLE_USDC_TOKEN_ID= |
| 71 | + |
| 72 | +# Misc |
| 73 | +ADMIN_EMAIL=admin@admin.com |
| 74 | +``` |
69 | 75 |
|
70 | | -- [Circle Gateway Documentation](https://developers.circle.com/gateway) |
71 | | -- [Unified Balance Guide](https://developers.circle.com/gateway/howtos/create-unified-usdc-balance) |
72 | | -- [Circle Faucet](https://faucet.circle.com/) |
| 76 | +| Variable | Scope | Purpose | |
| 77 | +| ------------------------------------- | ----------- | ------------------------------------------------------------------------ | |
| 78 | +| `NEXT_PUBLIC_SUPABASE_URL` | Public | Supabase project URL. | |
| 79 | +| `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_OR_ANON_KEY` | Public | Supabase anonymous/public key. | |
| 80 | +| `SUPABASE_SERVICE_ROLE_KEY` | Server-side | Service role for privileged writes (e.g., transaction inserts). | |
| 81 | +| `CIRCLE_API_KEY` | Server-side | Used to fetch Circle webhook public keys for signature verification. | |
| 82 | +| `CIRCLE_ENTITY_SECRET` | Server-side | Circle entity secret for wallet operations. | |
| 83 | +| `CIRCLE_BLOCKCHAIN` | Server-side | Blockchain network identifier (e.g., "ARC-TESTNET"). | |
| 84 | +| `CIRCLE_USDC_TOKEN_ID` | Server-side | USDC token ID for the specified blockchain. | |
| 85 | +| `ADMIN_EMAIL` | Server-side | Admin user email address. | |
0 commit comments