Skip to main content
Swap 1.5 USDCx for ETH on testnet with an SDK or the CLI. A swap takes two transactions: the request and the claim. The SDK steps follow the Veil and Python examples. Run them in order in one session; they use an existing testnet key and keep recovery data in memory. The complete programs also cover account creation and storage. For a first trade from a terminal, we recommend the CLI.

1. Install and configure an account

For the SDKs, supply your existing testnet private key through SHIELD_SWAP_PRIVATE_KEY in the process environment. The CLI can create and save an account for you.
Use Node.js 22 or later in an ES module project:
The client includes a record scanner to find spendable funds, plus delegated proving and fee payment.

2. Get test tokens

Your account needs spendable USDCx before you can trade. These examples authenticate and request test tokens if your existing balance is insufficient.
confirmAirdrop waits for the faucet transfer and its token records.
A swap spends one token record. If your balance is split across smaller records, prepare a covering record.

3. Quote and submit the swap

Quote 1.5 USDCx for ETH with 50 basis points (0.5%) slippage. The SDKs choose the route and preserve the quote’s minimum output when submitting. Each run submits a new swap.
Keep handle available until you claim the output.

4. Wait for the output and claim

The claim delivers the output and any unused input to your account. Continue with the handle or swap ID from step 3.
You’re done when the claim confirms with a positive ETH amount. If a call times out, keep the session open and recover the existing trade before retrying.

Run packaged examples

The complete programs create or reuse a testnet account and perform the same 1.5 USDCx swap. Each run starts a new trade.
With Node.js 22 or later and pnpm 10, run from a Veil checkout:
Keep the saved private key and recovery JSON file. The example’s README explains how to reuse them.

Next Steps

Setup covers mainnet configuration. Swap History & Recovery shows how to finish an existing trade, and Verify swap settlement checks its transactions and output records.