Escrow
Trustless Work adapter — the SDK signs and submits the unsigned XDR with the connected wallet, so your code only deals with business params.
Defaults to your wallet address.
one-time adapter setup
// adapter.ts — register once in your app
export const trustlessWorkAdapter: TrustlessWorkAdapter = {
deployEscrow: (p) => tw('/escrow/initialize-escrow', p),
fundEscrow: (p) => tw('/escrow/fund-escrow', p),
approveMilestone: (p) => tw('/escrow/approve-milestone', p),
releaseFunds: (p) => tw('/escrow/complete-escrow', p),
initiateDispute: (p) => tw('/escrow/dispute-escrow', p),
resolveDispute: (p) => tw('/escrow/resolute-dispute', p),
};
// each adapter fn must return { unsignedTransaction: string }.
// Pollar then signs + submits with the user's wallet automatically.
export const useEscrow =
createPollarAdapterHook<TrustlessWorkAdapter>('escrow');import { PollarClient } from '@pollar/core'; import { trustlessWorkAdapter } from './adapter'; const client = new PollarClient({ apiKey, baseUrl }); await client.ready(); // the adapter hits Trustless Work → returns an unsigned XDR const { unsignedTransaction } = await trustlessWorkAdapter.deployEscrow({ engagementId: 'unique-id-001', title: 'Web development contract', description: '...', approver: 'G...', serviceProvider: 'G...', platformAddress: 'G...', amount: '100', platformFee: '0', signer: 'G...', }); // Pollar signs + submits with the connected wallet await client.signAndSubmitTx(unsignedTransaction);
const { deployEscrow } = useEscrow(); // adapter calls Trustless Work → returns unsigned XDR. // Pollar signs + submits with the user's wallet automatically. await deployEscrow({ engagementId: 'unique-id-001', title: 'Web development contract', description: '...', approver: 'G...', serviceProvider: 'G...', platformAddress: 'G...', amount: '100', platformFee: '0', signer: 'G...', });
Trigger an operation to see signing progress.
@pollar/react — hook & values used
All of these come from the usePollar() hook (plus the adapter factory) — the react layer built on top of getClient().
usePollar()hookparams: No arguments. Call it at the top level of a component — it reads React context, so it must run during render.
returns: PollarContextValue — the whole SDK surface: reactive state values, modal openers, and getClient() to drop down to core.
createPollarAdapterHook(key)factoryparams: key: string — the adapter slot registered on the provider (e.g. 'escrow'). Call it once at module scope.
returns: A typed hook (e.g. useEscrow) whose methods each return Promise<SubmitOutcome> — adapter → unsigned XDR → auto sign + submit.
openTxModal()syncparams: No arguments.
returns: void — opens the prebuilt review/sign modal for the in-flight escrow tx.
txreactive valueparams: Not a function — a value of type TransactionState read from usePollar().
returns: Re-renders through the auto sign-and-submit flow (building → signing → submitting → success).
@pollar/core — functions used
All of these are methods on the client returned by getClient() — the underlying PollarClient instance.
signAndSubmitTx(unsignedXdr?)asyncparams: unsignedXdr?: string — the unsigned XDR the escrow adapter returns from Trustless Work. Omit it for custodial flows.
returns: Promise<SubmitOutcome> — signs the XDR with the connected wallet and broadcasts it; { status, hash, … }.
getTransactionState()syncparams: No arguments.
returns: TransactionState — the auto-sign-and-submit progress; null before any tx runs.