Skip to content

WarmStorageService

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

addApprovedProvider(client, providerId): Promise<`0x${string}`>

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

Add an approved provider by ID (owner only)

ParameterTypeDescription
clientClient<Transport, Chain, Account>Wallet client to add the approved provider
providerIdbigintProvider ID from registry

Promise<`0x${string}`>

Transaction response


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

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

Calculate storage costs for a given size

ParameterTypeDescription
sizeInBytesnumberSize 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(sizeInBytes, withCDN, paymentsService, lockupDays?): 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
sizeInBytesnumberSize of data to store
withCDNbooleanWhether CDN is enabled
paymentsServicePaymentsServicePaymentsService instance to check allowances
lockupDays?numberNumber of days for lockup period (defaults to 10)

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(dataSetId): Promise<bigint>

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

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

ParameterTypeDescription
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:610

Get list of approved provider IDs

Promise<OutputType>

Array of approved provider IDs


getClientDataSets(clientAddress): Promise<readonly DataSetInfo[]>

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

Get all data sets for a specific client

ParameterTypeDescription
clientAddress`0x${string}`The client address

Promise<readonly DataSetInfo[]>

Array of data set information


getClientDataSetsWithDetails(client, onlyManaged): Promise<EnhancedDataSetInfo[]>

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

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

ParameterTypeDefault valueDescription
client`0x${string}`undefinedThe client address
onlyManagedbooleanfalseIf true, only return data sets managed by this Warm Storage contract

Promise<EnhancedDataSetInfo[]>

Array of enhanced data set information


getDataSet(dataSetId): Promise<DataSetInfo>

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

Get a single data set by ID

ParameterTypeDescription
dataSetIdbigintThe data set ID to retrieve

Promise<DataSetInfo>

Data set information

Error if data set doesn’t exist


getDataSetMetadata(dataSetId): Promise<MetadataObject>

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

Get all metadata for a data set

ParameterTypeDescription
dataSetIdbigintThe data set ID

Promise<MetadataObject>

Object with metadata key-value pairs


getDataSetMetadataByKey(dataSetId, key): Promise<string | null>

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

Get specific metadata key for a data set

ParameterTypeDescription
dataSetIdbigintThe data set ID
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:632

Get the contract owner address

Promise<`0x${string}`>

Owner address


getPaymentsAddress(): `0x${string}`

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

`0x${string}`


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

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

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

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


getPDPVerifierAddress(): `0x${string}`

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

`0x${string}`


getPieceMetadata(dataSetId, pieceId): Promise<MetadataObject>

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

Get all metadata for a piece in a data set

ParameterTypeDescription
dataSetIdbigintThe data set ID
pieceIdbigintThe piece ID

Promise<MetadataObject>

Object with metadata key-value pairs


getPieceMetadataByKey(dataSetId, pieceId, key): Promise<string | null>

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

Get specific metadata key for a piece in a data set

ParameterTypeDescription
dataSetIdbigintThe data set ID
pieceIdbigintThe piece ID
keystringThe metadata key to retrieve

Promise<string | null>

The metadata value if it exists, null otherwise


getServicePrice(): Promise<OutputType>

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

Get the current service price per TiB per month

Promise<OutputType>

Service price information for both CDN and non-CDN options


getServiceProviderRegistryAddress(): `0x${string}`

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

`0x${string}`


getSessionKeyRegistryAddress(): `0x${string}`

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

`0x${string}`


getUSDFCTokenAddress(): `0x${string}`

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

`0x${string}`


getViewContractAddress(): `0x${string}`

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

`0x${string}`


isOwner(address): Promise<boolean>

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

Check if an address is the contract owner

ParameterTypeDescription
address`0x${string}`Address to check

Promise<boolean>

Whether the address is the owner


isProviderIdApproved(providerId): Promise<boolean>

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

Check if a provider ID is approved

ParameterTypeDescription
providerIdbigintProvider ID to check

Promise<boolean>

Whether the provider is approved


prepareStorageUpload(options, paymentsService): 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:476

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{ dataSize: number; withCDN?: boolean; }Configuration options for the storage upload
options.dataSizenumberSize of data to store in bytes
options.withCDN?booleanWhether to enable CDN for faster retrieval (optional, defaults to false)
paymentsServicePaymentsServiceInstance of PaymentsService for handling payment operations

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: Number(SIZE_CONSTANTS.GiB), withCDN: true },
paymentsService
)
if (prep.actions.length > 0) {
for (const action of prep.actions) {
console.log(`Executing: ${action.description}`)
await action.execute()
}
}

removeApprovedProvider(client, providerId): Promise<`0x${string}`>

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

Remove an approved provider by ID (owner only)

ParameterTypeDescription
clientClient<Transport, Chain, Account>Wallet client to remove the approved provider
providerIdbigintProvider ID from registry

Promise<`0x${string}`>

Transaction response


terminateDataSet(client, dataSetId): Promise<`0x${string}`>

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

Terminate a data set with given ID

ParameterTypeDescription
clientClient<Transport, Chain, Account>Wallet client to terminate the data set
dataSetIdbigintID of the data set to terminate

Promise<`0x${string}`>

Transaction receipt


topUpCDNPaymentRails(client, dataSetId, cdnAmountToAdd, cacheMissAmountToAdd): Promise<`0x${string}`>

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

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
clientClient<Transport, Chain, Account>-
dataSetIdbigintThe ID of the data set
cdnAmountToAddbigintAmount to add to the CDN rail lockup
cacheMissAmountToAddbigintAmount to add to the cache miss rail lockup

Promise<`0x${string}`>

Transaction response


validateDataSet(dataSetId): Promise<void>

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

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
dataSetIdbigintThe PDPVerifier data set ID

Promise<void>

if dataset is not valid for operations


static create(client): Promise<WarmStorageService>

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

Create a new WarmStorageService instance with initialized addresses

ParameterType
clientClient<Transport, Chain>

Promise<WarmStorageService>