UniportDocs

Callbacks

Three optional props tell your app what happened in the deposit modal.

Usage

DepositAction.tsx
1import { UniportButton } from "uniport-sdk";23export function DepositAction() {4return (5  <UniportButton6    recipient="0x..."7    destinationToken="optimismUSDC"8    label="Deposit"9    onSuccess={(result) => console.log(result.txHash)}10    onError={(error) => console.error(error.message)}11    onOpenChange={(open) => console.log(open)}12  />13);14}

onSuccess

Called when the payment completes. It receives { txHash: string; amount: string }.

onError

Called when the payment fails. It receives an Error. Failures from Uniport’s backend arrive as a UniportError with a code; see Errors.

onOpenChange

Called with true when the modal opens and false when it closes.