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.A newly generated account exists only in memory. Save
The sections below show how to set up your chosen trading tools for mainnet. To begin trading on testnet, use the Quickstart.
Install
- TypeScript
- Python
- CLI
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.
- TypeScript
- Python
- CLI
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.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
- TypeScript
- Python
- CLI
Client setup for services, scripts, and agents
The typescript SDK uses viem-likeClient 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, anRPC 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.- TypeScript
- Python
- CLI
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.- TypeScript
- Python
- CLI
Get or redeem a referral code (optional)
Optional referral code redemption can be redeemed via traders participating in Shield Swap incentive program.- TypeScript
- Python
- CLI
Get the account’s referral codeRedeem another trader’s codeReplace
getMyReferralCode() calls GET /referral/my-code to retrieve your shareable code or create one if permitted: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.Shield Wallet holds the account you use with Shield Swap and asks you to approve connections and transactions. You can create a new account or import one you already use.
Install Shield Wallet
Before you startYou’ll need Chrome or a Chromium-based desktop browser, such as Brave.- Open the Shield Wallet extension in the Chrome Web Store.
- Install the extension through your browser’s prompts.
- Open Shield Wallet from the extensions menu.
Create or import an account
Choose the path that matches whether you already have an account.Create a new account
- Select Create Wallet in Shield Wallet.
- Back up the seed phrase offline. It lets you restore the account if you lose access to this browser.
- Complete the wallet’s prompts to name the account and set a password.
Import an existing account
- Choose the import option during wallet setup.
- Follow the prompts to import with your existing seed phrase or private key.
- Check that the imported account shows the address you expect to use.