This quickstart walks you through how to use App Kit’s Swap capability to swap tokens on the same blockchain. The example swaps USDC for EURC on Arc Testnet, but you can use other supported tokens or blockchains.Documentation Index
Fetch the complete documentation index at: https://docs.arc.network/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22+.
- Created an EVM wallet using a wallet provider such as MetaMask and added Arc Testnet.
- Funded the wallet with testnet USDC and native tokens for fees from the Circle Faucet.
- Obtained a (free) kit key from Circle Console.
Step 1. Set up the project
This step shows you how to prepare your project and environment.1.1. Set up your development environment
Create a new directory and install App Kit and its dependencies:Shell
1.2. Configure TypeScript (optional)
This step is optional. It helps prevent missing types in your IDE or editor.
tsconfig.json file:
Shell
tsconfig.json file:
Shell
1.3. Configure environment variables
Create an.env file in the project directory:
Shell
YOUR_PRIVATE_KEY with the private key for
your wallet and YOUR_KIT_KEY with the kit key from
Circle Console:
.env
Step 2. Perform the swap
This step shows you how to set up your script, execute a swap from USDC to EURC on Arc Testnet, and check the result.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 on Arc Testnet:
Using other tokens
or a different blockchain? Change
the
tokenIn, tokenOut, and chain values in kit.swap() and use an adapter
for that chain.TypeScript
2.2. Run the script
Save theindex.ts file and run the script in your terminal:
Shell
2.3. Verify the transaction
After the script finishes, find the returned result object in the terminal output. Use theexplorerUrl to verify the swap transaction and confirm the
amount matches how much EURC was received.
The following code is an example of how the result of a successful swap might
look in the terminal output. The values are used in this example only and are
not a real transaction:
Shell