Skip to content

Submit

Submit a transfer plan with useWalletTransfer. The user confirms in the wallet. Does not require WalletsProvider — but you still need a connected walletId on the plan.

Same submit / retry as Submit (Core). If result.status === 'requires_retry', the wallet already signed and sent. Show Retry — do not submit again.

Ready to submit

Use this checklist to enable the confirm button. submit still validates the same things and will throw if something is missing — this is only for UI.

  1. Session view is active
  2. Connection status === 'connected'
  3. Token is eligible
  4. plan.flow !== 'unavailable'
  5. Amount is valid (useDualAmountInput().isValid)
  6. Not already in requires_retry (then show Retry instead)

useWalletTransferQuote is for the UI (receive amount, fees, ETA). submit only takes plan and amount.

Example

tsx
import {
  ConnectSdkError,
  ConnectSdkErrorCode,
} from '@swapped/connect-sdk'
import { useWalletTransfer } from '@swapped/connect-sdk/react'

function Confirm({
  plan,
  amount,
}: {
  plan: WalletTransferPlan
  amount: string
}) {
  const { submit, retry, result, isPending, error } = useWalletTransfer()

  return (
    <div>
      <button
        type="button"
        disabled={
          isPending ||
          plan.flow === 'unavailable' ||
          result?.status === 'requires_retry'
        }
        onClick={() =>
          void submit({
            plan,
            amount,
            onStatus: event => {
              event.status
            },
          })
        }
      >
        {isPending ? 'Confirming…' : 'Confirm in wallet'}
      </button>

      {result?.status === 'requires_retry' ? (
        <button
          type="button"
          disabled={isPending}
          onClick={() => void retry()}
        >
          Retry
        </button>
      ) : null}

      {error instanceof ConnectSdkError &&
      error.code !== ConnectSdkErrorCode.WALLET_TRANSACTION_REJECTED ? (
        <p>
          {error.code === ConnectSdkErrorCode.WALLET_TRANSFER_INSUFFICIENT_FEE
            ? 'Not enough to cover fees'
            : 'Transfer failed'}
        </p>
      ) : null}
    </div>
  )
}

Branch on ConnectSdkError.code — see Errors. User cancel (WALLET_TRANSACTION_REJECTED) is silent here.

submit options

OptionMeaning
planTransfer plan from useWalletTransferPlan
amountSource crypto string
onStatus?Status events for this submit

Returns

FieldMeaning
submit(request)Returns WalletTransferResult | null (null on throw; error is on error)
retry()Returns WalletTransferResult | null
resultLast WalletTransferResult (status, hash, …)
isPendingSubmit or retry in flight
errorLast thrown error
resetClear result / error

requires_retry

The wallet already signed / sent. Registration with Swapped failed. If result.status === 'requires_retry', call retry(). Do not submit again.

submit throws WALLET_TRANSFER_REQUIRES_RETRY (and the hook sets error) if a previous submit already returned requires_retry.

Status values: Submit (Core).