Skip to main content
Shield Swap is a decentralized AMM exchange that enables private swaps between asset pairs. This guide introduces the SDKs, CLIs, and APIs available for Shield Swap and provides installation and configuration steps for each option.The table below lists the available trading options and when to use each.The sections below show how to set up your chosen trading tools for mainnet. To begin trading on testnet, use the Quickstart.

Install

Services, scripts, and agents

Install Node.js 22 or later and the SDK packages in an application that uses ES modules:

Browser

For browser-based apps, install the trading SDK and wallet adapter packages:

Configure

1. Setup an account

Shield Swap runs on the Aleo network to enable private trades. The guide below shows how to setup an Aleo account for private trading.
Your private key controls your account and its funds. Never share it or include it in source control or logs. Keep a secure backup of your private key or saved account files so you can restore the account later. Aleo’s account keys guide explains the private key, view key, compute key, and address.

Services, scripts, and agents

Load an existing mnemonic or private key to set up an account, or generate a new account if neither is available.
A newly generated account exists only in memory. Save account.privateKey in your application’s secret manager before ending the session so you can load the same account next time.

Browser apps

Browser apps use a connected wallet to manage the account and its private key. Select an existing account in the wallet, or create one there, then connect it from the app:

2. Setup a trading client

Client setup for services, scripts, and agents

The typescript SDK uses viem-like Client and Action semantics and allows clients to be extended with arbitrary actions. The step below uses the account created above to create a Wallet Client and extends it with Shield-Swap trading actions. In detail, createAleoClient creates a WalletClient configured with Aleo RPC and gas payment services. The example then extends it with shieldSwapActions, which provides actions for quoting, swapping, inventory management, and accessors to the Shield Swap API.Continue with aleo and account from step 1:

Browser client setup

When building a web or browser application, a wallet manages the account, all token inventory records, and transaction signing. In this case, an RPC account must be created to request these services from a browser or embedded wallet.
publicClient reads chain state, including the transaction checks in Swap. The connected wallet authorizes trades.

3. Configure optional storage

Persistent storage retains swap history and the secret data needed to claim an output after a restart. Configure it before submitting swaps if the application needs this recovery path.

Client setup for services, scripts, and agents

For faster trading, it’s recommended to persist recovery data. To enable this, configure a swap file store before authenticating or submitting swaps. If this step is skipped, recovery data and swap history are lost when the process exits.

Browser client setup

All browser configurations persist history and recovery data within the configured wallet. No storage configuration is required for browser applications.

4. Authenticate with the API

The Shield Swap API requires authentication via a signature over a challenge containing the current Terms of Use. The step below performs this signature and grants API access.

Get or redeem a referral code (optional)

Optional referral code redemption can be redeemed via traders participating in Shield Swap incentive program.
Get the account’s referral codegetMyReferralCode() calls GET /referral/my-code to retrieve your shareable code or create one if permitted:
Redeem another trader’s codeReplace REFERRAL_CODE with the code another trader shared with you:

Next Steps

Fund the trading accountFollow the Fund guide to add assets to the configured Shield Swap trading account.Run full examplesThe TypeScript examples in the Shield Swap JS/TS SDK and Python examples in the Shield Swap SDK cover account setup, funding, quoting, submission, and claiming. Follow the run instructions to try them with test tokens on testnet.