Sign XDR
Sign a transaction that was built somewhere else — a backend, a CLI, another app — with the currently logged-in wallet. Paste the unsigned XDR and either sign + submit in one call, or split signing from submission.
The base64 transaction envelope produced wherever the transaction was built.
One-shot — sign + submit
Split flow — external wallets sign client-side
Paste an XDR and sign to drive the transaction state machine.
import { PollarClient } from '@pollar/core'; const client = new PollarClient({ apiKey, baseUrl }); await client.ready(); // an unsigned XDR built elsewhere — a backend, a CLI, another app const unsignedXdr = unsignedXdr; // one-shot: sign with the logged-in wallet, then submit await client.signAndSubmitTx(unsignedXdr); // …or split it (external wallets sign client-side): const res = await client.signTx(unsignedXdr); if (res.status === 'signed') await client.submitTx(res.signedXdr);
const { signAndSubmitTx, signTx, submitTx } = usePollar(); // one-shot — works for custodial and external wallets await signAndSubmitTx(unsignedXdr); // …or split signing from submission (external wallets only) const res = await signTx(unsignedXdr); if (res.status === 'signed') await submitTx(res.signedXdr);
Hook & values used
All of these come from the usePollar() hook — the react layer built on top of getClient().
signAndSubmitTx(unsignedXdr?)asyncparams: unsignedXdr: string — the envelope built elsewhere. Signs it with the logged-in wallet and submits in one call (custodial or external).
returns: Promise<SubmitOutcome> — { status: 'success' | 'pending', hash } or { status: 'error', … }. Also drives the reactive tx state.
signTx(unsignedXdr)asyncparams: unsignedXdr: string. External-wallet only — the wallet signs client-side. Custodial flows should use signAndSubmitTx.
returns: Promise<SignOutcome> — { status: 'signed', signedXdr } or { status: 'error', … }.
submitTx(signedXdr)asyncparams: signedXdr: string — the signed envelope from signTx. Broadcasts it to the network.
returns: Promise<SubmitOutcome> — { status: 'success' | 'pending', hash } or { status: 'error', … }.
txreactive valueparams: Not a function — a TransactionState read from usePollar(). Re-renders through 'signing' → 'submitting' → 'success' / 'error'.
returns: Mirrors getClient().getTransactionState(): step plus hash / buildData when present.
Functions used
The same methods on the client returned by getClient() — the underlying PollarClient instance.
signAndSubmitTx(unsignedXdr?)asyncparams: unsignedXdr: string — the envelope built elsewhere. One-shot sign + submit with the logged-in wallet.
returns: Promise<SubmitOutcome> — status + hash, or an error.
signTx(unsignedXdr)asyncparams: unsignedXdr: string. External-wallet only — returns the signed XDR without broadcasting.
returns: Promise<SignOutcome> — { status: 'signed', signedXdr } or error.
submitTx(signedXdr)asyncparams: signedXdr: string — broadcast a client-signed envelope.
returns: Promise<SubmitOutcome> — status + hash, or an error.