Skip to content

Storage Operations

This guide covers the primary storage API — synapse.storage.upload() — which stores your data with multiple providers for redundancy. For manual control over each upload phase, see Split Operations.

Data Set: A logical container of pieces stored with one provider. When a data set is created, a payment rail is established with that provider. All pieces in the data set share this single payment rail and are verified together via PDP proofs.

PieceCID: Content-addressed identifier for your data (format: bafkzcib...). Automatically calculated during upload and used to retrieve data from any provider.

Metadata: Optional key-value pairs for organization:

  • Data Set Metadata: Max 10 keys (e.g., project, environment)
  • Piece Metadata: Max 5 keys per piece (e.g., filename, contentType)

Copies and Durability: By default, upload() stores your data with 2 independent providers. Each provider maintains its own data set with separate PDP proofs and payment rails. If one provider goes down, your data is still available from the other.

Storage Manager: The main entry point for storage operations (synapse.storage). Handles provider selection, multi-copy orchestration, data set management, and provider-agnostic downloads.

Upload data with a single call — the SDK selects providers and handles multi-copy replication automatically:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk";
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from 'viem/accounts'
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
('0x...'),
SynapseOptions.source: string | null
source
: 'my-app' });
const
const data: Uint8Array<ArrayBuffer>
data
= new
var Uint8Array: Uint8ArrayConstructor
new (elements: Iterable<number>) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
([1, 2, 3, 4, 5])
const {
const pieceCid: PieceLink
pieceCid
,
const size: number
size
,
const complete: boolean
complete
,
const copies: CopyResult[]
copies
,
const failedAttempts: FailedAttempt[]
failedAttempts
} = await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
)
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("PieceCID:",
const pieceCid: PieceLink
pieceCid
.
Link<MerkleTreeNode, RAW_CODE, MulticodecCode<4113, "fr32-sha2-256-trunc254-padded-binary-tree">, 1>.toString<string>(base?: MultibaseEncoder<string> | undefined): ToString<Link<MerkleTreeNode, RAW_CODE, MulticodecCode<4113, "fr32-sha2-256-trunc254-padded-binary-tree">, Version>, string>

Returns a string representation of an object.

toString
())
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Size:",
const size: number
size
, "bytes")
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Stored on",
const copies: CopyResult[]
copies
.
Array<CopyResult>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
, "providers")
for (const
const copy: CopyResult
copy
of
const copies: CopyResult[]
copies
) {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(` Provider ${
const copy: CopyResult
copy
.
CopyResult.providerId: bigint
providerId
}: role=${
const copy: CopyResult
copy
.
CopyResult.role: CopyRole
role
}, dataSet=${
const copy: CopyResult
copy
.
CopyResult.dataSetId: bigint
dataSetId
}`)
}
if (!
const complete: boolean
complete
) {
var console: Console
console
.
Console.warn(...data: any[]): void

The console.warn() static method outputs a warning message to the console at the 'warning' log level.

MDN Reference

warn
("Some copies failed:",
const failedAttempts: FailedAttempt[]
failedAttempts
)
}

The result contains:

  • completetrue when all requested copies were stored and committed on-chain. This is the primary field to check.
  • requestedCopies — the number of copies that were requested (default: 2)
  • pieceCid — content address of your data, used for downloads
  • size — size of the uploaded data in bytes
  • copies — array of successful copies, each with providerId, dataSetId, pieceId, role ('primary' or 'secondary'), retrievalUrl, and isNewDataSet
  • failedAttempts — providers that were tried but did not produce a copy. The SDK retries failed secondaries with alternate providers, so a non-empty array often just means a provider was swapped out. These are diagnostic, check complete for the actual outcome.

Attach metadata to organize uploads. The SDK reuses existing data sets when metadata matches, avoiding duplicate payment rails:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk";
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from 'viem/accounts'
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
('0x...'),
SynapseOptions.source: string | null
source
: 'my-app' });
const
const data: Uint8Array<ArrayBuffer>
data
= new
var TextEncoder: new () => TextEncoder

The TextEncoder interface takes a stream of code points as input and emits a stream of UTF-8 bytes.

MDN Reference

TextEncoder
().
TextEncoder.encode(input?: string): Uint8Array<ArrayBuffer>

The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.

MDN Reference

encode
("Hello, Filecoin!")
const
const result: UploadResult
result
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
, {
BaseContextOptions.metadata?: Record<string, string> | undefined
metadata
: {
type Application: string
Application
: "My DApp",
type Version: string
Version
: "1.0.0",
type Category: string
Category
: "Documents",
},
StorageManagerUploadOptions.pieceMetadata?: Record<string, string> | undefined
pieceMetadata
: {
filename: string
filename
: "hello.txt",
contentType: string
contentType
: "text/plain",
},
})
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Uploaded:",
const result: UploadResult
result
.
UploadResult.pieceCid: PieceLink
pieceCid
.
Link<MerkleTreeNode, RAW_CODE, MulticodecCode<4113, "fr32-sha2-256-trunc254-padded-binary-tree">, 1>.toString<string>(base?: MultibaseEncoder<string> | undefined): ToString<Link<MerkleTreeNode, RAW_CODE, MulticodecCode<4113, "fr32-sha2-256-trunc254-padded-binary-tree">, Version>, string>

Returns a string representation of an object.

toString
())

Subsequent uploads with the same metadata reuse the same data sets and payment rails.

Track the lifecycle of a multi-copy upload with callbacks:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk"
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from "viem/accounts"
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
("0x..."),
SynapseOptions.source: string | null
source
: 'my-app' })
const
const data: Uint8Array<ArrayBuffer>
data
= new
var Uint8Array: Uint8ArrayConstructor
new (length: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
(1024) // 1KB of data
const
const result: UploadResult
result
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
, {
StorageManagerUploadOptions.callbacks?: Partial<CombinedCallbacks> | undefined
callbacks
: {
onStored?: ((providerId: bigint, pieceCid: PieceCID) => void) | undefined
onStored
: (
providerId: bigint
providerId
,
pieceCid: PieceLink
pieceCid
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Data stored on provider ${
providerId: bigint
providerId
}`)
},
onCopyComplete?: ((providerId: bigint, pieceCid: PieceCID) => void) | undefined
onCopyComplete
: (
providerId: bigint
providerId
,
pieceCid: PieceLink
pieceCid
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Secondary copy complete on provider ${
providerId: bigint
providerId
}`)
},
onCopyFailed?: ((providerId: bigint, pieceCid: PieceCID, error: Error) => void) | undefined
onCopyFailed
: (
providerId: bigint
providerId
,
pieceCid: PieceLink
pieceCid
,
error: Error
error
) => {
var console: Console
console
.
Console.warn(...data: any[]): void

The console.warn() static method outputs a warning message to the console at the 'warning' log level.

MDN Reference

warn
(`Copy failed on provider ${
providerId: bigint
providerId
}:`,
error: Error
error
.
Error.message: string
message
)
},
onPullProgress?: ((providerId: bigint, pieceCid: PieceCID, status: PullStatus) => void) | undefined
onPullProgress
: (
providerId: bigint
providerId
,
pieceCid: PieceLink
pieceCid
,
status: PullStatus
status
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Pull to provider ${
providerId: bigint
providerId
}: ${
status: PullStatus
status
}`)
},
onPiecesAdded?: ((transaction: Hex, providerId: bigint, pieces: {
pieceCid: PieceCID;
}[]) => void) | undefined
onPiecesAdded
: (
txHash: `0x${string}`
txHash
,
providerId: bigint
providerId
,
pieces: {
pieceCid: PieceCID;
}[]
pieces
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`On-chain commit submitted: ${
txHash: `0x${string}`
txHash
}`)
},
onPiecesConfirmed?: ((dataSetId: bigint, providerId: bigint, pieces: PieceRecord[]) => void) | undefined
onPiecesConfirmed
: (
dataSetId: bigint
dataSetId
,
providerId: bigint
providerId
,
pieces: PieceRecord[]
pieces
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Confirmed on-chain: dataSet=${
dataSetId: bigint
dataSetId
}, provider=${
providerId: bigint
providerId
}`)
},
onProgress?: ((bytesUploaded: number) => void) | undefined
onProgress
: (
bytesUploaded: number
bytesUploaded
) => {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Uploaded ${
bytesUploaded: number
bytesUploaded
} bytes`)
},
},
})

Callback lifecycle:

  1. onProgress — fires during upload to primary provider
  2. onStored — primary upload complete, piece parked on SP
  3. onPullProgress — SP-to-SP transfer status for secondaries
  4. onCopyComplete / onCopyFailed — secondary pull result
  5. onPiecesAdded — commit transaction submitted
  6. onPiecesConfirmed — commit confirmed on-chain

Adjust the number of copies for your durability requirements:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk"
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from "viem/accounts"
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
("0x..."),
SynapseOptions.source: string | null
source
: 'my-app' })
const
const data: Uint8Array<ArrayBuffer>
data
= new
var Uint8Array: Uint8ArrayConstructor
new (length: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
(256)
// Store 3 copies for higher redundancy
const
const result3: UploadResult
result3
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
, {
CreateContextsOptions.copies?: number | undefined
copies
: 3 })
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("3 copies:",
const result3: UploadResult
result3
.
UploadResult.copies: CopyResult[]
copies
.
Array<CopyResult>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
)
// Store a single copy when redundancy isn't needed
const
const result1: UploadResult
result1
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
, {
CreateContextsOptions.copies?: number | undefined
copies
: 1 })
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("1 copy:",
const result1: UploadResult
result1
.
UploadResult.copies: CopyResult[]
copies
.
Array<CopyResult>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
)

The default is 2 copies. The first copy is stored on an endorsed provider (high trust, curated), and secondary copies are pulled via SP-to-SP transfer from approved providers.

upload() is designed around partial success over atomicity: it commits whatever succeeded rather than throwing away successful work. This means the return value is the primary interface for understanding what happened — not just whether it threw.

upload() only throws in these cases:

ErrorWhat happenedWhat to do
StoreErrorPrimary upload failed — no data committed anywhereRetry the upload
CommitErrorData is stored on providers but all on-chain commits failedUse split operations to retry commit() without re-uploading
Selection errorNo endorsed provider available or reachableCheck provider health / network

If upload() returns (no throw), at least one copy is committed on-chain. But the result may contain fewer copies than requested. Every copy in copies[] represents a committed on-chain data set that the user is now paying for.

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk"
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from "viem/accounts"
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
("0x..."),
SynapseOptions.source: string | null
source
: 'my-app' })
const
const data: Uint8Array<ArrayBuffer>
data
= new
var Uint8Array: Uint8ArrayConstructor
new (length: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array
(256)
const
const result: UploadResult
result
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.upload(data: UploadPieceStreamingData, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload
(
const data: Uint8Array<ArrayBuffer>
data
, {
CreateContextsOptions.copies?: number | undefined
copies
: 2 })
// Check overall success: complete === true means all requested copies succeeded
if (!
const result: UploadResult
result
.
UploadResult.complete: boolean
complete
) {
var console: Console
console
.
Console.warn(...data: any[]): void

The console.warn() static method outputs a warning message to the console at the 'warning' log level.

MDN Reference

warn
(`Only ${
const result: UploadResult
result
.
UploadResult.copies: CopyResult[]
copies
.
Array<CopyResult>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
}/${
const result: UploadResult
result
.
UploadResult.requestedCopies: number
requestedCopies
} copies succeeded`)
for (const
const attempt: FailedAttempt
attempt
of
const result: UploadResult
result
.
UploadResult.failedAttempts: FailedAttempt[]
failedAttempts
) {
var console: Console
console
.
Console.warn(...data: any[]): void

The console.warn() static method outputs a warning message to the console at the 'warning' log level.

MDN Reference

warn
(` Provider ${
const attempt: FailedAttempt
attempt
.
FailedAttempt.providerId: bigint
providerId
} (${
const attempt: FailedAttempt
attempt
.
FailedAttempt.role: CopyRole
role
}): ${
const attempt: FailedAttempt
attempt
.
FailedAttempt.error: string
error
}`)
}
}
// Every copy is committed and being paid for
for (const
const copy: CopyResult
copy
of
const result: UploadResult
result
.
UploadResult.copies: CopyResult[]
copies
) {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Provider ${
const copy: CopyResult
copy
.
CopyResult.providerId: bigint
providerId
}, dataset ${
const copy: CopyResult
copy
.
CopyResult.dataSetId: bigint
dataSetId
}, piece ${
const copy: CopyResult
copy
.
CopyResult.pieceId: bigint
pieceId
}`)
}

For auto-selected providers (no explicit providerIds or dataSetIds), the SDK automatically retries failed secondaries with alternate providers up to 5 times. If you explicitly specify providers, the SDK respects your choice and does not retry.

Download from any provider that has the piece — the SDK resolves the provider automatically:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk"
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from "viem/accounts"
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
("0x..."),
SynapseOptions.source: string | null
source
: 'my-app' })
// Download using PieceCID from a previous upload
const
const pieceCid: "bafkzcib..."
pieceCid
= "bafkzcib..." // from upload result
const
const bytes: Uint8Array<ArrayBufferLike>
bytes
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.download(options: StorageManagerDownloadOptions): Promise<Uint8Array>
download
({
pieceCid: string | PieceLink
pieceCid
})
const
const text: string
text
= new
var TextDecoder: new (label?: string, options?: TextDecoderOptions) => TextDecoder

The TextDecoder interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, KOI8-R, GBK, etc.

MDN Reference

TextDecoder
().
TextDecoder.decode(input?: AllowSharedBufferSource, options?: TextDecodeOptions): string

The TextDecoder.decode() method returns a string containing text decoded from the buffer passed as a parameter.

MDN Reference

decode
(
const bytes: Uint8Array<ArrayBufferLike>
bytes
)
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Downloaded:",
const text: string
text
)

For CDN-accelerated downloads:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk"
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from "viem/accounts"
// Enable CDN globally
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
("0x..."),
SynapseOptions.source: string | null
source
: 'my-app',
SynapseOptions.withCDN?: boolean | undefined
withCDN
: true,
})
const
const bytes: Uint8Array<ArrayBufferLike>
bytes
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.download(options: StorageManagerDownloadOptions): Promise<Uint8Array>
download
({
pieceCid: string | PieceLink
pieceCid
: "bafkzcib..." })
// Or per-download:
const
const bytes2: Uint8Array<ArrayBufferLike>
bytes2
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.download(options: StorageManagerDownloadOptions): Promise<Uint8Array>
download
({
pieceCid: string | PieceLink
pieceCid
: "bafkzcib...",
withCDN?: boolean | undefined
withCDN
: true,
})

Retrieve all data sets owned by your account to inspect piece counts, CDN status, and metadata:

import {
class Synapse
Synapse
} from "@filoz/synapse-sdk";
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from 'viem/accounts'
const
const synapse: Synapse
synapse
=
class Synapse
Synapse
.
Synapse.create(options: SynapseOptions): Synapse
create
({
SynapseOptions.account: `0x${string}` | Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
('0x...'),
SynapseOptions.source: string | null
source
: 'my-app' });
const
const dataSets: EnhancedDataSetInfo[]
dataSets
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.findDataSets(options?: {
address?: Address;
}): Promise<EnhancedDataSetInfo[]>
findDataSets
();
for (const
const ds: EnhancedDataSetInfo
ds
of
const dataSets: EnhancedDataSetInfo[]
dataSets
) {
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Dataset ${
const ds: EnhancedDataSetInfo
ds
.
EnhancedDataSetInfo.pdpVerifierDataSetId: bigint
pdpVerifierDataSetId
}:`, {
live: boolean
live
:
const ds: EnhancedDataSetInfo
ds
.
EnhancedDataSetInfo.isLive: boolean
isLive
,
cdn: boolean
cdn
:
const ds: EnhancedDataSetInfo
ds
.
EnhancedDataSetInfo.withCDN: boolean
withCDN
,
pieces: bigint
pieces
:
const ds: EnhancedDataSetInfo
ds
.
EnhancedDataSetInfo.activePieceCount: bigint
activePieceCount
,
metadata: Record<string, string>
metadata
:
const ds: EnhancedDataSetInfo
ds
.
EnhancedDataSetInfo.metadata: Record<string, string>
metadata
});
}

List all pieces stored in a specific data set by iterating through a context:

const
const context: StorageContext
context
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.createContext(options?: StorageServiceOptions): Promise<StorageContext>
createContext
({
StorageServiceOptions.dataSetId?: bigint | undefined
dataSetId
});
const
const pieces: any[]
pieces
= [];
for await (const
const piece: PieceRecord
piece
of
const context: StorageContext
context
.
StorageContext.getPieces(options?: {
batchSize?: bigint;
}): AsyncGenerator<PieceRecord>
getPieces
()) {
const pieces: any[]
pieces
.
Array<any>.push(...items: any[]): number

Appends new elements to the end of an array, and returns the new length of the array.

@paramitems New elements to add to the array.

push
(
const piece: PieceRecord
piece
);
}
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Found ${
const pieces: any[]
pieces
.
Array<any>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
} pieces`);

Access custom metadata attached to individual pieces:

import {
class WarmStorageService
WarmStorageService
} from "@filoz/synapse-sdk/warm-storage";
import {
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
} from 'viem/accounts'
const
const warmStorage: WarmStorageService
warmStorage
=
class WarmStorageService
WarmStorageService
.
WarmStorageService.create(options: {
transport?: Transport;
chain?: Chain;
account: Account;
}): WarmStorageService
create
({
account: Account
account
:
function privateKeyToAccount(privateKey: Hex, options?: PrivateKeyToAccountOptions): PrivateKeyAccount

@description Creates an Account from a private key.

@returnsA Private Key Account.

privateKeyToAccount
('0x...') });
const
const metadata: MetadataObject
metadata
= await
const warmStorage: WarmStorageService
warmStorage
.
WarmStorageService.getPieceMetadata(options: {
dataSetId: bigint;
pieceId: bigint;
}): Promise<MetadataObject>
getPieceMetadata
({
dataSetId: bigint
dataSetId
,
pieceId: bigint
pieceId
:
const piece: {
pieceCid: string;
pieceId: bigint;
}
piece
.
pieceId: bigint
pieceId
});
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Piece metadata:",
const metadata: MetadataObject
metadata
);

Extract the size directly from a PieceCID using Synapse Core:

import {
function getSizeFromPieceCID(pieceCidInput: PieceCID | CID | string): number
getSizeFromPieceCID
} from "@filoz/synapse-core/piece";
const
const pieceCid: "bafkzcib..."
pieceCid
= "bafkzcib...";
const
const size: number
size
=
function getSizeFromPieceCID(pieceCidInput: PieceCID | CID | string): number
getSizeFromPieceCID
(
const pieceCid: "bafkzcib..."
pieceCid
);
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
(`Piece size: ${
const size: number
size
} bytes`);

Query service-wide pricing, available providers, and network parameters:

const
const info: StorageInfo
info
= await
const synapse: Synapse
synapse
.
Synapse.storage: StorageManager
storage
.
StorageManager.getStorageInfo(): Promise<StorageInfo>
getStorageInfo
();
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Price/TiB/month:",
const info: StorageInfo
info
.
StorageInfo.pricing: {
noCDN: {
perTiBPerMonth: bigint;
perTiBPerDay: bigint;
perTiBPerEpoch: bigint;
};
withCDN: {
perTiBPerMonth: bigint;
perTiBPerDay: bigint;
perTiBPerEpoch: bigint;
};
tokenAddress: Address;
tokenSymbol: string;
}
pricing
.
noCDN: {
perTiBPerMonth: bigint;
perTiBPerDay: bigint;
perTiBPerEpoch: bigint;
}
noCDN
.
perTiBPerMonth: bigint
perTiBPerMonth
);
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("Providers:",
const info: StorageInfo
info
.
StorageInfo.providers: PDPProvider[]
providers
.
Array<PDPProvider>.length: number

Gets or sets the length of the array. This is a number one higher than the highest index in the array.

length
);
const
const providerInfo: PDPProvider
providerInfo
= await
const synapse: Synapse
synapse
.
Synapse.getProviderInfo(providerAddress: Address | bigint): Promise<PDPProvider>
getProviderInfo
("0x...");
var console: Console
console
.
Console.log(...data: any[]): void

The console.log() static method outputs a message to the console.

MDN Reference

log
("PDP URL:",
const providerInfo: PDPProvider
providerInfo
.
PDPProvider.pdp: PDPOffering
pdp
.
PDPOffering.serviceURL: string
serviceURL
);
  • Split Operations — Manual control over store, pull, and commit phases for batch uploads, custom error handling, and direct core library usage.

  • Plan Storage Costs — Calculate your monthly costs and understand funding requirements.

  • Payment Management — Manage deposits, approvals, and payment rails.