Components
This page describes the components of the Synapse SDK and how they work together. You’ll learn how each component can be used independently, how they are organized within the SDK architecture, and how they interact with the underlying smart contracts and storage providers.
The SDK is built from these core components:
Synapse- Main SDK entry point with simple, high-level APIPaymentsService- SDK client for managing deposits, approvals, and payment rails (interacts with Filecoin Pay contract)StorageManager,StorageContext- Storage operation classesWarmStorageService- SDK client for storage coordination and pricing (interacts with WarmStorage contract)PDPVerifier- Client for PDPVerifier contract - get data set and piece status, create data sets and add piecesPDPServer- HTTP client for Curio providers - create data sets and add piecesPDPAuthHelper- Signature generation utility - Generate EIP-712 signatures for authenticated operations (create data sets and add pieces)
The following diagram illustrates how these components relate to each other and the external systems they interact with:
graph LR
subgraph "Public API"
Synapse
end
subgraph "Payment Services"
PS[PaymentsService]
end
subgraph "Storage Services"
SM[StorageManager]
end
subgraph "Lower-Level"
WSS[WarmStorageService]
SC[StorageContext]
PDPS[PDPServer]
PDPA[PDPAuthHelper]
PDPV[PDPVerifier]
end
Synapse --> SM
Synapse --> PS
SM --> SC
SM --> WSS
SC --> PDPS
SC --> PDPA
SC --> PDPV
PS --> SC
The SDK architecture is guided by several key principles that ensure maintainability, flexibility, and ease of use:
Design Principles:
- Separation of Concerns: Protocol, business logic, and application layers are distinct
- Composability: Each component can be used independently or together
- Abstraction: SDK hides blockchain complexity from applications
- Verification: All storage backed by cryptographic proofs
SDK Components
Section titled “SDK Components”The SDK is organized into three layers, each serving a specific purpose:
- High-Level API: The
Synapseclass provides a simple interface for common operations. - Service Layer:
PaymentsServiceandStorageManagerhandle domain-specific logic. - Lower-Level Clients: Direct access to contracts and providers for advanced use cases.
Synapse
Section titled “Synapse”Purpose: Main SDK entry point with simple, high-level API
API Reference: Synapse API Reference
Synapse Interface:
interface interface SynapseAPI
SynapseAPI { // Create a new Synapse instance SynapseAPI.create(options: SynapseOptions): Promise<Synapse>
create(options: SynapseOptions
options: (alias) interface SynapseOptionsimport SynapseOptions
SynapseOptions): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<class Synapse
Synapse>; // Properties SynapseAPI.payments: PaymentsService
payments: class PaymentsService
PaymentsService; SynapseAPI.storage: StorageManager
storage: class StorageManager
StorageManager; // Storage Information (pricing, providers, service parameters, allowances) SynapseAPI.getStorageInfo(): Promise<StorageInfo>
getStorageInfo(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface StorageInfoimport StorageInfo
StorageInfo>; SynapseAPI.getProviderInfo(providerAddress: string): Promise<ProviderInfo>
getProviderInfo(providerAddress: string
providerAddress: string): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface ProviderInfoimport ProviderInfo
ProviderInfo>; // Network Information SynapseAPI.getNetwork(): FilecoinNetworkType
getNetwork(): type FilecoinNetworkType = "mainnet" | "calibration" | "devnet"
FilecoinNetworkType; SynapseAPI.getChainId(): number
getChainId(): number; // Contract Addresses SynapseAPI.getWarmStorageAddress(): string
getWarmStorageAddress(): string; SynapseAPI.getPaymentsAddress(): string
getPaymentsAddress(): string; SynapseAPI.getPDPVerifierAddress(): string
getPDPVerifierAddress(): string; // Ethers Helpers SynapseAPI.getProvider(): ethers.Provider
getProvider(): import ethers
ethers.export Provider
A Provider is the primary method to interact with the read-only
content on Ethereum.
It allows access to details about accounts, blocks and transactions
and the ability to query event logs and simulate contract execution.
Account data includes the balance,
transaction count, code and
state trie storage.
Simulating execution can be used to call,
estimate gas and
get transaction results.
The [[broadcastTransaction]] is the only method which allows updating
the blockchain, but it is usually accessed by a [[Signer]], since a
private key must be used to sign the transaction before it can be
broadcast.
Provider; SynapseAPI.getSigner(): ethers.Signer
getSigner(): import ethers
ethers.export Signer
A Signer represents an account on the Ethereum Blockchain, and is most often
backed by a private key represented by a mnemonic or residing on a Hardware Wallet.
The API remains abstract though, so that it can deal with more advanced exotic
Signing entities, such as Smart Contract Wallets or Virtual Wallets (where the
private key may not be known).
Signer;}PaymentsService
Section titled “PaymentsService”The PaymentsService provides direct access to the Filecoin Pay contract, enabling you to:
- Manage token deposits and withdrawals
- Approve operators for automated payments
- Query and settle payment rails
- Monitor account health and balance
This is your primary interface for all payment-related operations in the SDK.
API Reference: PaymentsService API Reference
Check out the Payment Operations guide for more details.
Payments Service Interface:
interface interface PaymentsServiceAPI
PaymentsServiceAPI { // Balances PaymentsServiceAPI.walletBalance(token: TokenIdentifier): Promise<bigint>
walletBalance(token: string
token: type TokenIdentifier = string
TokenIdentifier): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<bigint>; PaymentsServiceAPI.balance(): Promise<bigint>
balance(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<bigint>; PaymentsServiceAPI.accountInfo(token: TokenIdentifier): Promise<AccountInfo>
accountInfo(token: string
token: type TokenIdentifier = string
TokenIdentifier): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<interface AccountInfo
AccountInfo>;
// Token Operations PaymentsServiceAPI.decimals(token: TokenIdentifier): number
decimals(token: string
token: type TokenIdentifier = string
TokenIdentifier): number; PaymentsServiceAPI.allowance(spender: string, token: TokenIdentifier): Promise<bigint>
allowance(spender: string
spender: string, token: string
token: type TokenIdentifier = string
TokenIdentifier): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<bigint>; PaymentsServiceAPI.approve(spender: string, amount: TokenAmount): Transaction
approve(spender: string
spender: string, amount: TokenAmount
amount: type TokenAmount = number | bigint
TokenAmount): type Transaction = Promise<ethers.TransactionResponse>
Transaction; // Deposits PaymentsServiceAPI.deposit(amount: TokenAmount): Transaction
deposit(amount: TokenAmount
amount: type TokenAmount = number | bigint
TokenAmount): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.depositWithPermit(amount: TokenAmount): Transaction
depositWithPermit(amount: TokenAmount
amount: type TokenAmount = number | bigint
TokenAmount): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.depositWithPermitAndApproveOperator(amount: TokenAmount, operator: string, rateAllowance: TokenAmount, lockupAllowance: TokenAmount, maxLockupPeriod: TokenAmount): Transaction
depositWithPermitAndApproveOperator( amount: TokenAmount
amount: type TokenAmount = number | bigint
TokenAmount, operator: string
operator: string, rateAllowance: TokenAmount
rateAllowance: type TokenAmount = number | bigint
TokenAmount, lockupAllowance: TokenAmount
lockupAllowance: type TokenAmount = number | bigint
TokenAmount, maxLockupPeriod: TokenAmount
maxLockupPeriod: type TokenAmount = number | bigint
TokenAmount ): type Transaction = Promise<ethers.TransactionResponse>
Transaction;
// Operator management PaymentsServiceAPI.approveService(service: string, rateAllowance: TokenAmount, lockupAllowance: TokenAmount, maxLockupPeriod: TokenAmount, token: TokenIdentifier): Transaction
approveService( service: string
service: string, rateAllowance: TokenAmount
rateAllowance: type TokenAmount = number | bigint
TokenAmount, lockupAllowance: TokenAmount
lockupAllowance: type TokenAmount = number | bigint
TokenAmount, maxLockupPeriod: TokenAmount
maxLockupPeriod: type TokenAmount = number | bigint
TokenAmount, token: string
token: type TokenIdentifier = string
TokenIdentifier ): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.revokeService(service: string, token: TokenIdentifier): Transaction
revokeService(service: string
service: string, token: string
token: type TokenIdentifier = string
TokenIdentifier): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.serviceApproval(service: string): Promise<ServiceApproval>
serviceApproval(service: string
service: string): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<interface ServiceApproval
ServiceApproval>;
// Rails PaymentsServiceAPI.getRailsAsPayer(): Promise<RailInfo[]>
getRailsAsPayer(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface RailInfoimport RailInfo
RailInfo[]>; PaymentsServiceAPI.getRailsAsPayee(): Promise<RailInfo[]>
getRailsAsPayee(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface RailInfoimport RailInfo
RailInfo[]>; PaymentsServiceAPI.getRail(railId: bigint): Promise<Rail>
getRail(railId: bigint
railId: bigint): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type Rail = { token: string; from: string; to: string; operator: string; validator: string; paymentRate: bigint; lockupPeriod: bigint; lockupFixed: bigint; settledUpTo: bigint; endEpoch: bigint; commissionRateBps: bigint; serviceFeeRecipient: string;}
Rail>;
PaymentsServiceAPI.getSettlementAmounts(railId: bigint, targetEpoch?: bigint): Promise<SettlementResult>
getSettlementAmounts( railId: bigint
railId: bigint, targetEpoch: bigint | undefined
targetEpoch?: bigint ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface SettlementResultimport SettlementResult
SettlementResult>; PaymentsServiceAPI.settle(railId: bigint, targetEpoch?: bigint): Transaction
settle(railId: bigint
railId: bigint, targetEpoch: bigint | undefined
targetEpoch?: bigint): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.settleTerminatedRail(railId: bigint): Transaction
settleTerminatedRail(railId: bigint
railId: bigint): type Transaction = Promise<ethers.TransactionResponse>
Transaction; PaymentsServiceAPI.settleAuto(railId: bigint, targetEpoch?: bigint): Transaction
settleAuto(railId: bigint
railId: bigint, targetEpoch: bigint | undefined
targetEpoch?: bigint): type Transaction = Promise<ethers.TransactionResponse>
Transaction;}StorageManager
Section titled “StorageManager”Purpose: High-level, auto-managed storage operations - upload and download data to and from the Filecoin Onchain Cloud.
API Reference: StorageManager API Reference
Check out the Storage Operations guide for more details.
Storage Manager Interface:
interface interface StorageManagerAPI
StorageManagerAPI { // Upload & Download StorageManagerAPI.upload(data: Uint8Array | ArrayBuffer, options?: StorageManagerUploadOptions): Promise<UploadResult>
upload( data: ArrayBuffer | Uint8Array<ArrayBufferLike>
data: interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array | interface ArrayBuffer
Represents a raw buffer of binary data, which is used to store data for the
different typed arrays. ArrayBuffers cannot be read from or written to directly,
but can be passed to a typed array or DataView Object to interpret the raw
buffer as needed.
ArrayBuffer, options: StorageManagerUploadOptions | undefined
options?: interface StorageManagerUploadOptions
StorageManagerUploadOptions ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface UploadResultimport UploadResult
UploadResult>; StorageManagerAPI.download(pieceCid: string | PieceCID): Promise<Uint8Array>
download(pieceCid: string | PieceLink
pieceCid: string | type PieceCID = Link<MerkleTreeNode, RAW_CODE, MulticodecCode<4113, "fr32-sha2-256-trunc254-padded-binary-tree">, 1>
PieceCID): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>
A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the
requested number of bytes could not be allocated an exception is raised.
Uint8Array>;
// Context Management StorageManagerAPI.createContext(options?: StorageServiceOptions): Promise<StorageContext>
createContext(options: StorageServiceOptions | undefined
options?: (alias) interface StorageServiceOptionsimport StorageServiceOptions
StorageServiceOptions): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<class StorageContext
StorageContext>; StorageManagerAPI.getDefaultContext(): Promise<StorageContext>
getDefaultContext(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<class StorageContext
StorageContext>;
// Data Set Management StorageManagerAPI.findDataSets(clientAddress?: string): Promise<EnhancedDataSetInfo[]>
findDataSets(clientAddress: string | undefined
clientAddress?: string): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface EnhancedDataSetInfoimport EnhancedDataSetInfo
EnhancedDataSetInfo[]>; StorageManagerAPI.terminateDataSet(dataSetId: number): Transaction
terminateDataSet(dataSetId: number
dataSetId: number): type Transaction = Promise<ethers.TransactionResponse>
Transaction;
// Preflight & Info StorageManagerAPI.preflightUpload(size: number, options?: { withCDN?: boolean; metadata?: Record<string, string>;}): Promise<PreflightInfo>
preflightUpload( size: number
size: number, options: { withCDN?: boolean; metadata?: Record<string, string>;} | undefined
options?: { withCDN?: boolean
withCDN?: boolean; metadata?: Record<string, string>
metadata?: type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
Record<string, string> } ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface PreflightInfoimport PreflightInfo
PreflightInfo>; StorageManagerAPI.getStorageInfo(): Promise<StorageInfo>
getStorageInfo(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface StorageInfoimport StorageInfo
StorageInfo>;}StorageContext
Section titled “StorageContext”Purpose: Provider-specific storage operations - upload and download data to and from the Filecoin Onchain Cloud.
API Reference: StorageContext API Reference
Check out the Storage Context guide for more details.
WarmStorageService
Section titled “WarmStorageService”Purpose: SDK client for storage coordination and pricing - storage pricing and cost calculations, data set management and queries, metadata operations (data sets and pieces), service provider approval management, contract address discovery, data set creation verification.
API Reference: WarmStorageService API Reference
WarmStorageService Interface:
interface interface WarmStorageServiceAPI
WarmStorageServiceAPI { // Factory Method WarmStorageServiceAPI.create(provider: ethers.Provider, warmStorageAddress: string): Promise<WarmStorageService>
create( provider: ethers.Provider
provider: import ethers
ethers.export Provider
A Provider is the primary method to interact with the read-only
content on Ethereum.
It allows access to details about accounts, blocks and transactions
and the ability to query event logs and simulate contract execution.
Account data includes the balance,
transaction count, code and
state trie storage.
Simulating execution can be used to call,
estimate gas and
get transaction results.
The [[broadcastTransaction]] is the only method which allows updating
the blockchain, but it is usually accessed by a [[Signer]], since a
private key must be used to sign the transaction before it can be
broadcast.
Provider, warmStorageAddress: string
warmStorageAddress: string ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<class WarmStorageService
WarmStorageService>
// Data Set Queries WarmStorageServiceAPI.getDataSet(dataSetId: number): Promise<DataSetInfo>
getDataSet(dataSetId: number
dataSetId: number): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface DataSetInfoimport DataSetInfo
DataSetInfo> WarmStorageServiceAPI.getClientDataSets(clientAddress: string): Promise<DataSetInfo[]>
getClientDataSets(clientAddress: string
clientAddress: string): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface DataSetInfoimport DataSetInfo
DataSetInfo[]> WarmStorageServiceAPI.getClientDataSetsWithDetails(client: string, onlyManaged?: boolean): Promise<EnhancedDataSetInfo[]>
getClientDataSetsWithDetails( client: string
client: string, onlyManaged: boolean | undefined
onlyManaged?: boolean ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<(alias) interface EnhancedDataSetInfoimport EnhancedDataSetInfo
EnhancedDataSetInfo[]>
// Metadata Operations WarmStorageServiceAPI.getDataSetMetadata(dataSetId: number): Promise<Record<string, string>>
getDataSetMetadata(dataSetId: number
dataSetId: number): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
Record<string, string>> WarmStorageServiceAPI.getDataSetMetadataByKey(dataSetId: number, key: string): Promise<string | null>
getDataSetMetadataByKey( dataSetId: number
dataSetId: number, key: string
key: string ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<string | null> WarmStorageServiceAPI.getPieceMetadata(dataSetId: number, pieceId: number): Promise<Record<string, string>>
getPieceMetadata( dataSetId: number
dataSetId: number, pieceId: number
pieceId: number ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type Record<K extends keyof any, T> = { [P in K]: T; }
Construct a type with a set of properties K of type T
Record<string, string>> WarmStorageServiceAPI.getPieceMetadataByKey(dataSetId: number, pieceId: number, key: string): Promise<string | null>
getPieceMetadataByKey( dataSetId: number
dataSetId: number, pieceId: number
pieceId: number, key: string
key: string ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<string | null>
// Pricing & Cost Calculations WarmStorageServiceAPI.getServicePrice(): Promise<ServicePriceInfo>
getServicePrice(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type ServicePriceInfo = { pricePerTiBPerMonthNoCDN: bigint; pricePerTiBCdnEgress: bigint; pricePerTiBCacheMissEgress: bigint; tokenAddress: string; epochsPerMonth: bigint; minimumPricePerMonth: bigint;}
ServicePriceInfo> WarmStorageServiceAPI.calculateStorageCost(sizeInBytes: number): Promise<CalculateStorageCostResult>
calculateStorageCost( sizeInBytes: number
sizeInBytes: number ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type CalculateStorageCostResult = { perEpoch: bigint; perDay: bigint; perMonth: bigint; withCDN: { perEpoch: bigint; perDay: bigint; perMonth: bigint; };}
CalculateStorageCostResult> WarmStorageServiceAPI.checkAllowanceForStorage(sizeInBytes: number, withCDN: boolean, paymentsService: PaymentsService, lockupDays?: number): Promise<CheckAllowanceForStorageResult>
checkAllowanceForStorage( sizeInBytes: number
sizeInBytes: number, withCDN: boolean
withCDN: boolean, paymentsService: PaymentsService
paymentsService: class PaymentsService
PaymentsService, lockupDays: number | undefined
lockupDays?: number ): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<type CheckAllowanceForStorageResult = { rateAllowanceNeeded: bigint; lockupAllowanceNeeded: bigint; currentRateAllowance: bigint; currentLockupAllowance: bigint; currentRateUsed: bigint; currentLockupUsed: bigint; sufficient: boolean; message?: string; costs: { perEpoch: bigint; perDay: bigint; perMonth: bigint; }; depositAmountNeeded: bigint;}
CheckAllowanceForStorageResult>
// Data Set Management WarmStorageServiceAPI.terminateDataSet(signer: ethers.Signer, dataSetId: number): Transaction
terminateDataSet(signer: ethers.Signer
signer: import ethers
ethers.export Signer
A Signer represents an account on the Ethereum Blockchain, and is most often
backed by a private key represented by a mnemonic or residing on a Hardware Wallet.
The API remains abstract though, so that it can deal with more advanced exotic
Signing entities, such as Smart Contract Wallets or Virtual Wallets (where the
private key may not be known).
Signer, dataSetId: number
dataSetId: number): type Transaction = Promise<ethers.TransactionResponse>
Transaction WarmStorageServiceAPI.topUpCDNPaymentRails(signer: ethers.Signer, dataSetId: number, cdnAmountToAdd: bigint, cacheMissAmountToAdd: bigint): Transaction
topUpCDNPaymentRails( signer: ethers.Signer
signer: import ethers
ethers.export Signer
A Signer represents an account on the Ethereum Blockchain, and is most often
backed by a private key represented by a mnemonic or residing on a Hardware Wallet.
The API remains abstract though, so that it can deal with more advanced exotic
Signing entities, such as Smart Contract Wallets or Virtual Wallets (where the
private key may not be known).
Signer, dataSetId: number
dataSetId: number, cdnAmountToAdd: bigint
cdnAmountToAdd: bigint, cacheMissAmountToAdd: bigint
cacheMissAmountToAdd: bigint ): type Transaction = Promise<ethers.TransactionResponse>
Transaction
WarmStorageServiceAPI.getApprovedProviderIds(): Promise<number[]>
getApprovedProviderIds(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<number[]> WarmStorageServiceAPI.isProviderIdApproved(providerId: number): Promise<boolean>
isProviderIdApproved(providerId: number
providerId: number): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<boolean>
WarmStorageServiceAPI.getPDPConfig(): Promise<{ maxProvingPeriod: number; challengeWindowSize: number; challengesPerProof: number; initChallengeWindowStart: number;}>
getPDPConfig(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<{ maxProvingPeriod: number
maxProvingPeriod: number challengeWindowSize: number
challengeWindowSize: number challengesPerProof: number
challengesPerProof: number initChallengeWindowStart: number
initChallengeWindowStart: number }>
WarmStorageServiceAPI.getMaxProvingPeriod(): Promise<number>
getMaxProvingPeriod(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<number> WarmStorageServiceAPI.getChallengeWindow(): Promise<number>
getChallengeWindow(): interface Promise<T>
Represents the completion of an asynchronous operation
Promise<number>}PDPComponents
Section titled “PDPComponents”PDPVerifier
Section titled “PDPVerifier”Purpose: Client for PDPVerifier contract - get dataset and piece status, create data sets and add pieces.
API Reference: PDPVerifier API Reference
PDPVerifier Example:
const const pdpVerifier: PDPVerifier
pdpVerifier = new new PDPVerifier(provider: ethers.Provider, contractAddress: string): PDPVerifier
PDPVerifier(const provider: ethers.Provider
provider, const pdpVerifierAddress: string
pdpVerifierAddress);
// Check if data set is liveconst const isLive: boolean
isLive = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.dataSetLive(dataSetId: number): Promise<boolean>
dataSetLive(const dataSetId: number
dataSetId);
// Query data set informationconst const nextPieceId: number
nextPieceId = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.getNextPieceId(dataSetId: number): Promise<number>
getNextPieceId(const dataSetId: number
dataSetId);const const listener: string
listener = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.getDataSetListener(dataSetId: number): Promise<string>
getDataSetListener(const dataSetId: number
dataSetId);const const storageProvider: { storageProvider: string; proposedStorageProvider: string;}
storageProvider = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.getDataSetStorageProvider(dataSetId: number): Promise<{ storageProvider: string; proposedStorageProvider: string;}>
getDataSetStorageProvider(const dataSetId: number
dataSetId);const const leafCount: number
leafCount = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.getDataSetLeafCount(dataSetId: number): Promise<number>
getDataSetLeafCount(const dataSetId: number
dataSetId);const const activePieces: { pieces: Array<{ pieceCid: PieceCID; pieceId: number; }>; hasMore: boolean;}
activePieces = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.getActivePieces(dataSetId: number, options?: { offset?: number; limit?: number; signal?: AbortSignal;}): Promise<{ pieces: Array<{ pieceCid: PieceCID; pieceId: number; }>; hasMore: boolean;}>
getActivePieces(const dataSetId: number
dataSetId);
// Extract data set ID from transaction receiptconst const extractedId: number | null
extractedId = await const pdpVerifier: PDPVerifier
pdpVerifier.PDPVerifier.extractDataSetIdFromReceipt(receipt: ethers.TransactionReceipt): number | null
extractDataSetIdFromReceipt(const transactionReceipt: ethers.TransactionReceipt
transactionReceipt);Complete Data Flow
Section titled “Complete Data Flow”This sequence diagram shows the complete lifecycle of a file upload operation, from initialization through verification. Each step represents an actual blockchain transaction or API call.
sequenceDiagram
participant Client
participant SDK
participant WarmStorage
participant Curio
participant PDPVerifier
participant Payments
Note over Client,Payments: Step 1: Preparation
Client->>SDK: Initialize Synapse SDK
SDK->>WarmStorage: Discover contract addresses
Note over Client,Payments: Step 2: Payment Setup
Client->>SDK: Check allowances
SDK->>WarmStorage: getServicePrice()
SDK->>Payments: accountInfo(client)
alt Needs setup
Client->>Payments: depositWithPermitAndApproveOperator()
end
Note over Client,Payments: Step 3: Storage Context
Client->>SDK: synapse.storage.upload(data)
SDK->>SDK: Auto-select provider or use default
alt No data set exists
SDK->>SDK: Sign CreateDataSet (EIP-712)
SDK->>Curio: POST /pdp/data-sets (+ signature)
Curio->>PDPVerifier: createDataSet(warmStorage, signature)
PDPVerifier->>WarmStorage: dataSetCreated()
WarmStorage->>Payments: createRail()
Payments-->>WarmStorage: railId
end
Note over Client,Payments: Step 4: Upload & Register
SDK->>SDK: Calculate PieceCID
SDK->>Curio: POST /pdp/piece (upload data)
Curio-->>SDK: uploadUUID
SDK->>SDK: Sign AddPieces (EIP-712)
SDK->>Curio: POST /pdp/data-sets/{id}/pieces
Curio->>PDPVerifier: addPieces(dataSetId, pieces, signature)
PDPVerifier->>WarmStorage: piecesAdded()
WarmStorage->>WarmStorage: Store metadata
WarmStorage-->>PDPVerifier: Success
Note over Client,Payments: Step 5: Verification Begins
PDPVerifier->>PDPVerifier: Schedule first challenge
PDPVerifier-->>Client: Upload complete!
Next Steps
Section titled “Next Steps”Choose your learning path based on your immediate needs:
Ready to Build?
Section titled “Ready to Build?”Jump straight to code with the Getting Started Guide →
- Storage Operations → - Upload and download your first file
- Storage Context → - Advanced storage operations and batch uploads
- Payment Operations → - Fund your account and manage payments
- Rails & Settlement → - Payment mechanics and settlement strategies
Want to Learn More?
Section titled “Want to Learn More?”- Architecture → - Understanding how all components work together
- PDP Overview → - Proof verification and data integrity
- Filecoin Pay → - Payment rails and lockup mechanisms
- Warm Storage Service → - Storage coordination and pricing model