|
1 | 1 | # arc-stablecoin-fx |
2 | | -This sample app demonstrates stablecoin FX swaps between USDC and EURC using the App Kit Swap SDK on Arc. |
| 2 | + |
| 3 | +This sample app demonstrates stablecoin FX swaps between USDC and EURC using the App Kits Swap SDK and Circle Developer Controlled Wallets on Arc. |
| 4 | + |
| 5 | +<img alt="Arc Stablecoin Fx" src="public/screenshot.png" /> |
| 6 | + |
| 7 | +## Getting started |
| 8 | + |
| 9 | +### Prerequisites |
| 10 | + |
| 11 | +- Node.js 20+ and npm |
| 12 | +- Docker (for local Supabase) |
| 13 | +- A [Circle](https://console.circle.com) account with API key + entity secret |
| 14 | +- A Circle App Kit `KIT_KEY` |
| 15 | + |
| 16 | +### 1. Install dependencies |
| 17 | + |
| 18 | +```sh |
| 19 | +npm install |
| 20 | +``` |
| 21 | + |
| 22 | +### 2. Start the local Supabase stack |
| 23 | + |
| 24 | +```sh |
| 25 | +npm run db:start |
| 26 | +``` |
| 27 | + |
| 28 | +This boots Postgres, Auth, etc. via the Supabase CLI and runs the migrations in |
| 29 | +`supabase/migrations/`. Use `npm run db:status` to print the local URLs and keys, |
| 30 | +`npm run db:reset` to wipe + re-migrate, and `npm run db:stop` to shut it down. |
| 31 | + |
| 32 | +### 3. Configure environment |
| 33 | + |
| 34 | +Copy the example file and fill in the blanks: |
| 35 | + |
| 36 | +```sh |
| 37 | +cp .env.example .env.local |
| 38 | +``` |
| 39 | + |
| 40 | +- `NEXT_PUBLIC_SUPABASE_URL` / `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` / |
| 41 | + `SUPABASE_SECRET_KEY` - from `npm run db:status`. |
| 42 | +- `CIRCLE_API_KEY` - from the Circle console. |
| 43 | +- `CIRCLE_ENTITY_SECRET` - your 32-byte hex entity secret. Must be registered |
| 44 | + with Circle once before use. |
| 45 | +- `CIRCLE_BLOCKCHAIN` - Circle blockchain identifier (default `ARC-TESTNET`). |
| 46 | +- `KIT_KEY` - Circle App Kit key. |
| 47 | +- `NEXT_PUBLIC_ARC_CHAIN` - App Kit chain identifier (default `Arc_Testnet`). |
| 48 | +- `APP_FEE_BPS` - platform fee in basis points (default `25` = 0.25%). |
| 49 | +- `APP_FEE_RECIPIENT` - leave blank, then run the script below. |
| 50 | + |
| 51 | +### 4. Provision the platform fee wallet |
| 52 | + |
| 53 | +Creates a Circle wallet to receive swap fees and writes its address back to |
| 54 | +`.env.local` as `APP_FEE_RECIPIENT`: |
| 55 | + |
| 56 | +```sh |
| 57 | +npm run wallet:generate |
| 58 | +``` |
| 59 | + |
| 60 | +### 5. Run the dev server |
| 61 | + |
| 62 | +```sh |
| 63 | +npm run dev |
| 64 | +``` |
| 65 | + |
| 66 | +App is at http://localhost:3000. |
| 67 | + |
| 68 | +## Project layout |
| 69 | + |
| 70 | +- `src/app/(auth)/` - register / login flows |
| 71 | +- `src/app/(app)/dashboard/` - authenticated swap panel |
| 72 | +- `src/app/(app)/dashboard/history/` - trades history |
| 73 | +- `src/app/api/webhooks/circle/` - Circle webhook receiver |
| 74 | +- `src/components/swap/`, `src/components/trades/`, `src/components/wallet/` - feature UI |
| 75 | +- `src/lib/circle/`, `src/lib/appkit/` - Circle wallets + App Kit integration |
| 76 | +- `src/lib/supabase/` - Supabase client/server/admin helpers |
| 77 | +- `supabase/migrations/` - database schema |
| 78 | +- `scripts/` - one-off operator scripts |
0 commit comments