# waitForFlushReceipt

> **waitForFlushReceipt**(`client`, `result`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/type-aliases/outputtype/)\>

Defined in: [packages/synapse-core/src/sp/create-piece-batcher.ts:573](https://github.com/FilOzone/synapse-sdk/blob/56f1ef3fb5ccfea19fb80cb59e997e381f37d85a/packages/synapse-core/src/sp/create-piece-batcher.ts#L573)

Wait for a flushed batch to land on chain and get its piece IDs.

Follows replace-by-fee replacements with [waitForAddPieces](/reference/filoz/synapse-core/sp/functions/waitforaddpieces/). A flush that created the
data set already waited for its transaction, so its outcome is returned without waiting again.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `client` | `Client`\<`Transport`, `Chain`\> | The client to wait with. |
| `result` | [`FlushResult`](/reference/filoz/synapse-core/sp/type-aliases/flushresult/) | The flush result, from [PieceBatcher.flush](/reference/filoz/synapse-core/sp/type-aliases/piecebatcher/#flush) or any piece's result. |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/waitforflushreceipt/type-aliases/optionstype/) | [waitForFlushReceipt.OptionsType](/reference/filoz/synapse-core/sp/namespaces/waitforflushreceipt/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`OutputType`](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/type-aliases/outputtype/)\>

The outcome [waitForFlushReceipt.OutputType](/reference/filoz/synapse-core/sp/namespaces/waitforflushreceipt/type-aliases/outputtype/). `pieceIds[batchIndex]` is a piece's ID.

## Throws

Errors [waitForFlushReceipt.ErrorType](/reference/filoz/synapse-core/sp/namespaces/waitforflushreceipt/type-aliases/errortype/)

## Example

```ts
import { createPieceBatcher, waitForFlushReceipt } from '@filoz/synapse-core/sp'

const batcher = createPieceBatcher(client, { dataSet })
const result = await batcher.upload({ data: file })
const { pieceIds } = await waitForFlushReceipt(client, result)
const pieceId = pieceIds[result.batchIndex]
```