getPiecesWithMetadata
getPiecesWithMetadata(
client,options):Promise<OutputType>
Defined in: packages/synapse-core/src/pdp-verifier/get-pieces.ts:191
Get one bounded page of visible pieces and their metadata.
The source cursor is preserved when scheduled-removal filtering produces
fewer or no visible items. Treat nextCursor as opaque and use
paginate to traverse every page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain> | The client to use to get the pieces with metadata. |
options | { address: `0x${string}`; contractAddress?: `0x${string}`; cursor?: bigint; dataSet: PdpDataSet; limit?: bigint; } | getPiecesWithMetadata.OptionsType |
options.address | `0x${string}` | The address of the user. |
options.contractAddress? | `0x${string}` | Optional PDPVerifier contract address override. |
options.cursor? | bigint | Opaque continuation cursor returned by the previous page. Defaults to 0n. |
options.dataSet | PdpDataSet | The data set to get the pieces from. |
options.limit? | bigint | Maximum number of items to return. Must be greater than 0n. |
Returns
Section titled “Returns”The active pieces for the data set getPiecesWithMetadata.OutputType
Examples
Section titled “Examples”Read the first page
import { getPiecesWithMetadata } from '@filoz/synapse-core/pdp-verifier'import { calibration } from '@filoz/synapse-core/chains'import { createPublicClient, http } from 'viem'
const client = createPublicClient({ chain: calibration, transport: http(),})
const address = '0x0000000000000000000000000000000000000000'const page = await getPiecesWithMetadata(client, { dataSet, address })console.log(page.items, page.nextCursor)Iterate over every page
import { paginate } from '@filoz/synapse-core'import { getPiecesWithMetadata } from '@filoz/synapse-core/pdp-verifier'
for await (const piece of paginate(({ cursor }) => getPiecesWithMetadata(client, { dataSet, address, cursor }))) { console.log(piece.id, piece.metadata)}