# waitForDeletePieces

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

Defined in: [packages/synapse-core/src/sp/wait-for-receipt.ts:329](https://github.com/FilOzone/synapse-sdk/blob/5989c4b03ed2fe4cf8b1ef29efe1d4ff1ad4c7bc/packages/synapse-core/src/sp/wait-for-receipt.ts#L329)

Wait for a schedule piece deletions transaction on chain, following replace-by-fee replacements.

The pieces are scheduled for removal, not removed: PDPVerifier removes them later, through
`processPieceDeletions`. Resolves once `PiecesScheduledForRemoval` events for the data set cover
every requested piece. PDPVerifier emits the IDs in chunks, so all matching events are collected.

If the receipt wait times out, or a replacement with different calldata landed, it checks the data
set's scheduled removals instead. That check cannot see pieces that were already removed: after a
timeout it rethrows the timeout, and after a replacement it throws [TransactionNotAppliedError](/reference/filoz/synapse-core/errors/classes/transactionnotappliederror/).

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/waitfordeletepieces/type-aliases/optionstype/) | [waitForDeletePieces.OptionsType](/reference/filoz/synapse-core/sp/namespaces/waitfordeletepieces/type-aliases/optionstype/) |

## Returns

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

The outcome [waitForDeletePieces.OutputType](/reference/filoz/synapse-core/sp/namespaces/waitfordeletepieces/type-aliases/outputtype/)

## Example

```ts
const result = await SP.schedulePieceDeletions(client, options)
const { pieceIds, confirmedTxHash } = await SP.waitForDeletePieces({ client, ...result })
```

## Throws

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