Skip to main content

prepareFlowSigning

Locks in the quote and transitions the flow to the signing state. Returns the flow with quote.signingPayload containing the data to sign.
Most integrations should use submitFlowTransaction instead, which calls prepareFlowSigning automatically. Use this function directly only when you need to handle signing and broadcasting yourself (e.g., server-side signing with a custody wallet).

Usage

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

const flow = await prepareFlowSigning({
  flowId: 'your-flow-id',
  assertBalanceForGasCost: true,
  assertBalanceForTransferAmount: true,
});

const { signingPayload } = flow.quote;

Parameters

ParameterTypeDescription
flowIdstringThe flow ID.
assertBalanceForGasCostboolean (optional)Verify the wallet has enough for gas. 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 with executionState: 'signing' and quote.signingPayload populated. The signing payload structure depends on the chain:
ChainFields
EVMevmTransaction (to, data, value, gasLimit) and optional evmApproval (tokenAddress, spenderAddress, amount)
SOL, SUIserializedTransaction (base64-encoded)
BTCpsbt (base64-encoded unsigned PSBT)
TRONtronTransaction (rawDataHex, to, value)

Examples

Prepare with balance assertions

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

const flow = await prepareFlowSigning({
  flowId: 'your-flow-id',
  assertBalanceForGasCost: true,
  assertBalanceForTransferAmount: true,
});

Manual sign and broadcast flow

import { prepareFlowSigning, broadcastFlow } from '@dynamic-labs-sdk/client';

// 1. Prepare
const prepared = await prepareFlowSigning({ flowId: 'your-flow-id' });
const { signingPayload } = prepared.quote;

// 2. Sign with your wallet (EVM example)
const txHash = await walletClient.sendTransaction({
  to: signingPayload.evmTransaction.to,
  data: signingPayload.evmTransaction.data,
  value: BigInt(signingPayload.evmTransaction.value),
});

// 3. Broadcast
await broadcastFlow({ flowId: 'your-flow-id', txHash });