WarmStorageService
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:105
Methods
Section titled “Methods”addApprovedProvider()
Section titled “addApprovedProvider()”addApprovedProvider(signer, providerId): Promise<TransactionResponse>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1005
Add an approved provider by ID (owner only)
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
signer | Signer | Signer with owner permissions |
providerId | number | Provider ID from registry |
Returns
Section titled “Returns”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:752
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 for both CDN and non-CDN
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:793
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
getAddPiecesInfo()
Section titled “getAddPiecesInfo()”getAddPiecesInfo(dataSetId): Promise<AddPiecesInfo>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:399
Get information for adding pieces to a data set
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | The PDPVerifier data set ID |
Returns
Section titled “Returns”Helper information for adding pieces
getApprovedProviderIds()
Section titled “getApprovedProviderIds()”getApprovedProviderIds(): Promise<number[]>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1037
Get list of approved provider IDs
Returns
Section titled “Returns”Promise
<number
[]>
Array of approved provider IDs
getChallengeWindow()
Section titled “getChallengeWindow()”getChallengeWindow(): Promise<number>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1089
Get the challenge window size from the WarmStorage contract
Returns
Section titled “Returns”Promise
<number
>
Challenge window size in epochs
getClientDataSets()
Section titled “getClientDataSets()”getClientDataSets(clientAddress): Promise<DataSetInfo[]>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:306
Get all data sets for a specific client
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
clientAddress | string | The client address |
Returns
Section titled “Returns”Array of data set information
getClientDataSetsWithDetails()
Section titled “getClientDataSetsWithDetails()”getClientDataSetsWithDetails(client, onlyManaged): Promise<EnhancedDataSetInfo[]>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:337
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 | 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
getComprehensiveDataSetStatus()
Section titled “getComprehensiveDataSetStatus()”getComprehensiveDataSetStatus(txHashOrTransaction, pdpServer?): Promise<ComprehensiveDataSetStatus>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:547
Get comprehensive data set creation status combining server and chain info
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
txHashOrTransaction | | string | TransactionResponse | Transaction hash or transaction object |
pdpServer? | PDPServer | PDP server instance for status checks |
Returns
Section titled “Returns”Promise
<ComprehensiveDataSetStatus
>
Combined status information
getDataSet()
Section titled “getDataSet()”getDataSet(dataSetId): Promise<DataSetInfo>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:277
Get a single data set by ID
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | 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<Record<string, string>>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:675
Get all metadata for a data set
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | The data set ID |
Returns
Section titled “Returns”Promise
<Record
<string
, string
>>
Object with metadata key-value pairs
getDataSetMetadataByKey()
Section titled “getDataSetMetadataByKey()”getDataSetMetadataByKey(dataSetId, key): Promise<null | string>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:693
Get specific metadata key for a data set
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | The data set ID |
key | string | The metadata key to retrieve |
Returns
Section titled “Returns”Promise
<null
| string
>
The metadata value if it exists, null otherwise
getMaxProvingPeriod()
Section titled “getMaxProvingPeriod()”getMaxProvingPeriod(): Promise<number>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1079
Get the maximum proving period from the WarmStorage contract
Returns
Section titled “Returns”Promise
<number
>
Maximum proving period in epochs
getNextClientDataSetId()
Section titled “getNextClientDataSetId()”getNextClientDataSetId(clientAddress): Promise<number>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:444
Get the next client dataset ID for a given client This reads the current counter from the WarmStorage contract
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
clientAddress | string | The client’s wallet address |
Returns
Section titled “Returns”Promise
<number
>
next client dataset ID that will be assigned by this WarmStorage contract
getOwner()
Section titled “getOwner()”getOwner(): Promise<string>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1057
Get the contract owner address
Returns
Section titled “Returns”Promise
<string
>
Owner address
getPaymentsAddress()
Section titled “getPaymentsAddress()”getPaymentsAddress(): string;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:209
Returns
Section titled “Returns”string
getPDPVerifierAddress()
Section titled “getPDPVerifierAddress()”getPDPVerifierAddress(): string;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:205
Returns
Section titled “Returns”string
getPieceMetadata()
Section titled “getPieceMetadata()”getPieceMetadata(dataSetId, pieceId): Promise<Record<string, string>>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:705
Get all metadata for a piece in a data set
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | The data set ID |
pieceId | number | The piece ID |
Returns
Section titled “Returns”Promise
<Record
<string
, string
>>
Object with metadata key-value pairs
getPieceMetadataByKey()
Section titled “getPieceMetadataByKey()”getPieceMetadataByKey( dataSetId, pieceId,key): Promise<null | string>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:724
Get specific metadata key for a piece in a data set
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
dataSetId | number | The data set ID |
pieceId | number | The piece ID |
key | string | The metadata key to retrieve |
Returns
Section titled “Returns”Promise
<null
| string
>
The metadata value if it exists, null otherwise
getProvider()
Section titled “getProvider()”getProvider(): Provider;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:229
Get the provider instance
Returns
Section titled “Returns”The ethers provider
getServicePrice()
Section titled “getServicePrice()”getServicePrice(): Promise<ServicePriceInfo>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:736
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:221
Returns
Section titled “Returns”string
getUSDFCTokenAddress()
Section titled “getUSDFCTokenAddress()”getUSDFCTokenAddress(): string;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:213
Returns
Section titled “Returns”string
getViewContractAddress()
Section titled “getViewContractAddress()”getViewContractAddress(): string;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:217
Returns
Section titled “Returns”string
isOwner()
Section titled “isOwner()”isOwner(signer): Promise<boolean>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1067
Check if a signer is the contract owner
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
signer | Signer | Signer to check |
Returns
Section titled “Returns”Promise
<boolean
>
Whether the signer is the owner
isProviderIdApproved()
Section titled “isProviderIdApproved()”isProviderIdApproved(providerId): Promise<boolean>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1048
Check if a provider ID is approved
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
providerId | number | 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:901
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(signer, providerId): Promise<TransactionResponse>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:1017
Remove an approved provider by ID (owner only)
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
signer | Signer | Signer with owner permissions |
providerId | number | Provider ID from registry |
Returns
Section titled “Returns”Transaction response
terminateDataSet()
Section titled “terminateDataSet()”terminateDataSet(signer, dataSetId): Promise<TransactionResponse>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:991
Terminate a data set with given ID
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
signer | Signer | Signer which created this dataset |
dataSetId | number | ID of the data set to terminate |
Returns
Section titled “Returns”Transaction receipt
verifyDataSetCreation()
Section titled “verifyDataSetCreation()”verifyDataSetCreation(txHashOrTransaction): Promise<DataSetCreationVerification>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:465
Verify that a data set creation transaction was successful This checks both the transaction status and on-chain data set state
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
txHashOrTransaction | | string | TransactionResponse | Transaction hash or transaction object |
Returns
Section titled “Returns”Promise
<DataSetCreationVerification
>
Verification result with data set ID if found
waitForDataSetCreationWithStatus()
Section titled “waitForDataSetCreationWithStatus()”waitForDataSetCreationWithStatus( txHashOrTransaction, pdpServer, maxWaitTime, pollInterval,onProgress?): Promise<ComprehensiveDataSetStatus>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:626
Wait for data set creation with status updates
Parameters
Section titled “Parameters”Parameter | Type | Default value | Description |
---|---|---|---|
txHashOrTransaction | | string | TransactionResponse | undefined | Transaction hash or transaction object to wait for |
pdpServer | PDPServer | undefined | PDP server for status checks |
maxWaitTime | number | TIMING_CONSTANTS.DATA_SET_CREATION_TIMEOUT_MS | Maximum time to wait in milliseconds |
pollInterval | number | TIMING_CONSTANTS.DATA_SET_CREATION_POLL_INTERVAL_MS | Polling interval in milliseconds |
onProgress? | (status , elapsedMs ) => Promise <void > | undefined | Optional progress callback |
Returns
Section titled “Returns”Promise
<ComprehensiveDataSetStatus
>
Final comprehensive status
create()
Section titled “create()”static create(provider, warmStorageAddress): Promise<WarmStorageService>;
Defined in: packages/synapse-sdk/src/warm-storage/service.ts:145
Create a new WarmStorageService instance with initialized addresses
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
provider | Provider |
warmStorageAddress | string |
Returns
Section titled “Returns”Promise
<WarmStorageService
>