> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# broadcastFlow

> Report a signed Flow wallet payment's transaction hash with the JavaScript SDK, for integrations that sign the transaction themselves.

Reports the transaction hash of a wallet payment that the payer signed and sent. The flow moves to `broadcasted`, and Dynamic follows the transaction from there. After this call, the payment can no longer be cancelled.

> [!NOTE]
>
> [`submitFlowTransaction`](https://docs.dynamic.xyz/docs/javascript/reference/client/submit-flow-transaction) calls `broadcastFlow` for you. Call it directly only when you sign the transaction yourself after [`prepareFlowSigning`](https://docs.dynamic.xyz/docs/javascript/reference/client/prepare-flow-signing).

## When to call

Call `broadcastFlow` for a wallet source, when `executionState` is `signing` and the wallet returned the transaction hash.

Do not call it for other sources. An exchange payment is confirmed by the exchange, so after the payer opens the purchase link, your page only reads the flow. A deposit is detected at the deposit address, and reporting a hash for a deposit-address flow is rejected.

If a call fails, read the flow with [`getFlow`](https://docs.dynamic.xyz/docs/javascript/reference/client/get-flow) before you try again. A flow in `broadcasted` or later already has the transaction.

## Usage

```javascript theme={"system"}
import { broadcastFlow } from '@dynamic-labs-sdk/client';

const flow = await broadcastFlow({
  flowId: 'your-flow-id',
  txHash: transactionHash,
});
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `flowId` | `string` | The flow ID. |
| `txHash` | `string` | The hash of the transaction the payer's wallet sent. Required. |

> [!NOTE]
>
> The SDK's TypeScript type marks `txHash` as optional, but a wallet source requires it.

## Returns

`Promise<Flow>`: the flow with `executionState: 'broadcasted'` and `txHash` set.

## Errors

| Error | When |
| - | - |
| `FlowStateConflictError` | `flow_invalid_transition`: the flow is not in `signing`, or its source is a deposit address. `flow_tx_hash_already_recorded`: the hash is already recorded, possibly on another flow. `flow_concurrent_update`: another request changed the flow first. |
| `FlowSessionTokenMissingError` | No session token for the flow is stored on this device. |
| `FlowSessionExpiredError` | The server no longer accepts the stored session token. |

After `flow_tx_hash_already_recorded`, read the flow to see whether this flow recorded the hash. Do not retry the same call. [Handle Flow errors](https://docs.dynamic.xyz/docs/javascript/reference/flow-errors.md) describes each error.

## React

`useBroadcastFlow` is a mutation hook. It takes the same parameters, and it writes the returned flow into the `useGetFlow` cache.

```tsx theme={"system"}
import { useBroadcastFlow } from '@dynamic-labs-sdk/react-hooks';

function ReportTransaction({ flowId, txHash }) {
  const { mutate: broadcastFlow, isPending } = useBroadcastFlow();

  return (
    <button onClick={() => broadcastFlow({ flowId, txHash })} disabled={isPending}>
      {isPending ? 'Reporting...' : 'Report transaction'}
    </button>
  );
}
```

## Related

* [`prepareFlowSigning`](https://docs.dynamic.xyz/docs/javascript/reference/client/prepare-flow-signing): get the transaction to sign.
* [`submitFlowTransaction`](https://docs.dynamic.xyz/docs/javascript/reference/client/submit-flow-transaction): prepare, sign, and report in one call.
* [`getFlow`](https://docs.dynamic.xyz/docs/javascript/reference/client/get-flow): follow the payment after it is sent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.