Skip to main content

prepareCheckoutTransaction

Prepares a checkout transaction for signing. This should be called immediately before triggering the transaction signing. It confirms the quote is still valid, verifies the risk state is cleared, and advances the transaction to a signing-ready state.
In most cases, you should use submitCheckoutTransaction instead, which calls prepareCheckoutTransaction internally and handles the full signing and broadcast flow.

Usage

import { prepareCheckoutTransaction } from '@dynamic-labs-sdk/client';

const transaction = await prepareCheckoutTransaction({
  transactionId: 'txn_abc123',
});

console.log('Ready to sign:', transaction.executionState);

Parameters

ParameterTypeDescription
transactionIdstringThe checkout transaction ID returned by createCheckoutTransaction.

Returns

Promise<CheckoutTransaction> - The updated transaction object with a locked quote and signing-ready state.

Examples

Manual signing flow

Use prepareCheckoutTransaction when you need fine-grained control over the signing process instead of using submitCheckoutTransaction:
import {
  prepareCheckoutTransaction,
  broadcastCheckoutTransaction,
} from '@dynamic-labs-sdk/client';
import { executeSwapTransaction } from '@dynamic-labs-sdk/client';

const manualCheckout = async (transactionId, walletAccount) => {
  // Step 1: Prepare the transaction (locks the quote)
  const prepared = await prepareCheckoutTransaction({ transactionId });

  // Step 2: Execute the on-chain transaction manually
  const { transactionHash } = await executeSwapTransaction({
    walletAccount,
    signingPayload: prepared.quote.signingPayload,
  });

  // Step 3: Record the broadcast
  const result = await broadcastCheckoutTransaction({
    transactionId,
    txHash: transactionHash,
  });

  return result;
};