StorageContext
Defined in: packages/synapse-sdk/src/storage/context.ts:64
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StorageContext( synapse, warmStorageService, provider, dataSetId, options, dataSetMetadata): StorageContext;Defined in: packages/synapse-sdk/src/storage/context.ts:148
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
synapse | Synapse |
warmStorageService | WarmStorageService |
provider | ProviderInfo |
dataSetId | number | undefined |
options | StorageServiceOptions |
dataSetMetadata | Record<string, string> |
Returns
Section titled “Returns”StorageContext
Properties
Section titled “Properties”serviceProvider
Section titled “serviceProvider”readonly serviceProvider: string;Defined in: packages/synapse-sdk/src/storage/context.ts:94
Accessors
Section titled “Accessors”dataSetId
Section titled “dataSetId”Get Signature
Section titled “Get Signature”get dataSetId(): number | undefined;Defined in: packages/synapse-sdk/src/storage/context.ts:112
Returns
Section titled “Returns”number | undefined
dataSetMetadata
Section titled “dataSetMetadata”Get Signature
Section titled “Get Signature”get dataSetMetadata(): Record<string, string>;Defined in: packages/synapse-sdk/src/storage/context.ts:107
Returns
Section titled “Returns”Record<string, string>
provider
Section titled “provider”Get Signature
Section titled “Get Signature”get provider(): ProviderInfo;Defined in: packages/synapse-sdk/src/storage/context.ts:102
Returns
Section titled “Returns”withCDN
Section titled “withCDN”Get Signature
Section titled “Get Signature”get withCDN(): boolean;Defined in: packages/synapse-sdk/src/storage/context.ts:97
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”deletePiece()
Section titled “deletePiece()”deletePiece(piece): Promise<string>;Defined in: packages/synapse-sdk/src/storage/context.ts:1184
Delete a piece with given CID from this data set
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
piece | string | number | PieceLink | The PieceCID identifier or a piece number to delete by pieceID |
Returns
Section titled “Returns”Promise<string>
Transaction hash of the delete operation
download()
Section titled “download()”download(pieceCid, options?): Promise<Uint8Array<ArrayBufferLike>>;Defined in: packages/synapse-sdk/src/storage/context.ts:1072
Download data from this specific service provider
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pieceCid | string | PieceLink | The PieceCID identifier |
options? | DownloadOptions | Download options |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
The downloaded data
getDataSetPieces()
Section titled “getDataSetPieces()”getDataSetPieces(): Promise<PieceLink[]>;Defined in: packages/synapse-sdk/src/storage/context.ts:1104
Get the list of piece CIDs for this service service’s data set.
Returns
Section titled “Returns”Promise<PieceLink[]>
Array of piece CIDs as PieceCID objects
getPieces()
Section titled “getPieces()”getPieces(options?): AsyncGenerator<{ pieceCid: PieceLink; pieceId: number;}>;Defined in: packages/synapse-sdk/src/storage/context.ts:1124
Get all active pieces for this data set as an async generator. This provides lazy evaluation and better memory efficiency for large data sets.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options? | { batchSize?: number; signal?: AbortSignal; } | Optional configuration object |
options.batchSize? | number | The batch size for each pagination call (default: 100) |
options.signal? | AbortSignal | Optional AbortSignal to cancel the operation |
Returns
Section titled “Returns”AsyncGenerator<{
pieceCid: PieceLink;
pieceId: number;
}>
Yields
Section titled “Yields”Object with pieceCid and pieceId - the piece ID is needed for certain operations like deletion
getProviderInfo()
Section titled “getProviderInfo()”getProviderInfo(): Promise<ProviderInfo>;Defined in: packages/synapse-sdk/src/storage/context.ts:1095
Get information about the service provider used by this service
Returns
Section titled “Returns”Provider information including pricing (currently same for all providers)
hasPiece()
Section titled “hasPiece()”hasPiece(pieceCid): Promise<boolean>;Defined in: packages/synapse-sdk/src/storage/context.ts:1199
Check if a piece exists on this service provider.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pieceCid | string | PieceLink | The PieceCID (piece CID) to check |
Returns
Section titled “Returns”Promise<boolean>
True if the piece exists on this provider, false otherwise
pieceStatus()
Section titled “pieceStatus()”pieceStatus(pieceCid): Promise<PieceStatus>;Defined in: packages/synapse-sdk/src/storage/context.ts:1225
Check if a piece exists on this service provider and get its proof status. Also returns timing information about when the piece was last proven and when the next proof is due.
Note: Proofs are submitted for entire data sets, not individual pieces. The timing information returned reflects when the data set (containing this piece) was last proven and when the next proof is due.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pieceCid | string | PieceLink | The PieceCID (piece CID) to check |
Returns
Section titled “Returns”Status information including existence, data set timing, and retrieval URL
preflightUpload()
Section titled “preflightUpload()”preflightUpload(size): Promise<PreflightInfo>;Defined in: packages/synapse-sdk/src/storage/context.ts:822
Run preflight checks for an upload
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
size | number | The size of data to upload in bytes |
Returns
Section titled “Returns”Preflight information including costs and allowances
providerDownload()
Section titled “providerDownload()”providerDownload(pieceCid, options?): Promise<Uint8Array<ArrayBufferLike>>;Defined in: packages/synapse-sdk/src/storage/context.ts:1086
Download data from the service provider
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
pieceCid | string | PieceLink |
options? | DownloadOptions |
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
terminate()
Section titled “terminate()”terminate(): Promise<TransactionResponse>;Defined in: packages/synapse-sdk/src/storage/context.ts:1355
Terminates the data set by sending on-chain message. This will also result in the removal of all pieces in the data set.
Returns
Section titled “Returns”Promise<TransactionResponse>
Transaction response
upload()
Section titled “upload()”upload(data, options?): Promise<UploadResult>;Defined in: packages/synapse-sdk/src/storage/context.ts:838
Upload data to the service provider
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | | ArrayBuffer | Uint8Array<ArrayBufferLike> |
options? | UploadOptions |
Returns
Section titled “Returns”create()
Section titled “create()”static create( synapse, warmStorageService,options): Promise<StorageContext>;Defined in: packages/synapse-sdk/src/storage/context.ts:274
Static factory method to create a StorageContext Handles provider selection and data set selection/creation
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
synapse | Synapse |
warmStorageService | WarmStorageService |
options | StorageServiceOptions |
Returns
Section titled “Returns”Promise<StorageContext>
createContexts()
Section titled “createContexts()”static createContexts( synapse, warmStorageService,options): Promise<StorageContext[]>;Defined in: packages/synapse-sdk/src/storage/context.ts:185
Creates new storage contexts with specified options Each context corresponds to a different data set
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
synapse | Synapse |
warmStorageService | WarmStorageService |
options | CreateContextsOptions |
Returns
Section titled “Returns”Promise<StorageContext[]>
performPreflightCheck()
Section titled “performPreflightCheck()”static performPreflightCheck( warmStorageService, paymentsService, size,withCDN): Promise<PreflightInfo>;Defined in: packages/synapse-sdk/src/storage/context.ts:789
Static method to perform preflight checks for an upload
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
warmStorageService | WarmStorageService | WarmStorageService instance |
paymentsService | PaymentsService | PaymentsService instance |
size | number | The size of data to upload in bytes |
withCDN | boolean | Whether CDN is enabled |
Returns
Section titled “Returns”Preflight check results without provider/dataSet specifics