Skip to main content
This quickstart is for developers who want to integrate xReserve into their apps. It helps you write a TypeScript script that deposits USDC into xReserve on Ethereum Sepolia. Your recipient wallet will receive USDC-backed stablecoins on the remote blockchain when that network supports automatic settlement.
Need to transfer USDC from another chain first? Use Arc App Kit’s Bridge capability to move testnet funds to Ethereum Sepolia before making an xReserve deposit.
Select the tab below to view the steps for your blockchain.
This quickstart covers the deposit into xReserve on Ethereum Sepolia. After the deposit confirms, Aleo requires you to mint USDCx before it appears in the recipient wallet. For details, see the official Aleo documentation

Prerequisites

Before you begin, ensure that you’ve:
  • Installed Node.js v22.6+.
  • Created an Ethereum Sepolia wallet and an Aleo Testnet wallet and funded them with testnet tokens.
  • Installed the required dependencies:
    • viem - A TypeScript library that interfaces with Ethereum.
    • @provablehq/sdk - Official Aleo SDK for address encoding.

Step 1: Set up your project

This step shows you how to set up a fresh Node.js workspace, install dependencies, configure your environment variables, and prepare your Ethereum Sepolia wallet.

1.1. Set up your development environment

Create a new directory and install dependencies:
Shell

1.2. Configure environment variables

Create a .env file in the project directory and add your wallet private key and the recipient address on Aleo.
If you use MetaMask, follow their guide for how to find and export your private key.
Shell
This example uses one or more private keys for local testing. In production, use a secure key management solution and never expose or share private keys.

Step 2: Set up your script

This step shows you how to build the script by importing its dependencies and defining the configuration constants and ABI fragments that the script uses.

2.1. Import dependencies

Create a file called index.ts and add the following code to import the dependencies:
index.ts

2.2. Define configuration constants

Add the following code snippet to your index.ts file. It specifies the RPC and wallet private key, contract addresses, and Aleo-specific parameters that the rest of the script relies on. The ALEO_RECIPIENT is loaded from your .env file.
You can review the xReserve EVM contracts on GitHub.
index.ts

2.3. Set up contract ABIs

Add the following code snippet to your index.ts file. It adds xReserve and ERC-20 ABI fragments which tell viem how to format and send the contract calls when the script runs.
For more background on contract ABIs, see QuickNode’s guide, What is an ABI?.
index.ts

Step 3: Execute the deposit

This step shows you how to implement the main() function which performs the deposit of USDC from your Ethereum Sepolia wallet into the xReserve contract. The xReserve contract mints an equivalent amount of USDCx on Aleo Testnet and sends it to your recipient wallet.

3.1. Implement the main function

Add the following code snippet to your index.ts file. It implements the main() function which uses viem to read balances, approve a USDC spend, call the xReserve deposit function, and console.log the transaction results.Aleo uses bech32m-encoded addresses and little-endian byte ordering for field elements. The script uses the Aleo SDK’s Address.toBytesLe() method to convert the recipient address to a 32-byte field element for remoteRecipient.The hookData parameter selects the mint mode on Aleo. This quickstart performs a public deposit. For the full hookData format and other mint modes, see the Aleo USDCx bridge documentation.
index.ts
This step finalizes the transfer, depositing USDC into xReserve on Ethereum Sepolia to make USDCx available on Aleo Testnet.

3.2. Run the script

Execute the script in your terminal:
Shell

3.3. Verify the deposit

After the script finishes, find the Deposit tx hash in the terminal output and paste it into Sepolia Etherscan to confirm your deposit transaction was successful.After the deposit confirms, Aleo requires you to mint USDCx before it appears in the recipient wallet. For details, see the official Aleo documentation.