filecoin-pin
    Preparing search index...

    Interface FilecoinPinAPI

    interface FilecoinPinAPI {
        checkUploadReadiness: (
            options: UploadReadinessOptions,
        ) => Promise<UploadReadinessResult>;
        createCarFromFile: (
            file: File,
            options?: CreateCarOptions,
        ) => Promise<CreateCarResult>;
        createCarFromFiles: (
            files: File[],
            options?: CreateCarOptions,
        ) => Promise<CreateCarResult>;
        createCarFromPath: (
            path: string,
            options?: CreateCarOptions,
        ) => Promise<CreateCarResult>;
        executeUpload: (
            synapse: Synapse,
            carData: Uint8Array,
            rootCid: CID,
            options: UploadExecutionOptions,
        ) => Promise<UploadExecutionResult>;
        getDataSetPieces: (
            synapse: Synapse,
            storageContext: StorageContext,
            options?: GetDataSetPiecesOptions,
        ) => Promise<DataSetPiecesResult>;
        getDetailedDataSet: (
            synapse: Synapse,
            dataSetId: bigint,
            options?: ListDataSetsOptions,
        ) => Promise<DataSetSummary>;
        getPaymentStatus: (synapse: Synapse) => Promise<PaymentStatus>;
        initializeSynapse: (
            config: SynapseSetupConfig,
            logger?: Logger,
        ) => Promise<Synapse>;
        listDataSets: (
            synapse: Synapse,
            options?: ListDataSetsOptions,
        ) => Promise<DataSetSummary[]>;
        setMaxAllowances: (synapse: Synapse) => Promise<SetMaxAllowancesResult>;
        validatePaymentCapacity: (
            synapse: Synapse,
            pieceSizeBytes: number,
        ) => Promise<PaymentCapacityCheck>;
    }
    Index

    Properties

    checkUploadReadiness: (
        options: UploadReadinessOptions,
    ) => Promise<UploadReadinessResult>

    Type Declaration

      • (options: UploadReadinessOptions): Promise<UploadReadinessResult>
      • Check readiness for uploading a CAR file.

        This performs the same validation chain previously used by the CLI/action:

        1. Ensure basic wallet requirements (FIL for gas, USDFC balance)
        2. Confirm or configure WarmStorage allowances
        3. Validate that the current deposit can cover the upload

        The function only mutates state when autoConfigureAllowances is enabled (default), in which case it will call setMaxAllowances as needed.

        Session Key Authentication: When using session key authentication, autoConfigureAllowances is automatically disabled since payment operations require the owner wallet to sign. Allowances must be configured separately by the owner wallet before uploads can proceed.

        Parameters

        Returns Promise<UploadReadinessResult>

    createCarFromFile: (
        file: File,
        options?: CreateCarOptions,
    ) => Promise<CreateCarResult>

    Type Declaration

    createCarFromFiles: (
        files: File[],
        options?: CreateCarOptions,
    ) => Promise<CreateCarResult>

    Type Declaration

    createCarFromPath: (
        path: string,
        options?: CreateCarOptions,
    ) => Promise<CreateCarResult>

    Type Declaration

      • (path: string, options?: CreateCarOptions): Promise<CreateCarResult>
      • Create a CAR file from a file or directory using UnixFS encoding

        Parameters

        • path: string

          Path to the file or directory to encode

        • options: CreateCarOptions = {}

          Optional logger, bare flag, and directory flag

        Returns Promise<CreateCarResult>

        Path to temporary CAR file, root CID, and entry count

    executeUpload: (
        synapse: Synapse,
        carData: Uint8Array,
        rootCid: CID,
        options: UploadExecutionOptions,
    ) => Promise<UploadExecutionResult>

    Type Declaration

    getDataSetPieces: (
        synapse: Synapse,
        storageContext: StorageContext,
        options?: GetDataSetPiecesOptions,
    ) => Promise<DataSetPiecesResult>

    Type Declaration

      • (
            synapse: Synapse,
            storageContext: StorageContext,
            options?: GetDataSetPiecesOptions,
        ): Promise<DataSetPiecesResult>
      • Get all pieces for a dataset from a StorageContext

        Uses StorageContext.getPieces() async generator to retrieve all pieces. Optionally fetches metadata for each piece from WarmStorage.

        Parameters

        • synapse: Synapse

          Initialized Synapse instance

        • storageContext: StorageContext

          Storage context bound to a dataset

        • Optionaloptions: GetDataSetPiecesOptions

          Optional configuration

        Returns Promise<DataSetPiecesResult>

        Pieces and warnings

    getDetailedDataSet: (
        synapse: Synapse,
        dataSetId: bigint,
        options?: ListDataSetsOptions,
    ) => Promise<DataSetSummary>
    getPaymentStatus: (synapse: Synapse) => Promise<PaymentStatus>

    Type Declaration

      • (synapse: Synapse): Promise<PaymentStatus>
      • Get current payment status including all balances and approvals

        Example usage:

        const status = await getPaymentStatus(synapse)
        console.log(`Address: ${status.address}`)
        console.log(`FIL Balance: ${formatUnits(status.filBalance, 18)}`)
        console.log(`USDFC Balance: ${formatUnits(status.walletUsdfcBalance, 18)}`)
        console.log(`Deposited: ${formatUnits(status.filecoinPayBalance, 18)}`)

        Parameters

        • synapse: Synapse

          Initialized Synapse instance

        Returns Promise<PaymentStatus>

        Complete payment status

    initializeSynapse: (
        config: SynapseSetupConfig,
        logger?: Logger,
    ) => Promise<Synapse>

    Type Declaration

      • (config: SynapseSetupConfig, logger?: Logger): Promise<Synapse>
      • Create a Synapse instance from CLI-friendly configuration.

        Parameters

        • config: SynapseSetupConfig

          Authentication and network configuration

        • Optionallogger: Logger

          Optional logger for initialization events

        Returns Promise<Synapse>

        Initialized Synapse instance

    listDataSets: (
        synapse: Synapse,
        options?: ListDataSetsOptions,
    ) => Promise<DataSetSummary[]>

    Type Declaration

      • (synapse: Synapse, options?: ListDataSetsOptions): Promise<DataSetSummary[]>
      • List all datasets for an address with optional provider enrichment

        Example usage:

        const synapse = await Synapse.create({ privateKey, rpcURL })
        const datasets = await listDataSets(synapse)

        for (const ds of datasets) {
        console.log(`Dataset ${ds.dataSetId}: ${ds.currentPieceCount} pieces`)
        if (ds.provider) {
        console.log(` Provider: ${ds.provider.name}`)
        }
        }

        Parameters

        • synapse: Synapse

          Initialized Synapse instance

        • Optionaloptions: ListDataSetsOptions

          Optional configuration

        Returns Promise<DataSetSummary[]>

        Array of dataset summaries

    setMaxAllowances: (synapse: Synapse) => Promise<SetMaxAllowancesResult>

    Type Declaration

      • (synapse: Synapse): Promise<SetMaxAllowancesResult>
      • Set WarmStorage allowances to maximum

        This function sets the allowances for WarmStorage to maximum values, effectively treating it as a fully trusted service.

        Parameters

        • synapse: Synapse

          Initialized Synapse instance

        Returns Promise<SetMaxAllowancesResult>

        Transaction hash and updated allowances

    validatePaymentCapacity: (
        synapse: Synapse,
        pieceSizeBytes: number,
    ) => Promise<PaymentCapacityCheck>

    Type Declaration

      • (synapse: Synapse, pieceSizeBytes: number): Promise<PaymentCapacityCheck>
      • Validate payment capacity for a specific piece size

        This function checks if the deposit is sufficient for the piece upload. It does not account for allowances since WarmStorage is assumed to be given full trust with max allowances.

        Note: This function will attempt to automatically set max allowances unless using session key authentication, in which case allowances must be configured separately by the owner wallet.

        Example usage:

        const fileSize = 10 * 1024 * 1024 * 1024 // 10 GiB
        const capacity = await validatePaymentCapacity(synapse, fileSize)

        if (!capacity.canUpload) {
        console.error('Cannot upload file with current payment setup')
        capacity.suggestions.forEach(s => console.log(` - ${s}`))
        }

        Parameters

        • synapse: Synapse

          Initialized Synapse instance

        • pieceSizeBytes: number

          Size of the piece (CAR, File, etc.) file in bytes

        Returns Promise<PaymentCapacityCheck>

        Capacity check result