Skip to content

WarmStorageService

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

addApprovedProvider(signer, providerId): Promise<TransactionResponse>;

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

Add an approved provider by ID (owner only)

ParameterTypeDescription
signerSignerSigner with owner permissions
providerIdnumberProvider ID from registry

Promise<TransactionResponse>

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:728

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:768

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


getApprovedProviderIds(): Promise<number[]>;

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

Get list of approved provider IDs

Promise<number[]>

Array of approved provider IDs


getChallengeWindow(): Promise<number>;

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

Get the challenge window size from the WarmStorage contract

Promise<number>

Challenge window size in epochs


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

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

Get all data sets for a specific client

ParameterTypeDescription
clientAddressstringThe client address

Promise<DataSetInfo[]>

Array of data set information


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

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

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

ParameterTypeDefault valueDescription
clientstringundefinedThe client address
onlyManagedbooleanfalseIf true, only return data sets managed by this Warm Storage contract

Promise<EnhancedDataSetInfo[]>

Array of enhanced data set information


getComprehensiveDataSetStatus(txHashOrTransaction, pdpServer?): Promise<ComprehensiveDataSetStatus>;

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

Get comprehensive data set creation status combining server and chain info

ParameterTypeDescription
txHashOrTransactionstring | TransactionResponseTransaction hash or transaction object
pdpServer?PDPServerPDP server instance for status checks

Promise<ComprehensiveDataSetStatus>

Combined status information


getDataSet(dataSetId): Promise<DataSetInfo>;

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

Get a single data set by ID

ParameterTypeDescription
dataSetIdnumberThe data set ID to retrieve

Promise<DataSetInfo>

Data set information

Error if data set doesn’t exist


getDataSetMetadata(dataSetId): Promise<Record<string, string>>;

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

Get all metadata for a data set

ParameterTypeDescription
dataSetIdnumberThe data set ID

Promise<Record<string, string>>

Object with metadata key-value pairs


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

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

Get specific metadata key for a data set

ParameterTypeDescription
dataSetIdnumberThe data set ID
keystringThe metadata key to retrieve

Promise<string | null>

The metadata value if it exists, null otherwise


getMaxProvingPeriod(): Promise<number>;

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

Get the maximum proving period from the WarmStorage contract

Promise<number>

Maximum proving period in epochs


getOwner(): Promise<string>;

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

Get the contract owner address

Promise<string>

Owner address


getPaymentsAddress(): string;

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

string


getPDPVerifierAddress(): string;

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

string


getPieceMetadata(dataSetId, pieceId): Promise<Record<string, string>>;

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

Get all metadata for a piece in a data set

ParameterTypeDescription
dataSetIdnumberThe data set ID
pieceIdnumberThe piece ID

Promise<Record<string, string>>

Object with metadata key-value pairs


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

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

Get specific metadata key for a piece in a data set

ParameterTypeDescription
dataSetIdnumberThe data set ID
pieceIdnumberThe piece ID
keystringThe metadata key to retrieve

Promise<string | null>

The metadata value if it exists, null otherwise


getProvider(): Provider;

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

Get the provider instance

Provider

The ethers provider


getServicePrice(): Promise<ServicePriceInfo>;

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

Get the current service price per TiB per month

Promise<ServicePriceInfo>

Service price information for both CDN and non-CDN options


getServiceProviderRegistryAddress(): string;

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

string


getSessionKeyRegistryAddress(): string;

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

string


getUSDFCTokenAddress(): string;

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

string


getViewContractAddress(): string;

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

string


isOwner(signer): Promise<boolean>;

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

Check if a signer is the contract owner

ParameterTypeDescription
signerSignerSigner to check

Promise<boolean>

Whether the signer is the owner


isProviderIdApproved(providerId): Promise<boolean>;

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

Check if a provider ID is approved

ParameterTypeDescription
providerIdnumberProvider 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:876

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(signer, providerId): Promise<TransactionResponse>;

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

Remove an approved provider by ID (owner only)

ParameterTypeDescription
signerSignerSigner with owner permissions
providerIdnumberProvider ID from registry

Promise<TransactionResponse>

Transaction response


terminateDataSet(signer, dataSetId): Promise<TransactionResponse>;

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

Terminate a data set with given ID

ParameterTypeDescription
signerSignerSigner which created this dataset
dataSetIdnumberID of the data set to terminate

Promise<TransactionResponse>

Transaction receipt


topUpCDNPaymentRails(
signer,
dataSetId,
cdnAmountToAdd,
cacheMissAmountToAdd): Promise<TransactionResponse>;

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

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
signerSigner-
dataSetIdnumberThe ID of the data set
cdnAmountToAddbigintAmount to add to the CDN rail lockup
cacheMissAmountToAddbigintAmount to add to the cache miss rail lockup

Promise<TransactionResponse>

Transaction response


validateDataSet(dataSetId): Promise<void>;

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

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

Promise<void>

if dataset is not valid for operations


verifyDataSetCreation(txHashOrTransaction): Promise<DataSetCreationVerification>;

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

Verify that a data set creation transaction was successful This checks both the transaction status and on-chain data set state

ParameterTypeDescription
txHashOrTransactionstring | TransactionResponseTransaction hash or transaction object

Promise<DataSetCreationVerification>

Verification result with data set ID if found


waitForDataSetCreationWithStatus(
txHashOrTransaction,
pdpServer,
maxWaitTime,
pollInterval,
onProgress?): Promise<ComprehensiveDataSetStatus>;

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

Wait for data set creation with status updates

ParameterTypeDefault valueDescription
txHashOrTransactionstring | TransactionResponseundefinedTransaction hash or transaction object to wait for
pdpServerPDPServerundefinedPDP server for status checks
maxWaitTimenumberTIMING_CONSTANTS.DATA_SET_CREATION_TIMEOUT_MSMaximum time to wait in milliseconds
pollIntervalnumberTIMING_CONSTANTS.DATA_SET_CREATION_POLL_INTERVAL_MSPolling interval in milliseconds
onProgress?(status, elapsedMs) => Promise<void>undefinedOptional progress callback

Promise<ComprehensiveDataSetStatus>

Final comprehensive status


static create(provider, warmStorageAddress): Promise<WarmStorageService>;

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

Create a new WarmStorageService instance with initialized addresses

ParameterType
providerProvider
warmStorageAddressstring

Promise<WarmStorageService>