@spheron/fvm-deal-utils
v1.0.0
Published
Typescript library for creating deal parameters for creating a FVM storage deal.
Downloads
20
Readme
getFvmMetadata Example
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 {
SpheronDealClient,
DealDataResult,
} = require("@spheron/fvm-deal-utils");
const client = new SpheronDealClient({ token });
let currentlyUploaded = 0;
const result: DealDataResult = await client.getFvmMetadata(filePath, {
name,
onUploadInitiated: (uploadId) => {
console.log(`Upload with id ${uploadId} started...`);
},
onChunkUploaded: (uploadedSize, totalSize) => {
currentlyUploaded += uploadedSize;
console.log(`Uploaded ${currentlyUploaded} of ${totalSize} Bytes.`);
},
});
- The response of the
getFvmMetadata
function is an object with the following properties:pieceSize
- the size of the file in bytessize
- the size of the CAR file in bytespieceCid
- hash of the piece in hexdataCid
- IPFS hash of the car filecarLink
- the IPFS URL of the generated car file.carName
- the name of the caruploadId
- the id of the upload on which the car was uploaded
Access Token
To create the token
that is used with the SpheronClient
, follow the instructions in the DOCS. When you are creating the tokens, please choose web app type in the dashboard.
Notes
The package is only meant for Node.js environments and will not work in a browser or frontend apps.
Learn More
You can learn more about Spheron and Storage SDK here: