WarmStorageService
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:68
Methods
Section titled “Methods”addApprovedProvider()
Section titled “addApprovedProvider()”addApprovedProvider(
client,providerId):Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:597
Add an approved provider by ID (owner only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | Wallet client to add the approved provider |
providerId | bigint | Provider ID from registry |
Returns
Section titled “Returns”Promise<`0x${string}`>
Transaction response
calculateStorageCost()
Section titled “calculateStorageCost()”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:347
Calculate storage costs for a given size
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
sizeInBytes | number | Size of data to store in bytes |
Returns
Section titled “Returns”Promise<{ perDay: bigint; perEpoch: bigint; perMonth: bigint; withCDN: { perDay: bigint; perEpoch: bigint; perMonth: bigint; }; }>
Cost estimates per epoch, day, and month
Remarks
Section titled “Remarks”CDN costs are usage-based (egress pricing), so withCDN field reflects base storage cost only
checkAllowanceForStorage()
Section titled “checkAllowanceForStorage()”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:387
Check if user has sufficient allowances for a storage operation and calculate costs
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
sizeInBytes | number | Size of data to store |
withCDN | boolean | Whether CDN is enabled |
paymentsService | PaymentsService | PaymentsService instance to check allowances |
lockupDays? | number | Number of days for lockup period (defaults to 10) |
Returns
Section titled “Returns”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()
Section titled “getActivePieceCount()”getActivePieceCount(
dataSetId):Promise<bigint>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:273
Get the count of active pieces in a dataset (excludes removed pieces)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The PDPVerifier data set ID |
Returns
Section titled “Returns”Promise<bigint>
The number of active pieces
getApprovedProviderIds()
Section titled “getApprovedProviderIds()”getApprovedProviderIds():
Promise<OutputType>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:629
Get list of approved provider IDs
Returns
Section titled “Returns”Array of approved provider IDs
getClientDataSets()
Section titled “getClientDataSets()”getClientDataSets(
clientAddress):Promise<readonlyDataSetInfo[]>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:142
Get all data sets for a specific client
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
clientAddress | `0x${string}` | The client address |
Returns
Section titled “Returns”Promise<readonly DataSetInfo[]>
Array of data set information
getClientDataSetsWithDetails()
Section titled “getClientDataSetsWithDetails()”getClientDataSetsWithDetails(
client,onlyManaged):Promise<EnhancedDataSetInfo[]>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:158
Get all data sets for a client with enhanced details This includes live status and management information
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
client | `0x${string}` | undefined | The client address |
onlyManaged | boolean | false | If true, only return data sets managed by this Warm Storage contract |
Returns
Section titled “Returns”Promise<EnhancedDataSetInfo[]>
Array of enhanced data set information
getDataSet()
Section titled “getDataSet()”getDataSet(
dataSetId):Promise<DataSetInfo>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:121
Get a single data set by ID
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The data set ID to retrieve |
Returns
Section titled “Returns”Data set information
Throws
Section titled “Throws”Error if data set doesn’t exist
getDataSetMetadata()
Section titled “getDataSetMetadata()”getDataSetMetadata(
dataSetId):Promise<MetadataObject>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:284
Get all metadata for a data set
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The data set ID |
Returns
Section titled “Returns”Object with metadata key-value pairs
getDataSetMetadataByKey()
Section titled “getDataSetMetadataByKey()”getDataSetMetadataByKey(
dataSetId,key):Promise<string|null>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:294
Get specific metadata key for a data set
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The data set ID |
key | string | The metadata key to retrieve |
Returns
Section titled “Returns”Promise<string | null>
The metadata value if it exists, null otherwise
getOwner()
Section titled “getOwner()”getOwner():
Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:651
Get the contract owner address
Returns
Section titled “Returns”Promise<`0x${string}`>
Owner address
getPaymentsAddress()
Section titled “getPaymentsAddress()”getPaymentsAddress():
string
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:93
Returns
Section titled “Returns”string
getPDPConfig()
Section titled “getPDPConfig()”getPDPConfig():
Promise<{challengesPerProof:bigint;challengeWindowSize:bigint;initChallengeWindowStart:bigint;maxProvingPeriod:bigint; }>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:673
Get the PDP config from the WarmStorage contract. Returns maxProvingPeriod, challengeWindowSize, challengesPerProof, initChallengeWindowStart
Returns
Section titled “Returns”Promise<{ challengesPerProof: bigint; challengeWindowSize: bigint; initChallengeWindowStart: bigint; maxProvingPeriod: bigint; }>
getPDPVerifierAddress()
Section titled “getPDPVerifierAddress()”getPDPVerifierAddress():
`0x${string}`
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:89
Returns
Section titled “Returns”`0x${string}`
getPieceMetadata()
Section titled “getPieceMetadata()”getPieceMetadata(
dataSetId,pieceId):Promise<MetadataObject>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:310
Get all metadata for a piece in a data set
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The data set ID |
pieceId | bigint | The piece ID |
Returns
Section titled “Returns”Object with metadata key-value pairs
getPieceMetadataByKey()
Section titled “getPieceMetadataByKey()”getPieceMetadataByKey(
dataSetId,pieceId,key):Promise<string|null>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:321
Get specific metadata key for a piece in a data set
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The data set ID |
pieceId | bigint | The piece ID |
key | string | The metadata key to retrieve |
Returns
Section titled “Returns”Promise<string | null>
The metadata value if it exists, null otherwise
getServicePrice()
Section titled “getServicePrice()”getServicePrice():
Promise<OutputType>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:337
Get the current service price per TiB per month
Returns
Section titled “Returns”Service price information for both CDN and non-CDN options
getServiceProviderRegistryAddress()
Section titled “getServiceProviderRegistryAddress()”getServiceProviderRegistryAddress():
string
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:105
Returns
Section titled “Returns”string
getSessionKeyRegistryAddress()
Section titled “getSessionKeyRegistryAddress()”getSessionKeyRegistryAddress():
string
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:109
Returns
Section titled “Returns”string
getUSDFCTokenAddress()
Section titled “getUSDFCTokenAddress()”getUSDFCTokenAddress():
string
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:97
Returns
Section titled “Returns”string
getViewContractAddress()
Section titled “getViewContractAddress()”getViewContractAddress():
string
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:101
Returns
Section titled “Returns”string
isOwner()
Section titled “isOwner()”isOwner(
address):Promise<boolean>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:664
Check if an address is the contract owner
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
address | `0x${string}` | Address to check |
Returns
Section titled “Returns”Promise<boolean>
Whether the address is the owner
isProviderIdApproved()
Section titled “isProviderIdApproved()”isProviderIdApproved(
providerId):Promise<boolean>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:638
Check if a provider ID is approved
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
providerId | bigint | Provider ID to check |
Returns
Section titled “Returns”Promise<boolean>
Whether the provider is approved
prepareStorageUpload()
Section titled “prepareStorageUpload()”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:495
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | { dataSize: number; withCDN?: boolean; } | Configuration options for the storage upload |
options.dataSize | number | Size of data to store in bytes |
options.withCDN? | boolean | Whether to enable CDN for faster retrieval (optional, defaults to false) |
paymentsService | PaymentsService | Instance of PaymentsService for handling payment operations |
Returns
Section titled “Returns”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
Example
Section titled “Example”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()
Section titled “removeApprovedProvider()”removeApprovedProvider(
client,providerId):Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:610
Remove an approved provider by ID (owner only)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | Wallet client to remove the approved provider |
providerId | bigint | Provider ID from registry |
Returns
Section titled “Returns”Promise<`0x${string}`>
Transaction response
terminateDataSet()
Section titled “terminateDataSet()”terminateDataSet(
client,dataSetId):Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:585
Terminate a data set with given ID
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | Wallet client to terminate the data set |
dataSetId | bigint | ID of the data set to terminate |
Returns
Section titled “Returns”Promise<`0x${string}`>
Transaction receipt
topUpCDNPaymentRails()
Section titled “topUpCDNPaymentRails()”topUpCDNPaymentRails(
client,dataSetId,cdnAmountToAdd,cacheMissAmountToAdd):Promise<`0x${string}`>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:707
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | - |
dataSetId | bigint | The ID of the data set |
cdnAmountToAdd | bigint | Amount to add to the CDN rail lockup |
cacheMissAmountToAdd | bigint | Amount to add to the cache miss rail lockup |
Returns
Section titled “Returns”Promise<`0x${string}`>
Transaction response
validateDataSet()
Section titled “validateDataSet()”validateDataSet(
dataSetId):Promise<void>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:237
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
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dataSetId | bigint | The PDPVerifier data set ID |
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”if dataset is not valid for operations
create()
Section titled “create()”
staticcreate(client):Promise<WarmStorageService>
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:85
Create a new WarmStorageService instance with initialized addresses
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
client | Client<Transport, Chain> |
Returns
Section titled “Returns”Promise<WarmStorageService>