A delegate wallet can deposit into a user’s Unified Balance and spend from it after the user gives authorization. In this quickstart, you’ll need two wallets: a user wallet that owns the Unified Balance and a delegate wallet that deposits funds and signs spends on the user’s behalf. You’ll write scripts that deposit from Base Sepolia, authorize the delegate on Base Sepolia, check the user’s Unified Balance, and spend on Arc Testnet. These are examples only. You can use any of the supported blockchains and fund the Unified Balance from as many sources as you need. The scripts use built-in public RPC URLs, which may be rate-limited or unreliable. For a more stable connection, you can configure a custom RPC.Documentation Index
Fetch the complete documentation index at: https://docs.arc.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, ensure that you’ve:- Installed Node.js v22+.
- Created two EVM wallets (delegate and user) using a wallet provider such as MetaMask and added the Base Sepolia and Arc Testnet networks.
- Funded the delegate wallet with testnet tokens:
- Get testnet USDC from the Circle Faucet on Base Sepolia.
- Get testnet ETH on Base Sepolia from a public faucet (needed for deposit and spend transactions on Base Sepolia).
- Funded the user wallet with testnet ETH on Base Sepolia (needed for gas to authorize the delegate on Base Sepolia).
- Fund wallets on Arc Testnet if needed (USDC there can cover gas for the destination credit when the delegate spends on Arc Testnet).
- Obtained a recipient address on Arc Testnet that will receive the USDC.
Step 1. Set up your project
1.1. Create the project and install dependencies
Create a new directory and install App Kit and its dependencies:Shell
1.2. Configure TypeScript (optional)
This step is optional. It helps prevent missing types in your IDE or editor.
tsconfig.json file:
Shell
tsconfig.json file:
Shell
1.3. Set environment variables
Create a.env file in the project directory:
.env
- Replace
0xYOUR_DELEGATE_PRIVATE_KEYwith the private key for the delegate wallet that holds USDC on Base Sepolia, signs deposits, and spends on the user’s behalf. - Replace
0xYOUR_USER_PRIVATE_KEYwith the private key for the user wallet that owns the Unified Balance and authorizes the delegate. - Replace
0xYOUR_USER_ADDRESSwith the user wallet’s public address. - Replace
0xYOUR_RECIPIENT_ADDRESSwith the address that should receive USDC on Arc Testnet when the delegate spends.
If you use MetaMask, follow their guide for how to find and export your
private
key.
Step 2. Deposit into the user’s Unified Balance
In this step, the delegate funds the user’s Unified Balance from Base Sepolia.2.1. Create the deposit script
Create adelegate-deposit.ts file. In this script, the delegate deposits 2.00
USDC from the delegate’s Base Sepolia wallet into the user’s Unified Balance.
delegate-deposit.ts
depositFor is permissionless. Any wallet can fund another user’s Unified
Balance. The delegate does not need prior authorization to deposit.2.2. Run the deposit script
In your terminal, run:Shell
Shell
2.3. Verify the deposit
Open theexplorerUrl from the deposit result to confirm the onchain
transaction on Base Sepolia.
Step 3. Authorize the delegate
In this step, the user grants the delegate permission to spend from their Unified Balance on a specific blockchain.3.1. Create the authorize script
Create adelegate-authorize.ts file. In this script, the user wallet
authorizes the delegate to spend from their Unified Balance on Base Sepolia:
delegate-authorize.ts
addDelegate is an onchain transaction signed by the user. Once authorized, the
delegate can spend repeatedly on the same blockchain without reauthorization.
Authorization is per-blockchain. See
Manage Delegates for
details.3.2. Run the authorize script
In your terminal, run:Shell
Shell
status is already 'ready', the script exits without calling
addDelegate. If status is 'pending', it asks you to wait and run the
script again. Otherwise it submits addDelegate.
Step 4. Check the user’s Unified Balance
In this step, the delegate checks the user’s Unified Balance by address.4.1. Create the balance check script
Create adelegate-check-balance.ts file. This script prints the user’s
confirmed and pending Unified Balance totals:
delegate-check-balance.ts
4.2. Run the balance check script
In your terminal, run:Shell
Shell
totalPendingBalance before they are
reflected in totalConfirmedBalance. Wait until the user’s
totalConfirmedBalance is high enough for the spend you plan to make before you
continue.
Step 5. Spend from the user’s balance
In this step, the delegate spends from the user’s Unified Balance on Arc Testnet for the recipient.5.1. Create the spend script
Create adelegate-spend.ts file. This script spends 0.50 USDC from the user’s
Unified Balance on Arc Testnet for the recipient, signed by the delegate.
App Kit chooses
how much USDC to use from each blockchain.
delegate-spend.ts
5.2. Run the spend script
In your terminal, run:Shell
Shell
5.3. Verify the spend
Use theexplorerUrl from the spend result to confirm that USDC arrived at the
recipient address on Arc Testnet. The received amount can be less than the
requested spend after fees. For more on fees, see
How Unified Balance fees work.