shomix-testing-coredeal-utils
v1.0.3
Published
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://github.com/spheronFdn/sdk/blob/main/.github/assets/spheron-logo-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://github.com/spheron
Downloads
6
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: