Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.particle.network/llms.txt

Use this file to discover all available pages before exploring further.

The Universal Accounts SDK supports sell/swap transactions through the createSellTransaction() method. This allows you to programmatically sell a token (e.g., ARB on Arbitrum) into a target primary asset, with the transaction routed through Particle’s Chain Abstraction layer. Once the transaction is created, it returns a rootHash payload that needs to be signed. You then use your signer (e.g., Particle Auth) to sign and pass it into sendTransaction() to broadcast.
The amount you specify is the raw token amount to be sold (no decimals adjustment needed). Ensure the Universal Account has a sufficient balance of the token before calling createSellTransaction().
import { CHAIN_ID, UniversalAccount } from "@particle-network/universal-account-sdk";
import { useEthereum } from "@particle-network/authkit";

// extract the provider from Particle Auth
const { provider } = useEthereum();

// In your app
const transaction = await ua.createSellTransaction({
  token: {
    chainId: CHAIN_ID.ARBITRUM_MAINNET_ONE,
    address: "0x912CE59144191C1204E64559FE8253a0e49E6548", // ARB on Arbitrum
  },
  amount: "0.1", // Amount of token to sell
});

const signature = await provider.signMessage(transaction.rootHash);
const result = await ua.sendTransaction(transaction, signature);

console.log("Explorer URL:", `https://universalx.app/activity/details?id=${result.transactionId}`);
The sendTransaction() method returns a TransactionResult object with the transaction ID and other metadata.

Specifying the Output Token Type

By default, createSellTransaction() accepts an optional second argument, tradeConfig, which lets you control what token you receive as proceeds from the sell. The preferTokenType field inside tradeConfig accepts either a numeric literal or the named PREFER_TOKEN_TYPE enum member — both are equivalent since PREFER_TOKEN_TYPE is a numeric TypeScript enum.
ValueEnumMeaning
0PREFER_TOKEN_TYPE.USDReceive a USD-pegged stablecoin (USDC)
1PREFER_TOKEN_TYPE.NATIVEReceive the chain’s native token (e.g. ETH, BNB)
If tradeConfig is omitted entirely, the SDK uses its own default output token.
import { CHAIN_ID, PREFER_TOKEN_TYPE, UniversalAccount } from "@particle-network/universal-account-sdk";
import { useEthereum } from "@particle-network/authkit";

const { provider } = useEthereum();

const transaction = await universalAccount.createSellTransaction(
  {
    token: {
      chainId: CHAIN_ID.ARBITRUM_MAINNET_ONE,
      address: "0x912CE59144191C1204E64559FE8253a0e49E6548", // ARB on Arbitrum
    },
    amount: "1",
  },
  {
    preferTokenType: PREFER_TOKEN_TYPE.USD, // 0 = USDC, 1 = native token
  },
);

const signature = await provider.signMessage(transaction.rootHash);
const result = await universalAccount.sendTransaction(transaction, signature);

console.log("Explorer URL:", `https://universalx.app/activity/details?id=${result.transactionId}`);

Next steps

Conversion Transaction

createConvertTransaction() — convert between primary assets.

sendTransaction() Response

Full breakdown of the TransactionResult object.