Skip to main content

broadcastCheckoutTransaction

Records the on-chain broadcast of a checkout transaction by associating a transaction hash with the checkout. This advances the transaction to the broadcasted execution state.
In most cases, you should use submitCheckoutTransaction instead, which handles prepare, sign, and broadcast in one call. Use broadcastCheckoutTransaction directly only when implementing a custom signing flow.

Usage

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

const transaction = await broadcastCheckoutTransaction({
  transactionId: 'txn_abc123',
  txHash: '0x1234567890abcdef...',
});

console.log('Status:', transaction.executionState); // 'broadcasted'

Parameters

ParameterTypeDescription
transactionIdstringThe checkout transaction ID.
txHashstringThe on-chain transaction hash from the wallet signing.

Returns

Promise<CheckoutTransaction> - The updated transaction with the broadcast recorded.

Examples

Custom signing flow

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

const customSubmit = async (transactionId, walletAccount) => {
  // Prepare the transaction
  const prepared = await prepareCheckoutTransaction({ transactionId });

  // Sign and execute on-chain
  const { transactionHash } = await executeSwapTransaction({
    walletAccount,
    signingPayload: prepared.quote.signingPayload,
  });

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

  return result;
};