Use this file to discover all available pages before exploring further.
The Universal Accounts SDK also allows you to register an account on UniversalX, a chain-abstracted trading platform built upon Universal Accounts.This can automatically onboard your users into UniversalX when they create or initialize a Universal Account. UniversalX registration is optional and only needs to be done once per UA.
import { UniversalAccount, createUnsignedMessage } from "@particle-network/universal-account-sdk";import { randomUUID } from "crypto";const ua = new UniversalAccount({ projectId: process.env.NEXT_PUBLIC_PROJECT_ID!, projectClientKey: process.env.NEXT_PUBLIC_CLIENT_KEY!, projectAppUuid: process.env.NEXT_PUBLIC_APP_ID!, ownerAddress: 'USER_ADDRESS',});// Fetch smart account info to get the UA addressconst smartAccountOptions = await ua.getSmartAccountOptions();// Optional invite codeconst inviteCode = "000000";// Prepare registration payloadconst deviceId = randomUUID();const timestamp = Date.now();const unsignedMessage = createUnsignedMessage( smartAccountOptions.smartAccountAddress!, deviceId, timestamp);// Sign message using EOA (can be a backend wallet)const signature = provider.signMessage(unsignedMessage);// Register the UniversalX accountconst result = await ua.register(inviteCode, deviceId, timestamp, signature);if (!!result.token) { console.log("Registration successful.");} else { console.error("Registration failed:", result);}
You can also pass an invite code ("000000" by default) if you have one.