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    appId="app_..."7    recipient="0x..."8    destinationToken="optimismUSDC"9    label="Deposit"10    onSuccess={(result) => console.log(result.depositAddress)}11    onError={(error) => console.error(error.message)}12    onOpenChange={(open) => console.log(open)}13  />14);15}

onSuccess

Called when the payment completes. It receives:

FieldWhat it is
txHashThe first transaction hash on the destination chain, or an empty string if none was reported.
amountThe quoted amount delivered, in the destination token’s smallest units.
depositAddressThe payment’s deposit address. Send this to your server to confirm the payment.
depositMemoThe deposit memo, on chains that use one.
correlationIdA reference for the quote, useful when asking for support.

onSuccess runs in the payer’s browser, so treat it as a hint and not as proof. Before you ship goods or grant access, confirm the payment on your server.

onError

Called when something goes wrong: a mistake in how the button is set up, a quote that was refused, or a payment that failed or was refunded. It always receives a UniportError, with a code and a fixableBy that says who can do something about it. See Errors.

onOpenChange

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