Skip to content

WarmStorageService

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

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

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

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

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

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<number>;

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

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

ParameterTypeDescription
dataSetIdnumberThe PDPVerifier data set ID

Promise<number>

The number of active pieces


getApprovedProviderIds(): Promise<number[]>;

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

Get list of approved provider IDs

Promise<number[]>

Array of approved provider IDs


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

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

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

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

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

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

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

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


getMulticall3Address(): string;

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

string


getNextPieceId(dataSetId): Promise<number>;

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

Get the next piece ID for a dataset (total pieces ever added; does not decrease when pieces are removed)

ParameterTypeDescription
dataSetIdnumberThe PDPVerifier data set ID

Promise<number>

The next piece ID as a number


getOwner(): Promise<string>;

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

Get the contract owner address

Promise<string>

Owner address


getPaymentsAddress(): string;

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

string


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

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

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

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


getPDPVerifierAddress(): string;

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

string


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

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

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

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

Get the provider instance

Provider

The ethers provider


getServicePrice(): Promise<ServicePriceInfo>;

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

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

string


getSessionKeyRegistryAddress(): string;

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

string


getUSDFCTokenAddress(): string;

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

string


getViewContractAddress(): string;

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

string


isOwner(signer): Promise<boolean>;

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

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

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

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

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

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

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

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

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

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,
multicall3Address): Promise<WarmStorageService>;

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

Create a new WarmStorageService instance with initialized addresses

ParameterTypeDefault value
providerProviderundefined
warmStorageAddressstringundefined
multicall3Addressstring | nullnull

Promise<WarmStorageService>