Skip to main content
This guide walks you through the process of integrating Universal Account features into a working demo app built with Particle Auth and the Universal Accounts SDK. We’ll explain how user logins, account initialization, and balance display are handled in the code. You’ll also learn how to:
  • Initialize a Universal Account after a user logs in.
  • Fetch and display the user’s Universal Account addresses.
  • Fetch and display the user’s unified balance across chains.
You can use this as a reference or base for your own app.
This example showcases a Next.js app using Particle Auth as its login method.However, the same logic can be applied to any other EOA-based provider or signer.

Getting Started

To start integrating Universal Accounts:
1

Clone the Quickstart Repository

This repository includes the full working demo app.
Terminal
2

Set Environment Variables

Create a .env file in the root of the ua-quickstart directory with the following variables:
.env
You can retrieve your Auth project credentials from the Particle Dashboard.
If you need a UA access key, contact the Particle team.

This example uses Particle Auth for simplicity, but Universal Accounts are compatible with any EOA-based provider or signer.
3

Install Dependencies

Install the project dependencies using your preferred package manager:
The Universal Accounts SDK is currently private. Contact the Particle Team to get access.
4

Run the App

Start the development server:
Once the app is running, log in with any supported method via Particle Auth. After logging in, the app will display your Universal Account addresses and unified balance.
Universal Accounts are standalone smart accounts. As such, to fund yours, you will need to transfer assets into it—unless you’re logging into a pre-existing Universal Account, created through UniversalX or any other Universal Accounts-enabled app.

Features Walkthrough

1. Universal Account Initialization

After the user logs in, the app creates a new Universal Account instance inside a useEffect. The constructor requires:
  • The connected user’s address.
  • Your Universal Accounts project ID.
  • Optional config settings for slippage and gas abstraction.
Within the demo app, this looks as follows:
page.tsx
In this case, the user’s address is retrieved directly from Particle Auth after they log in.

Universal Account Initialization in the Repository

Code location: page.tsxuseEffect watching connected && address

2. Fetching a Universal Account’s Addresses

The app fetches a Universal Account’s EVM and Solana Universal Account addresses using getSmartAccountOptions(). This returns a UA’s:
  • EOA/Owner Account (from Particle Auth).
  • EVM Universal Account address.
  • Solana Universal Account address.
page.tsx
The addresses are stored in state and rendered in the UI.

Fetching Smart Account Addresses in the Repository

Code location: page.tsxuseEffect watching universalAccount && address

3. Fetching A Universal Account’s Unified Balance

To show the user’s total balance of Primary Assets across chains, the app uses getPrimaryAssets() from the Universal Accounts SDK. This returns:
  • totalAmountInUSD
  • Detailed breakdown per token + chain (if needed).

Full Primary Assets Breakdown

Learn how to retrieve a full Primary Assets breakdown on our SDK reference.
The following code snippet shows how to retrieve the user’s Primary Assets balance:
page.tsx
The UI then displays the account’s Primary Assets balance in USD:
page.tsx
Primary Assets are key tokens for which Universal Accounts have deep liquidity. As such, the SDK uses them as the base assets for any cross-chain operation—including gas, swaps, and liquidity routing.

Fetching Unified Balance in the Repository

Code location: page.tsxuseEffect watching universalAccount && address

4. Sending Transactions

Within the demo app, you can find examples for two types of transactions, both using a Universal Account:
  • A custom contract call with its destination on the Base Mainnet.
  • A USDT transfer to Arbitrum.
Both transactions use the user’s Universal Account to handle asset conversion and automate liquidity routing. Let’s take a closer look into both:

Contract Call Example

To interact with a smart contract—such as calling a function like checkIn()—you can use createUniversalTransaction() with the transactions and expectTokens fields. This method lets you define one or more contract calls while specifying which tokens the contract expects to receive or require:
page.tsx
In this case, the provider instance of Particle Auth is used to sign the transaction directly.
In this example, the transaction expects 0.0000001 ETH on Base Mainnet. Even if the user doesn’t have ETH on Base, Universal Accounts will convert assets from other chains to meet this requirement.

Send Custom Transaction in the Repository

Code location: page.tsxhandleTransaction()

Token Transfer Example

To transfer tokens (e.g., 0.1 Arbitrum USDT in this example), the demo app uses createTransferTransaction(). It does so in the following way:
page.tsx
The user can use any token on any supported chain to initiate the transfer—Universal Accounts handle conversion to the destination asset and routing automatically.

Send Transfer Transaction in the Repository

Code location: page.tsxhandleTransferTransaction()

Full Code Reference

Check out the complete page.tsx file below to see how everything fits together. You can also copy/paste the below file into your project or use it as a base for your own integration:
page.tsx

Additional Resources

SDK Reference

Learn more about the Universal Accounts SDK.

Supported Chains

Learn more about the chains supported by Universal Accounts.