If your Circle Wallet is a smart contract account (SCA), set
allowanceStrategy: "approve". USDC permit signatures use ecrecover, which
does not accept the SCA’s ERC-1271 signature, so the SDK uses an onchain
approve.Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22+.
- Obtained the following from the
Circle Console:
- API Key
- Entity secret
- Kit key (optional): recommended for production or high-volume usage
- Created a developer-controlled wallet on Arc Testnet.
- Funded your Arc Testnet wallet with enough testnet USDC for the swap amount and transaction fees from the Circle Faucet.
Step 1. Set up the project
1.1. Create the project and install dependencies
Create a project directory, initialize a Node.js project with an ES module type and start script, then install runtime and dev dependencies:Shell
1.2. Configure TypeScript (optional)
This step is optional. It helps prevent missing types in your IDE or editor.
tsconfig.json file configured for ESM and Node:
Shell
1.3. Set environment variables
Create an.env file in the project directory:
Shell
YOUR_API_KEY with your Circle
Developer API key and YOUR_ENTITY_SECRET with your entity secret. If you have
a kit key, add it as KIT_KEY—it is optional but recommended for production and
high-volume usage to avoid rate limits:
.env
Step 2. Swap tokens
2.1. Create the script
Create anindex.ts file in the project directory and add the following code.
This code swaps 1.00 USDC for EURC from your Circle Wallets-controlled Arc
Testnet wallet. Replace YOUR_SOURCE_WALLET_ADDRESS with the wallet address
from the
Circle Developer Console
or the
list wallets
endpoint:
Using another
token pair or
blockchain? Change the
tokenIn,
tokenOut, and chain values in swapParams and ensure the source wallet has
enough input tokens and gas.TypeScript
2.2. Run the script
Save theindex.ts file and run the script in your terminal:
Shell
Arc Testnet swap liquidity can be unstable. If a simulation reverts or a quote
looks far from the expected rate, the testnet pool may be imbalanced or low on
liquidity. Mainnet pools are typically deeper, but execution still depends on
pool conditions, trade size, and slippage.