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()syncparams: 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()asyncparams: 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 valueparams: 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.
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> ); }
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.
Trustline functions
setTrustline is the path to reach for: it picks the route by wallet type and lets each server endpoint sponsor or self-pay. runTx('change_trust') stays as the manual, always self-paid escape hatch. All come from usePollar() (or the underlying PollarClient via getClient()).
setTrustline(asset, opts?)asyncparams: asset: { code, issuer }; opts.limit?: string ('0' removes the trustline, omitted = max); opts.skipSponsorship?: boolean — force self-pay even when the app would sponsor.
returns: Promise<TrustlineOutcome> — status: 'success' | 'pending' | 'error'. Custodial wallets get one server call; an external wallet gets a sponsor-signed XDR to co-sign. Does NOT refresh on its own.
runTx(operation, params, options?)asyncparams: 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, always paid by the user. This is what setTrustline falls back to under skipSponsorship.
buildTx(operation, params, options?)asyncparams: 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()asyncparams: No arguments.
returns: Promise<void> — re-fetches the enabled-assets table so trustlineEstablished reflects the change_trust you just submitted.
import { PollarClient } from '@pollar/core'; const client = new PollarClient({ apiKey, baseUrl }); await client.ready(); // Sponsorship is decided server-side from the app's dashboard // config. Omit skipSponsorship and the app pays when eligible. await client.setTrustline({ code: "USDC", issuer: "G..." }); // disable — limit "0" removes it (the asset balance must be 0) await client.setTrustline({ code: "USDC", issuer: "G..." }, { limit: '0' }); // setTrustline does not refresh on its own await client.refreshAssets(); // The manual escape hatch, always self-paid — this is what // setTrustline falls back to when skipSponsorship is set: // await client.runTx('change_trust', { asset: { type: "credit_alphanum4", code: "USDC", issuer: "G..." } });
import { usePollar } from '@pollar/react'; const { setTrustline, refreshAssets } = usePollar(); // Sponsorship is decided server-side from the app's dashboard // config. Omit skipSponsorship and the app pays when eligible. await setTrustline({ code: "USDC", issuer: "G..." }); // disable — limit "0" removes it (the asset balance must be 0) await setTrustline({ code: "USDC", issuer: "G..." }, { limit: '0' }); // setTrustline does not refresh on its own await refreshAssets(); // The manual escape hatch, always self-paid — this is what // setTrustline falls back to when skipSponsorship is set: // await runTx('change_trust', { asset: { type: "credit_alphanum4", code: "USDC", issuer: "G..." } });
Set the asset, then enable or disable its trustline.
tx.step only moves on the self-pay route — the sponsored endpoints submit server-side and never enter the transaction machine.