npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-mcs-sdk

v4.3.0

Published

A SDK for the MCS service. It provides a convenient interface for working with the MCS API from a web browser or Node.js

Downloads

6

Readme

Multichain Storage SDK - Javascript

Made by FilSwan Chat on discord

A javascript software development kit for the Multi-Chain Storage (MCS) https://www.multichain.storage/ service. It provides a convenient interface for working with the MCS API from a web browser or Node.js. This SDK has the following functionalities:

Table of Contents

🆕 Getting Started

Prerequisites

  • Node.js - v16.13.0 (npm v8.1.0)
  • API Key and Access Token - Generated via https://multichain.storage

Installation

In a new working directory, use npm init -y to initialize a Node.js project. Install the package using npm

npm init -y
npm install js-mcs-sdk

Setup Credentials

Create a .env file that includes the following content. Optionally include your wallet's private key and RPC-url.

API_KEY='<API_KEY>'
ACCESS_TOKEN='<ACCESS_TOKEN>'

# for onchain storage only
PRIVATE_KEY='<PRIVATE_KEY>'
RPC_URL='<RPC_URL>'

Initialize SDK

require('dotenv').config()
const { mcsSDK } = require('js-mcs-sdk')

async function main() {
  // initialize js-mcs-sdk
  const mcs = await mcsSDK.initialize({
    apiKey: process.env.API_KEY,
    accessToken: process.env.ACCESS_TOKEN,
    chainName: 'polygon.mainnet',
  })
}

main()

👨‍💻 Examples

Bucket Storage

  • Create a bucket

    let bucketData = await mcs.createBucket('<BUCKET_NAME>')
    console.log(bucketData)
  • Upload a file to the bucket

    let fileData = mcs.uploadToBucket(
      '<BUCKET_NAME>',
      '<OBJECT_NAME>',
      '<FILE_PATH>',
    )
    console.log(fileData)

For more examples, please see the SDK documentation.

Onchain Storage

Onchain storage is designed for storing file information in the smart contract. It requires payment for each file.

To use certain Onchain Storage features (upload, payment, minting), you will need to set up the web3 environment first.

  • Setup Web3

    await mcs.setupWeb3(process.env.PRIVATE_KEY, process.env.RPC_URL)
    console.log(mcs.web3Initialized) // true
  • Upload File to Onchain storage

    let uploadResponse = await mcs.upload('<FILE_PATH>')
    console.log(uploadResponse)
  • Pay for file storage after uploading, the response should return the source_file_upload_id and the file size.

    let tx = await mcs.makePayment('SOURCE_FILE_UPLOAD_ID>', '<FILE_SIZE>')
    console.log(transaction hash: ' + tx.transactionHash)

ℹ️ Functions

For Onchain Storage


  • POST Upload file to Filswan IPFS gateway
  • GET List of files uploaded
  • GET Files by cid
  • GET Status from filecoin
  • CONTRACT Make payment to swan filecoin storage gateway
  • CONTRACT Mint asset as NFT

For Buckets Storage


  • POST Create a bucket
  • POST Create a folder
  • POST Upload File to the bucket
  • POST Rename bucket
  • GET Delete bucket
  • GET Bucket List
  • GET File List
  • GET File information
  • GET Delete File

🌐 Contributing

Feel free to join in and discuss. Suggestions are welcome! Open an issue or Join the Discord!

Sponsors

Filecoin Foundation sponsors this project

Flink SDK - A data provider offers Chainlink Oracle service for Filecoin Network