Skip to main content

submitFlowTransaction

Prepares, signs, and broadcasts a flow transaction in one call. This is the recommended way to submit — it handles the full sequence:
  1. Calls prepareFlowSigning to lock the quote and get the signing payload
  2. Switches the wallet to the correct network
  3. Signs the transaction (including ERC-20 approval if needed)
  4. Calls broadcastFlow with the resulting txHash

Usage

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

const flow = await submitFlowTransaction({
  flowId: 'your-flow-id',
  walletAccount,
});

console.log('Broadcasted:', flow.txHash);

Parameters

ParameterTypeDescription
flowIdstringThe flow ID.
walletAccountWalletAccountThe wallet account to sign with. Get this from the Dynamic SDK’s wallet management (e.g., useWalletAccounts() in React hooks).
onStepChange(step: 'approval' | 'transaction') => void (optional)Callback fired when the signing step changes — useful for showing progress UI.
assertBalanceForGasCostboolean (optional)Verify the wallet has enough for gas before signing. Returns 422 if insufficient. Default: false.
assertBalanceForTransferAmountboolean (optional)Verify the wallet has enough for the transfer. Returns 422 if insufficient. Default: false.

Returns

Promise<Flow> — the flow after broadcast, with executionState: 'broadcasted' and txHash populated.

Examples

Basic submission

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

const flow = await submitFlowTransaction({
  flowId: 'your-flow-id',
  walletAccount,
});

With balance assertions and step tracking

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

const flow = await submitFlowTransaction({
  flowId: 'your-flow-id',
  walletAccount,
  assertBalanceForGasCost: true,
  assertBalanceForTransferAmount: true,
  onStepChange: (step) => {
    console.log('Current step:', step);
    // 'approval' — signing ERC-20 token approval
    // 'transaction' — signing the main transaction
  },
});

Handle wallet rejection

import { submitFlowTransaction, cancelFlow } from '@dynamic-labs-sdk/client';

try {
  await submitFlowTransaction({
    flowId: 'your-flow-id',
    walletAccount,
  });
} catch (error) {
  if (error.message.includes('rejected')) {
    await cancelFlow({ flowId: 'your-flow-id' });
  }
}