PDPAuthHelper
Defined in: packages/synapse-sdk/src/pdp/auth.ts:73
Helper class for creating EIP-712 typed signatures for PDP operations
This class provides methods to create cryptographic signatures required for authenticating PDP (Proof of Data Possession) operations with service providers. All signatures are EIP-712 compatible for improved security and UX.
Can be used standalone or through the Synapse SDK.
Example
Section titled “Example”// Direct instantiation with ethers signerimport { PDPAuthHelper } from '@filoz/synapse-sdk'import { ethers } from 'ethers'
const wallet = new ethers.Wallet(privateKey, provider)const auth = new PDPAuthHelper(contractAddress, wallet, BigInt(chainId))
// Or get from Synapse instance (convenience method)const synapse = await Synapse.create({ privateKey, rpcURL })const auth = synapse.getPDPAuthHelper()
// Sign operations for PDP service authenticationconst createSig = await auth.signCreateDataSet(0, providerAddress, false)const addPiecesSig = await auth.signAddPieces(0, 1, pieceDataArray)
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PDPAuthHelper( serviceContractAddress, signer, chainId): PDPAuthHelper;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:78
Parameters
Section titled “Parameters”Parameter | Type |
---|---|
serviceContractAddress | string |
signer | Signer |
chainId | bigint |
Returns
Section titled “Returns”PDPAuthHelper
Properties
Section titled “Properties”WITH_CDN_METADATA
Section titled “WITH_CDN_METADATA”readonly WITH_CDN_METADATA: MetadataEntry;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:76
Methods
Section titled “Methods”getSignerAddress()
Section titled “getSignerAddress()”getSignerAddress(): Promise<string>;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:551
Get the address of the signer
Returns
Section titled “Returns”Promise
<string
>
Promise resolving to the signer’s Ethereum address
signAddPieces()
Section titled “signAddPieces()”signAddPieces( clientDataSetId, firstPieceId, pieceDataArray,metadata): Promise<AuthSignature>;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:317
Create signature for adding pieces to a data set
This signature authorizes a service provider to add new data pieces to an existing data set. Each piece represents aggregated data that will be proven using PDP challenges.
Parameters
Section titled “Parameters”Parameter | Type | Default value | Description |
---|---|---|---|
clientDataSetId | number | bigint | undefined | Client’s dataset ID (same as used in createDataSet) |
firstPieceId | number | bigint | undefined | ID of the first piece being added (sequential numbering) |
pieceDataArray | | string [] | PieceLink [] | undefined | Array of piece data containing PieceCID CIDs and raw sizes |
metadata | MetadataEntry [][] | [] | - |
Returns
Section titled “Returns”Promise resolving to authentication signature for adding pieces
Example
Section titled “Example”const auth = new PDPAuthHelper(contractAddress, signer, chainId)const pieceData = [{ cid: 'bafkzcibc...', // PieceCID of aggregated data rawSize: Number(SIZE_CONSTANTS.MiB) // Raw size in bytes before padding}]const signature = await auth.signAddPieces( 0, // Same dataset ID as data set creation 1, // First piece has ID 1 (0 reserved) pieceData // Array of pieces to add)
signCreateDataSet()
Section titled “signCreateDataSet()”signCreateDataSet( clientDataSetId, payee,metadata): Promise<AuthSignature>;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:239
Create signature for data set creation
This signature authorizes a service provider to create a new data set on behalf of the client. The signature includes the client’s dataset ID, the service provider’s payment address, and CDN preference.
Parameters
Section titled “Parameters”Parameter | Type | Default value | Description |
---|---|---|---|
clientDataSetId | number | bigint | undefined | Unique dataset ID for the client (typically starts at 0 and increments) |
payee | string | undefined | Service provider’s address that will receive payments |
metadata | MetadataEntry [] | [] | - |
Returns
Section titled “Returns”Promise resolving to authentication signature for data set creation
Example
Section titled “Example”const auth = new PDPAuthHelper(contractAddress, signer, chainId)const signature = await auth.signCreateDataSet( 0, // First dataset for this client '0x1234...abcd', // Service provider address true // Enable CDN service)
signDeleteDataSet()
Section titled “signDeleteDataSet()”signDeleteDataSet(clientDataSetId): Promise<AuthSignature>;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:503
Create signature for data set deletion
This signature authorizes complete deletion of a data set and all its associated data. This action is irreversible and will terminate the storage service for this dataset.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
clientDataSetId | number | bigint | Client’s dataset ID to delete |
Returns
Section titled “Returns”Promise resolving to authentication signature for data set deletion
Example
Section titled “Example”const auth = new PDPAuthHelper(contractAddress, signer, chainId)const signature = await auth.signDeleteDataSet( 0 // Dataset ID to delete)
signSchedulePieceRemovals()
Section titled “signSchedulePieceRemovals()”signSchedulePieceRemovals(clientDataSetId, pieceIds): Promise<AuthSignature>;
Defined in: packages/synapse-sdk/src/pdp/auth.ts:428
Create signature for scheduling piece removals
This signature authorizes a service provider to schedule specific pieces for removal from the data set. Pieces are typically removed after the next successful proof submission.
Parameters
Section titled “Parameters”Parameter | Type | Description |
---|---|---|
clientDataSetId | number | bigint | Client’s dataset ID |
pieceIds | (number | bigint )[] | Array of piece IDs to schedule for removal |
Returns
Section titled “Returns”Promise resolving to authentication signature for scheduling removals
Example
Section titled “Example”const auth = new PDPAuthHelper(contractAddress, signer, chainId)const signature = await auth.signSchedulePieceRemovals( 0, // Dataset ID [1, 2, 3] // Piece IDs to remove)