Prerequisites
Before you begin, make sure you have:- Installed Node.js v22+ and npm.
- A Circle Developer Console account
- An API key created in the Console:
Keys → Create a key → API key → Standard Key - Your Entity Secret registered for your wallet (you need it for the script below)
Step 1: Set up your project
In this step, you prepare your project and environment.1.1. Create a new project
Create a new directory, navigate to it and initialize a new project.1.2. Initialize and configure the project
This command creates atsconfig.json file:
tsconfig.json file:
1.3 Configure environment variables
Create a.env file in the project directory with your Circle credentials,
replacing these placeholders with your own credentials:
CIRCLE_API_KEY: your API key should be either environment-prefixed (for example,TEST_API_KEY:abc123:def456orLIVE_API_KEY:xyz:uvw) or base64-encoded strings.CIRCLE_ENTITY_SECRET: your entity secret should be 64 lowercase alphanumeric characters.
Step 2: Set up your wallets
In this step, you create dev-controlled wallets and fund them with USDC and native tokens to make a deposit into a unified Gateway balance. If you already have funded dev-controlled wallets, skip to Step 3.2.1. Create wallets on supported chains
Import the Circle Wallets SDK and initialize the client using your API key and Entity Secret. Dev-controlled wallets are created in a wallet set, which serves as the source from which individual wallet keys are derived.If you supply a
refId, all EVM wallets sharing that refId in the function
call will have the same
address.
Having the same address across all the blockchains makes it more
straightforward when depositing funds with the deposit
function.If you’re calling the API directly, you’ll need
to make two requests: one to create the wallet set; one to create the wallet.Be sure to replace the
Entity Secret ciphertext
and the idempotency key in your request. If you’re using the SDKs, this is
handled automatically for you.
2.2. Add testnet funds to your wallet
To interact with Gateway, you need test USDC and native tokens in your wallet on each chain you deposit from. You also need testnet native tokens on the destination chain to call the Gateway Minter contract. Use the Circle Faucet to get testnet USDC and the Console Faucet to get testnet native tokens. In addition, the following faucets can also be used to fund your wallet with testnet native tokens:- Arc
- Avalanche
- Base
- Ethereum
Faucet: Arc Testnet (USDC + native tokens)
| Property | Value |
|---|---|
| Chain name | arcTestnet |
| USDC address | 0x3600000000000000000000000000000000000000 |
| Domain ID | 26 |
2.3. Check wallet balances
You can check your wallet balances from the Circle Developer Console or programmatically by making a request to GET /wallets/{id}/balances with the specified wallet ID.Step 3: Deposit into a unified crosschain balance
In this step, you review each part of the script to deposit USDC into the Gateway Wallet contracts. You can skip to the full deposit script if you prefer.3.1. Create the script file
3.2. Define chain configuration
3.3. Define constants
3.4. Add helper functions
3.5. Approve and deposit USDC
The main logic performs two key actions:- Approve USDC transfers: It calls the
approvemethod on the USDC contract to allow the Gateway Wallet contract to transfer USDC from your wallet. - Deposit USDC into Gateway: After receiving the approval transaction hash,
it calls the
depositmethod on the Gateway Wallet contract.
Important: You must call the
deposit method, not the standard transfer
function on the USDC contract. Deposits into the Gateway Wallet only work
through the designated deposit function.3.6. Full deposit script
Now that you’ve completed the setup and core steps, this full script brings everything together. It deposits 2 USDC from the specified chain into your Gateway balance. The script includes inline comments to explain what each function does, making it easier to follow and modify if needed.3.7. Run the script to create a crosschain balance
Run thedeposit.ts script to make the deposits. You can select which chain to
deposit from using command-line arguments.
3.8. Check the balances on the Gateway Wallet
Create a new file calledbalances.ts, and add the following code. This script
retrieves the USDC balances available from your Gateway Wallet on each supported
chain. You can run it to check whether finality has been reached for recent
transactions.
<WALLET_ID> with any of the wallet IDs from the
created wallets. The code derives the address from the wallet ID provided.
Step 4: Transfer USDC from the crosschain balance to Arc
In this step, you can review the transfer script, covering configuration, approval, and minting USDC on Arc from your crosschain balance. You can skip to the full transfer script if you prefer.4.1. Create the script file
4.2. Define chain configuration
4.3. Define constants and EIP-712 typed data types
These constants define the parameters for transferring funds from your Gateway balance to a wallet on the destination chain.- Replace the
<WALLET_ADDRESS>placeholder with the unified wallet address of your created dev-controlled wallets. You can run thebalances.tsscript to check the balance. - The
DESTINATION_CHAINis currently set toBASE-SEPOLIAbut you can change it to a chain of your choice. Note that gas fees differ between chains. - You can set the amount of USDC to be transfered from each chain within the unified balance, which is currently set to 1 USDC.
4.4. Add helper functions
4.5. Construct and sign the burn intents
First, within the main logic, you need to build the requests and sign them before they can be submitted to the Gateway API.4.6. Submit the burn intents to the API
Then, you use the signed burn intents to request an attestation from the Gateway API.4.7. Mint USDC on destination chain
Finally, you need to pass the attestation to mint USDC to the destination chain by callinggatewayMint() on the Gateway Minter contract.
4.8. Full transfer script
Now that you’ve covered the setup and core steps, this full script puts everything together and transfers out 1 USDC from each specified Gateway balances to the destination address. It includes comments that describe what each function does as well for reference.4.9. Run the script to transfer USDC to destination chain
Run thetransfer.ts script to transfer 1 USDC from each selected Gateway
balance to the destination chain.
Gateway gas fees are
charged per burn intent. To reduce overall gas costs, consider keeping most
Gateway funds on low-cost chains, where Circle’s base fee for burns is
cheaper.
Summary
After completing this tutorial, you’ve successfully:- Created dev-controlled wallets
- Funded your wallet with testnet USDC
- Created a unified USDC balance
- Transferred USDC out from your unified USDC balance