Skip to main content

How funding works

Shield Swap runs on the Aleo network and uses token records for private trading. Each record holds an amount your account can spend in a swap.To fund your trading account from a supported EVM chain or Solana, you bridge assets to Aleo, then convert the received public balance into token records. This conversion is called shielding. USDC can be bridged directly into USDCx records, without a separate shielding step.Once trading is complete, you can bridge your funds out to another supported chain. If your account already holds spendable token records, you can go straight to getting a quote.

Check spendable funds

Prerequisites: Your account and trading clients from Setup: client for TypeScript, dex for Python, or a configured CLI profile. For practice with test assets, use the separate testnet funding flow.Check your USDCx balance to decide whether you need funding or record preparation.
privateBalance is a decimal string in USDCx units. For example, "1" means 1 USDCx, not one base unit.
Your total record balance can be sufficient even when no single record covers the swap. For example, two records of 0.5 USDCx total 1 USDCx, but neither covers a 1 USDCx input. Prepare a covering record before swapping.If you have a public balance, configure the bridge client in step 1, then continue to shielding. If your funds are on another chain, follow the bridge steps below.

Bridge assets

Use these mainnet examples to transfer ETH between Ethereum and Aleo through Hyperlane. Choose TypeScript, Python, or REST, and use the same interface through delivery so you can track one transfer throughout.For the supported pairs and examples covering Solana, USDCx delivery modes, frontend integration, and embedded wallets, see the Bridging integration guide. Use the Shield Swap CLI to check balances before and after funding.

1. Configure access

You need a source account that can sign the transfer and a destination address to receive it. Keep funds for network fees in the source account in addition to the transfer amount. When funding, use your mainnet Aleo account from Setup as the recipient.The examples below use private keys managed by your application. For a Dynamic or Privy signer, follow Use Embedded Wallets for bridging, then continue at route discovery.Your application must supply the keys, RPC URL, and wallet addresses from an external source, such as its configuration or a secret manager. The examples below use environment variables:
Install the packages in an ES module application using Node.js 22 or later:
--legacy-peer-deps avoids a conflict between the bridge package’s optional Solana and server-wallet peers in npm.Connect your Aleo trading account and Ethereum signer to the bridge. Your Ethereum RPC connection handles chain reads and transaction submission:
You now have a mainnet bridge client and Aleo account. Keep both in the same session for the TypeScript steps that follow.

2. Discover assets and routes

Prerequisites: The bridge client or REST shell configuration from Configure access.A route identifies the asset and the provider that can move it between two chains. Discover routes to check where you can send your funds. Use the returned chain and asset identifiers when quoting; a symbol alone does not identify an asset across chains.
assets lists the registered assets; inboundRoutes and outboundRoutes list routes in each direction. Check availability before quoting: metadata-required means deployment metadata is still needed.
For the ETH examples, the identifiers are:For an Aleo-to-Ethereum withdrawal, Hyperlane spends your public balance. If your ETH is held in records, unshield the withdrawal amount and wait for acceptance before quoting.

3. Request and review a quote

Prerequisites: The client or REST shell configuration from Configure access, a supported route from Discover assets and routes, and your recipient address.Request a quote to see how much your recipient can expect and the route fees before you move funds. Choose one direction below. Each example requests 0.01 ETH in display units, not base units.For an Ethereum destination, replace ETHEREUM_RECIPIENT with the receiving wallet’s Ethereum address. For an Aleo destination, the SDKs use your configured trading account. In REST, set SOURCE_ADDRESS and DESTINATION_ADDRESS to the wallets for your chosen direction.
Ethereum to Aleo:
Aleo to Ethereum, with your destination address in place of ETHEREUM_RECIPIENT:
quote.plan contains the selected route, amount, and recipient. Review the returned fees and transfer details before using that plan to submit.

4. Submit the reviewed transfer

Prerequisites: Your client from Configure access and the quote or QUOTES response you reviewed in Request and review a quote.Submission moves funds into the bridge. Save a reference so you can check delivery after a restart: the SDKs use checkpoints, while REST uses an order ID.
Recover an uncertain submission before sending again. A timeout does not prove that funds stayed in your source account; another submission could send them twice. Use Recover an interrupted transfer to check the original transfer.
Supply saveCheckpoint, your storage callback, before running this example. It receives a BridgeCheckpoint and must persist it before returning; it can return void or Promise<void>. The SDK has no default persistent store for this callback.
You receive execution.receipt, which identifies the submitted work for the delivery check. Some token routes require an approval before the transfer.

5. Check delivery

Prerequisites: Your configured client and the submission result from Submit the reviewed transfer: quote.plan and execution.receipt for TypeScript, progress for Python, or ORDER_ID for REST.Your source transaction can be confirmed while delivery is still pending. Check the existing transfer to see whether the destination has received the funds. These calls do not sign another transaction.
For either SDK, use the returned progress.next to decide what to do:For Hyperlane withdrawals from Aleo, both SDKs can use the recipient’s balance increase to detect delivery. Spending from that destination account before the check can leave a delivered transfer marked as pending; unrelated incoming funds can also make the balance check misleading. Confirm the original transfer in the Hyperlane explorer and check its destination transaction before resubmitting or treating the balance change as proof.After inbound Hyperlane delivery, shield your public balance to prepare it for trading. After a withdrawal, check the destination receipt and recipient balance.

6. Recover an interrupted transfer

Prerequisites: Recreate the client from Configure access with the same account, then load the checkpoint or order ID saved during submission.You can inspect an interrupted transfer without sending funds again. Recovery uses its saved reference to find how far the original transfer progressed.
Recover the original transfer before calling execute again. Another execution can submit a second transfer instead of finishing the first.
Load checkpoint, the BridgeCheckpoint object saved by your saveCheckpoint callback. Pass that object to your recreated client:
Read recovered.next using the delivery result table. If it requests resume or complete, follow the route’s packaged example. A Circle mint using a secret nonce also needs the original nonce; retain it separately because checkpoints and public transaction history cannot reconstruct it.

Shield public balances

Prerequisites: Your bridge client from Configure access, plus a public ETH balance for shielding or a sufficient ETH record for unshielding.Shield the amount you want to trade after Hyperlane delivers it to your public balance. To withdraw through Hyperlane, unshield that amount instead. Unshielding exposes the recipient and amount in public balance state.Each example converts 0.01 ETH in display units and submits a separate transaction with a fee. The CLI and wallet services order endpoints do not provide this conversion.
Use your configured mainnet client to shield 0.01 ETH:
To unshield, supply record as an encoded plaintext string from your account’s record scanner. It must be an unspent ETH record covering at least 0.01 ETH:
You receive conversion.transactionId. Wait for acceptance before spending the converted amount. A connected wallet that supports record requests can select the record if you omit it; the local-key example supplies it explicitly.
After shielding is accepted, repeat the balance check with ETH in place of USDCx. Your received ETH is ready for a swap when a record covers the input amount. Circle’s supported record-based USDCx withdrawal can burn records directly and does not need this Hyperlane conversion.

Request testnet tokens

Testnet prerequisites: The separate account and clients from the Quickstart: client and account for TypeScript, shield_swap_client for Python, or the CLI testnet profile. For the Python examples below, set dex = shield_swap_client.Use the faucet to practice without transferring mainnet assets. The SDK calls wait for the faucet transfer and its token records. With the Quickstart’s delegated proving setup, you do not need a public ALEO balance.A faucet job can deliver USDCx even if another asset transfer fails. Check the same account’s USDCx records before requesting more tokens; an available record covering your input is enough to continue the testnet swap.
On success, check your testnet balance to confirm the received funds. If the call times out, set jobId to the job ID reported by the timeout, then inspect that request:
A completed faucet job can still be waiting for record indexing. Check your balance before requesting more funds; you can trade when a record covers your intended input.

Next steps

Get a trading quote

Use the Quote guide to find a pool and review a swap once your input is available in a record.

Run packaged examples

Run a complete mainnet example for your chosen route. Each repository documents the accounts and connections you need.
Follow the Veil bridge examples README to configure your accounts, then run the ETH example for your direction from its example directory:
You receive a quote without submitting funds. To execute, supply the acknowledgement documented in the example. The same directory covers USDC/USDCx routes and checkpoint recovery.