Skip to main content

Overview

The WarmStorageService provides direct access to Filecoin Warm Storage Service (FWSS) contract operations. This is a low-level service used internally by StorageManager and StorageContext. Most users should use StorageManager instead. This service is exposed for advanced use cases requiring direct contract interaction.
For most use cases, use StorageManager instead.This service provides low-level contract access and is primarily used internally by the SDK.

Data Set Queries

getDataSet()

Get information about a specific data set.
options
object
required
dataSet
object
Data set information including rail IDs, payer, payee, and provider details
const dataSet = await warmStorage.getDataSet({ dataSetId: 1n })

console.log('Provider:', dataSet.providerId)
console.log('Payer:', dataSet.payer)

getClientDataSets()

Get all data set IDs for a client address.
options
object
required
dataSets
DataSetInfo[]
Array of data set information
const dataSets = await warmStorage.getClientDataSets({
  address: '0x...'
})

getClientDataSetsWithDetails()

Get enhanced data set information including live status and management details.
options
object
dataSets
EnhancedDataSetInfo[]
Enhanced data set information with:
  • isLive - Whether data set is active on-chain
  • isManaged - Whether managed by current FWSS
  • activePieceCount - Number of pieces
  • withCDN - CDN status
  • metadata - Data set metadata
const dataSets = await warmStorage.getClientDataSetsWithDetails({
  onlyManaged: true
})

dataSets.forEach(ds => {
  console.log(`Dataset ${ds.dataSetId}:`)
  console.log(`  Live: ${ds.isLive}`)
  console.log(`  Pieces: ${ds.activePieceCount}`)
  console.log(`  CDN: ${ds.withCDN}`)
})

Service Configuration

getServicePrice()

Get current storage service pricing.
pricing
object
Pricing information:
  • pricePerTiBPerMonthNoCDN - Base storage cost
  • pricePerTiBCdnEgress - CDN egress cost
  • pricePerTiBCacheMissEgress - Cache miss cost
  • tokenAddress - Payment token address
  • epochsPerMonth - Epochs per month
  • minimumPricePerMonth - Minimum monthly charge
const pricing = await warmStorage.getServicePrice()

console.log('Base price/TiB/month:', pricing.pricePerTiBPerMonthNoCDN)
console.log('CDN egress/TiB:', pricing.pricePerTiBCdnEgress)
console.log('Token:', pricing.tokenAddress)

getPDPConfig()

Get PDP (Proof of Data Possession) configuration parameters.
config
object
PDP configuration including:
  • maxProvingPeriod - Maximum epochs between proofs
  • challengeWindowSize - Challenge window duration
  • Other PDP parameters
const config = await warmStorage.getPDPConfig()

console.log('Max proving period:', config.maxProvingPeriod)
console.log('Challenge window:', config.challengeWindowSize)

Provider Management

getApprovedProviderIds()

Get list of approved provider IDs.
providerIds
bigint[]
Array of approved provider IDs
const providerIds = await warmStorage.getApprovedProviderIds()
console.log('Approved providers:', providerIds)

addApprovedProvider()

Add a provider to the approved list (admin only).
options
object
required
txHash
Hash
Transaction hash
const txHash = await warmStorage.addApprovedProvider({
  providerId: 5n
})

removeApprovedProvider()

Remove a provider from the approved list (admin only).
options
object
required
txHash
Hash
Transaction hash
const txHash = await warmStorage.removeApprovedProvider({
  providerId: 5n
})

Data Set Operations

validateDataSet()

Validate that a data set is live and managed by this contract.
options
object
required
valid
void
Throws if validation fails
try {
  await warmStorage.validateDataSet({ dataSetId: 1n })
  console.log('Dataset is valid')
} catch (error) {
  console.error('Validation failed:', error.message)
}

getDataSetMetadata()

Get metadata for a data set.
options
object
required
metadata
Record<string, string>
Metadata key-value pairs
const metadata = await warmStorage.getDataSetMetadata({
  dataSetId: 1n
})

console.log(metadata)
// { category: 'videos', cdn: '' }

getActivePieceCount()

Get the number of active pieces in a data set.
options
object
required
count
bigint
Number of active pieces
const count = await warmStorage.getActivePieceCount({
  dataSetId: 1n
})

console.log('Active pieces:', count)

terminateDataSet()

Terminate a data set and remove all pieces.
options
object
required
txHash
Hash
Transaction hash
const txHash = await warmStorage.terminateDataSet({
  dataSetId: 1n
})

Allowance Checks

checkAllowanceForStorage()

Check if user has sufficient operator allowance for a storage operation.
options
object
required
check
object
Allowance check result:
  • sufficient - Whether allowance is sufficient
  • message - Error message if insufficient
  • costs - Cost breakdown (per epoch/day/month)
const check = await warmStorage.checkAllowanceForStorage({
  sizeInBytes: 1024n * 1024n * 100n, // 100 MiB
  withCDN: true
})

if (!check.sufficient) {
  console.error('Insufficient allowance:', check.message)
} else {
  console.log('Cost per month:', check.costs.perMonth)
}

See Also

Build docs developers (and LLMs) love