# waitForAddPieces

> **waitForAddPieces**(`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/wait-for-receipt.ts:190](https://github.com/FilOzone/synapse-sdk/blob/840d7b2c6263846ac51b7558000e62dd68d33a44/packages/synapse-core/src/sp/wait-for-receipt.ts#L190)

Wait for an add pieces transaction on chain, following replace-by-fee replacements.

Uses viem's `waitForTransactionReceipt` on the hash the SP returned, so a sped-up or repriced
replacement resolves with its own hash in `confirmedTxHash`. If the wait times out, it checks the
nonce FWSS records before failing, in case a replacement landed unnoticed.

For recovery after a crash, call `getAddPiecesResult` with the persisted `extraData` instead:
after a replacement the original hash can no longer be looked up.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/type-aliases/optionstype/) | [waitForAddPieces.OptionsType](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/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 [waitForAddPieces.OutputType](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/type-aliases/outputtype/)

## Example

```ts
const result = await SP.addPieces(client, options)
const { dataSetId, pieceIds, confirmedTxHash } = await SP.waitForAddPieces({ client, ...result })
```

## Throws

Errors [waitForAddPieces.ErrorType](/reference/filoz/synapse-core/sp/namespaces/waitforaddpieces/type-aliases/errortype/). [TransactionNotAppliedError](/reference/filoz/synapse-core/errors/classes/transactionnotappliederror/) when the landed transaction reverted or was a cancellation.