FVM Deal Utils SDK

FVM Deal Utils SDK

The Spheron FVM Deal Utils SDK is equipped with multi-chain storage capabilities powered by Spheron.


The package is only meant for Node.js environments and will not work in a browser or frontend apps.


Using NPM

npm i @spheron/fvm-deal-utils

Using Yarn

yarn add @spheron/fvm-deal-utils


To use the FVM Deal Utils SDK, you have to create an instance of SpheronDealClient.

import { SpheronDealClient } from "@spheron/fvm-deal-utils";
const client = new SpheronDealClient({ token });

The SpheronDealClient constructor takes an object that has one property token. Follow the instructions in the DOCS (opens in a new tab) to generate this token.

NOTE: When you are creating the tokens, please choose static site type in the dashboard.


In the example below you can see how to create an instance of SpheronDealClient and how to generate the metadata required for creating a storage deal on FVM.

const {
} = require("@spheron/fvm-deal-utils");
const client = new SpheronDealClient({ token });
let currentlyUploaded = 0;
const result: DealDataResult = await client.getFvmMetadata(filePath, {
  onUploadInitiated: (uploadId) => {
    console.log(`Upload with id ${uploadId} started...`);
  onChunkUploaded: (uploadedSize, totalSize) => {
    currentlyUploaded += uploadedSize;
    console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);

Function getFvmMetadata takes two parameters:

  • filePath - (string) - The path to the file which will be transformed to a Car file and uploaded to IPFS
  • configuration: An object with the following parameters:
    1. configuration.name (string)
      • Represents the name of the bucket on which you are uploading the Car file.
    2. configuration.onUploadInitiated (Optional)
      • Callback function (uploadId: string) => void. The function will be called once, when the upload is initiated, right before the data is uploaded. The function will be called with one parameter, uploadId, which represents the id of the started upload.
    3. configuration.onChunkUploaded (Optional)
      • Callback function (uploadedSize: number, totalSize: number) => void. The function will be called multiple times, depending on the upload size. The function will be called each time a chunk is uploaded, with two parameters. The first one uploadedSize represents, the size in Bytes for the uploaded chunk. The totalSize represents the total size of the upload in Bytes.


interface DealDataResult {
  pieceSize: number; // the size of the file in bytes
  size: number; // the size of the CAR file in bytes
  pieceCid: string; // hash of the piece in hex
  dataCid: string; // IPFS hash of the car file
  carLink: string; // the IPFS link to the car
  carName: string; // the name of the car
  uploadId: string; // the id of the upload
Site SDKSpheron CLI