PollarPollarDemo

Products

WalletTransactionsSessionsDistribution

Integrations

KYCSoonRampNewSwapNew

Wallet Adapters

Stellar Wallets KitPrivyNewAcceslySoon

Built with Pollar

Trustless WorkNiriumNewLumenWipeNew
WalletTransactionsSessionsDistributionKYCSoonRampNewSwapNewStellar Wallets KitPrivyNewAcceslySoonTrustless WorkNiriumNewLumenWipeNew
SendReceiveBalanceAssetsHistory

Enabled assets

The app's dashboard-enabled assets paired with the connected wallet's on-chain trustline state — so you know which trustlines the wallet still needs to add. Native XLM is always present.

Drop-in button that opens a prebuilt modal listing every enabled asset and whether the connected wallet has a trustline for it.

openEnabledAssetsModal() takes no arguments — it reads the connected wallet's session and renders the trustline table for you.

Hook & values used

All of these come from the usePollar() hook — the react layer built on top of getClient().

  • openEnabledAssetsModal()sync

    params: No arguments — it reads the connected wallet and renders the enabled-assets / trustline table inside the modal.

    returns: void — opens the prebuilt modal; there is nothing to await.

  • refreshAssets()async

    params: No arguments — same call as the core method, re-exported on the hook for convenience.

    returns: Promise<void> — refreshes the enabledAssets reactive value below.

  • enabledAssetsreactive value

    params: Not a function — a value of type EnabledAssetsState read from usePollar().

    returns: Re-renders your component whenever it changes. Mirrors getClient().getEnabledAssetsState(): step plus data when loaded.

@pollar/react— hooks & components
import { usePollar } from '@pollar/react';

export function AssetsButton() {
  const { openEnabledAssetsModal, isAuthenticated } = usePollar();

  // openEnabledAssetsModal lists every dashboard-enabled asset and
  // whether the connected wallet has a trustline — on top of refreshAssets().
  return (
    <button
      onClick={openEnabledAssetsModal}
      disabled={!isAuthenticated}
    >
      Enabled assets
    </button>
  );
}
enabledAssets.stepidle

Refresh to load the app's enabled assets.

Enable / disable a trustline

A trustline is a change_trust operation. Enabling adds the asset (optionally capped by a limit); disabling sends limit "0", which removes it — and only succeeds when the asset balance is already zero. Native XLM never needs a trustline.

Maximum amount you'll trust. Leave empty for the maximum; Disable forces "0".

On a successful disable, the balance response reports trustlineRemoved: true.

change_trust functions

runTx is the one-shot path; the demo then re-renders the table via refreshAssets(). Both come from usePollar() (or the underlying PollarClient via getClient()).

  • runTx(operation, params, options?)async

    params: operation: 'change_trust'; params.asset: { type, code, issuer }; params.limit?: string ('0' removes the trustline, omitted = max).

    returns: Promise<SubmitOutcome> — build → sign → submit in one call; status: 'success' | 'pending' | 'error'. Drives the reactive tx state.

  • buildTx(operation, params, options?)async

    params: Same arguments as runTx — use it when you want to inspect the unsigned XDR before signing.

    returns: Promise<BuildOutcome> — returns the built tx without submitting; pair it with signAndSubmitTx().

  • refreshAssets()async

    params: No arguments.

    returns: Promise<void> — re-fetches the enabled-assets table so trustlineEstablished reflects the change_trust you just submitted.

@pollar/core— framework-agnostic
import { PollarClient } from '@pollar/core';

const client = new PollarClient({ apiKey, baseUrl });
await client.ready();
const asset = { type: "credit_alphanum4", code: "USDC", issuer: "G..." };

// enable — build → sign → submit in one call
await client.runTx('change_trust', { asset });

// disable — limit "0" removes the trustline (balance must be 0)
await client.runTx('change_trust', { asset, limit: '0' });

await client.refreshAssets();
@pollar/react— hooks & components
import { usePollar } from '@pollar/react';

const { runTx, refreshAssets } = usePollar();
const asset = { type: "credit_alphanum4", code: "USDC", issuer: "G..." };

// enable — add the trustline (omit limit for the max, or cap it)
await runTx('change_trust', { asset });

// disable — send "0" to remove it (the asset balance must be 0)
await runTx('change_trust', { asset, limit: '0' });

await refreshAssets(); // refresh trustlineEstablished below
tx.stepidle

Set the asset, then enable or disable its trustline.