Skip to content

WarmStorageService

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:52

new WarmStorageService(options): WarmStorageService

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:63

Create a new WarmStorageService instance

ParameterTypeDescription
options{ client: Client<Transport, Chain, Account>; }Options for the WarmStorageService
options.clientClient<Transport, Chain, Account>Wallet client

WarmStorageService

A new WarmStorageService instance

addApprovedProvider(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:585

Add an approved provider by ID (owner only)

ParameterTypeDescription
options{ providerId: bigint; }Options for the approved provider addition
options.providerIdbigintProvider ID from registry

Promise<`0x${string}`>

Transaction response


calculateStorageCost(options): Promise<{ perDay: bigint; perEpoch: bigint; perMonth: bigint; withCDN: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; }>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:327

Calculate storage costs for a given size

ParameterTypeDescription
options{ sizeInBytes: bigint; }Options for the storage cost
options.sizeInBytesbigintSize of data to store in bytes

Promise<{ perDay: bigint; perEpoch: bigint; perMonth: bigint; withCDN: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; }>

Cost estimates per epoch, day, and month

CDN costs are usage-based (egress pricing), so withCDN field reflects base storage cost only


checkAllowanceForStorage(options): Promise<{ costs: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; currentLockupAllowance: bigint; currentLockupUsed: bigint; currentRateAllowance: bigint; currentRateUsed: bigint; depositAmountNeeded: bigint; lockupAllowanceNeeded: bigint; message?: string; rateAllowanceNeeded: bigint; sufficient: boolean; }>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:368

Check if user has sufficient allowances for a storage operation and calculate costs

ParameterTypeDescription
options{ address?: `0x${string}`; lockupDays?: bigint; operator?: `0x${string}`; sizeInBytes: bigint; withCDN: boolean; }Options for the allowance check
options.address?`0x${string}`Address of the account to check allowances for (optional, defaults to the client account address)
options.lockupDays?bigintNumber of days for lockup period (defaults to 30)
options.operator?`0x${string}`Address of the operator to check allowances for (optional, defaults to the WarmStorage contract address)
options.sizeInBytesbigintSize of data to store
options.withCDNbooleanWhether CDN is enabled

Promise<{ costs: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; currentLockupAllowance: bigint; currentLockupUsed: bigint; currentRateAllowance: bigint; currentRateUsed: bigint; depositAmountNeeded: bigint; lockupAllowanceNeeded: bigint; message?: string; rateAllowanceNeeded: bigint; sufficient: boolean; }>

Allowance requirement details and storage costs


getActivePieceCount(options): Promise<bigint>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:244

Get the count of active pieces in a dataset (excludes removed pieces)

ParameterTypeDescription
options{ dataSetId: bigint; }Options for the data set
options.dataSetIdbigintThe PDPVerifier data set ID

Promise<bigint>

The number of active pieces


getApprovedProviderIds(): Promise<OutputType>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:611

Get list of approved provider IDs

Promise<OutputType>

Array of approved provider IDs


getClientDataSets(options): Promise<OutputType>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:112

Get all data sets for a specific client

ParameterTypeDescription
options{ address: `0x${string}`; }Options for the client data sets
options.address`0x${string}`The client address

Promise<OutputType>

Array of data set information getClientDataSets.OutputType

Errors getClientDataSets.ErrorType


getClientDataSetsWithDetails(options): Promise<EnhancedDataSetInfo[]>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:124

Get all data sets for a client with enhanced details This includes live status and management information

ParameterTypeDescription
options{ address?: `0x${string}`; onlyManaged?: boolean; }Options for the client data sets
options.address?`0x${string}`The client address
options.onlyManaged?booleanIf true, only return data sets managed by this Warm Storage contract

Promise<EnhancedDataSetInfo[]>

Array of enhanced data set information EnhancedDataSetInfo


getDataSet(options): Promise<OutputType>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:101

Get a single data set by ID

ParameterTypeDescription
options{ dataSetId: bigint; }Options for the data set
options.dataSetIdbigintThe data set ID to retrieve

Promise<OutputType>

Data set information getDataSet.OutputType

Errors getDataSet.ErrorType


getDataSetMetadata(options): Promise<MetadataObject>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:257

Get all metadata for a data set

ParameterTypeDescription
options{ dataSetId: bigint; }Options for the data set
options.dataSetIdbigintThe data set ID

Promise<MetadataObject>

Object with metadata key-value pairs


getDataSetMetadataByKey(options): Promise<string | null>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:269

Get specific metadata key for a data set

ParameterTypeDescription
options{ dataSetId: bigint; key: string; }Options for the data set
options.dataSetIdbigintThe data set ID
options.keystringThe metadata key to retrieve

Promise<string | null>

The metadata value if it exists, null otherwise


getOwner(): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:634

Get the contract owner address

Promise<`0x${string}`>

Owner address


getPDPConfig(): Promise<{ challengesPerProof: bigint; challengeWindowSize: bigint; initChallengeWindowStart: bigint; maxProvingPeriod: bigint; }>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:657

Get the PDP config from the WarmStorage contract. Returns maxProvingPeriod, challengeWindowSize, challengesPerProof, initChallengeWindowStart

Promise<{ challengesPerProof: bigint; challengeWindowSize: bigint; initChallengeWindowStart: bigint; maxProvingPeriod: bigint; }>


getPieceMetadata(options): Promise<MetadataObject>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:287

Get all metadata for a piece in a data set

ParameterTypeDescription
options{ dataSetId: bigint; pieceId: bigint; }Options for the piece
options.dataSetIdbigintThe data set ID
options.pieceIdbigintThe piece ID

Promise<MetadataObject>

Object with metadata key-value pairs


getPieceMetadataByKey(options): Promise<string | null>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:300

Get specific metadata key for a piece in a data set

ParameterTypeDescription
options{ dataSetId: bigint; key: string; pieceId: bigint; }Options for the piece
options.dataSetIdbigintThe data set ID
options.keystringThe metadata key to retrieve
options.pieceIdbigintThe piece ID

Promise<string | null>

The metadata value if it exists, null otherwise


getServicePrice(): Promise<OutputType>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:316

Get the current service price per TiB per month

Promise<OutputType>

Service price information for both CDN and non-CDN options


isOwner(options): Promise<boolean>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:648

Check if an address is the contract owner

ParameterTypeDescription
options{ address: `0x${string}`; }Options for the owner check
options.address`0x${string}`Address to check

Promise<boolean>

Whether the address is the owner


isProviderIdApproved(options): Promise<boolean>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:621

Check if a provider ID is approved

ParameterTypeDescription
options{ providerId: bigint; }Options for the provider ID approval check
options.providerIdbigintProvider ID to check

Promise<boolean>

Whether the provider is approved


prepareStorageUpload(options): Promise<{ actions: object[]; allowanceCheck: { message?: string; sufficient: boolean; }; estimatedCost: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; }>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:480

Prepare for storage upload by checking balances and allowances

This method performs a comprehensive check of the prerequisites for storage upload, including verifying sufficient funds and service allowances. It returns a list of actions that need to be executed before the upload can proceed.

ParameterTypeDescription
options{ address?: `0x${string}`; dataSize: bigint; lockupDays?: bigint; operator?: `0x${string}`; withCDN?: boolean; }Configuration options for the storage upload
options.address?`0x${string}`Address of the account to check allowances for (optional, defaults to the client account address)
options.dataSizebigintSize of data to store in bytes
options.lockupDays?bigintNumber of days for lockup period (defaults to 30)
options.operator?`0x${string}`Address of the operator to check allowances for (optional, defaults to the WarmStorage contract address)
options.withCDN?booleanWhether to enable CDN for faster retrieval (optional, defaults to false)

Promise<{ actions: object[]; allowanceCheck: { message?: string; sufficient: boolean; }; estimatedCost: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; }>

Object containing:

  • estimatedCost: Breakdown of storage costs (per epoch, day, and month)
  • allowanceCheck: Status of service allowances with optional message
  • actions: Array of required actions (deposit, approveService) that need to be executed
const prep = await warmStorageService.prepareStorageUpload(
{ dataSize: SIZE_CONSTANTS.GiB, withCDN: true, address: '0x...' },
)
if (prep.actions.length > 0) {
for (const action of prep.actions) {
console.log(`Executing: ${action.description}`)
await action.execute()
}
}

removeApprovedProvider(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:595

Remove an approved provider by ID (owner only)

ParameterTypeDescription
options{ providerId: bigint; }Options for the approved provider removal
options.providerIdbigintProvider ID from registry

Promise<`0x${string}`>

Transaction response


terminateDataSet(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:573

Terminate a data set with given ID

ParameterTypeDescription
options{ dataSetId: bigint; }Options for the data set termination
options.dataSetIdbigintID of the data set to terminate

Promise<`0x${string}`>

Transaction receipt


topUpCDNPaymentRails(options): Promise<`0x${string}`>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:691

Increments the fixed locked-up amounts for CDN payment rails.

This method tops up the prepaid balance for CDN services by adding to the existing lockup amounts. Both CDN and cache miss rails can be incremented independently.

ParameterTypeDescription
options{ cacheMissAmountToAdd: bigint; cdnAmountToAdd: bigint; dataSetId: bigint; }Options for the top up CDN payment rails
options.cacheMissAmountToAddbigintAmount to add to the cache miss rail lockup
options.cdnAmountToAddbigintAmount to add to the CDN rail lockup
options.dataSetIdbigintThe ID of the data set

Promise<`0x${string}`>

Transaction response Hash


validateDataSet(options): Promise<void>

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:207

Validate that a dataset is live and managed by this WarmStorage contract

Performs validation checks in parallel:

  • Dataset exists and is live
  • Dataset is managed by this WarmStorage contract
ParameterTypeDescription
options{ dataSetId: bigint; }Options for the data set
options.dataSetIdbigintThe PDPVerifier data set ID

Promise<void>

if dataset is not valid for operations


static create(options): WarmStorageService

Defined in: packages/synapse-sdk/src/warm-storage/service.ts:77

Create a new WarmStorageService with pre-configured client

ParameterTypeDescription
options{ account: Account; chain?: Chain; transport?: Transport; }Options for the WarmStorageService
options.accountAccountViem account (required)
options.chain?ChainFilecoin chain (optional, defaults to DEFAULT_CHAIN)
options.transport?TransportViem transport (optional, defaults to http())

WarmStorageService

A new WarmStorageService instance