Use @circle-fin/app-kit
to swap USDC for EURC on Arc Testnet with a browser wallet and the viem
adapter.
This Vite + TypeScript page connects an EIP-6963 wallet (for example MetaMask),
creates a Circle adapter from the provider, then calls swap().
- Node.js 22 or later
- An EIP-6963 browser wallet such as MetaMask
- Testnet USDC on Arc Testnet
- Native gas token on Arc Testnet for the wallet transaction
This project does not require environment variables or API keys.
npm install
npm run devOpen the local Vite URL in a browser with your wallet installed.
npm run build- Discovers an EIP-6963 browser wallet and requests account access.
- Creates a viem adapter with
createViemAdapterFromProvider(). - Swaps 1 USDC for EURC on
Arc_Testnetwithkit.swap().
Arc Testnet pools are often thin or imbalanced. Failures here are usually the environment, not your integration.
- No route available — no quote for that pair/amount; try a smaller
amountIn, flip the direction (EURC→USDCoften has more depth), or retry later. - On-chain simulation failed — quote existed but slippage/minimum output
could not be met; lower
amountInor raiseconfig.slippageBpsabove the default300(3%).
Browser swaps need the wallet to broadcast approve (if needed) then the swap tx. If MetaMask (or another wallet) shows Pending forever and the tx hash is not on Arcscan:
- The wallet’s Arc Testnet RPC likely failed to broadcast — fix or replace the network RPC in the wallet settings.
- Clear stuck local activity (MetaMask: Settings → Advanced → Clear activity tab data / Reset account) so a phantom pending does not block the next prompt.
- Confirm you are on Arc Testnet with USDC/EURC and native gas, then retry. Another EIP-6963 wallet can work if one wallet’s RPC is bad; this example prefers MetaMask when both are installed.
A custodial / Circle Wallets script can succeed while a browser wallet stalls for the same route — that points at wallet RPC/queue, not App Kit.
src/main.ts— wallet connect, adapter creation, and swap. Changechain,tokenIn/tokenOut, andamountInin the swap params for a different chain, pair, or amount.