Skip to content

getCreateDataSetAndAddPiecesResult

getCreateDataSetAndAddPiecesResult(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/warm-storage/submission-result.ts:183

Check on chain whether a create data set and add pieces submission landed, without the SP or any transaction hash.

Both happen in one transaction, so the add pieces nonce alone tells whether it landed and gives the data set ID and piece IDs. If created is false, resubmitting the same extraData is safe.

Parameter Type Description
client Client<Transport, Chain> The client to use to read the nonce.
options OptionsType getCreateDataSetAndAddPiecesResult.OptionsType

Promise<OutputType>

The result getCreateDataSetAndAddPiecesResult.OutputType

Errors getCreateDataSetAndAddPiecesResult.ErrorType

import { getCreateDataSetAndAddPiecesResult } from '@filoz/synapse-core/warm-storage'
import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'

const client = createPublicClient({
  chain: calibration,
  transport: http(),
})

// `extraData` and `pieceCount` were persisted from `createDataSetAndAddPieces` before a crash
const result = await getCreateDataSetAndAddPiecesResult(client, {
  extraData: '0x...',
  pieceCount: 1,
})

if (result.created) {
  console.log(result.dataSetId, result.pieceIds)
}