Use this file to discover all available pages before exploring further.
The Universal Accounts SDK can also be used in backend environments to construct and sign transactions programmatically.The example below demonstrates usage with ethers.js and a private key in Node.js:
import { UniversalAccount, CHAIN_ID } from "@particle-network/universal-account-sdk";import { Wallet, getBytes } from "ethers";// Initialize walletconst wallet = new Wallet("PRIVATE_KEY_OR_MNEMONIC");// Create a Universal Account instanceconst ua = new UniversalAccount({ projectId: "UA_PROJECT_ID", ownerAddress: wallet.address, tradeConfig: { slippageBps: 100, // Set slippage to 1% (100 basis points) universalGas: true // Use PARTI tokens to cover gas fees }});// Create a transaction to buy $0.1 worth of ARB on Arbitrumconst tx = await ua.createBuyTransaction({ token: { chainId: CHAIN_ID.ARBITRUM_MAINNET_ONE, address: "0x912CE59144191C1204E64559FE8253a0e49E6548" // ARB token contract }, amountInUSD: "0.1"});// Sign and send the transactionconst result = await ua.sendTransaction(tx, wallet.signMessageSync(getBytes(tx.rootHash)));// Log the transaction result and link to explorerconsole.log("Transaction ID:", result.transactionId);console.log("View on Explorer:", `https://universalx.app/activity/details?id=${result.transactionId}`);