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

@moibitjs/matic

v1.0.1

Published

MoiBit module which writes provenance to matic network

Downloads

2

Readme

MoiBit + Matic

@moibitjs/matic

npm version Chat on Slack Chat on Telegram Follow us on Twitter

MoiBitJS/matic uses MoiBitJS/core module to perform file actions and the provenance of files will be stored in Matic network.

Installation

Just run the following npm command and the SDK will be installed.

npm install --save @moibitjs/matic

Get Started

import  Matic  from  'maticjs'
import  MoiBit  from  '@moibitjs/matic'
// Initialize matic object
let _matic = new Matic({
	parentProvider : 'https://ropsten.infura.io/v3/70645f042c3a409599c60f96f6dd9fbc',
	maticProvider : 'https://testnet2.matic.network'
});

// Initialize moibit object with matic object as parameter
let  mFiles = new  MoiBit(_matic)
await  mfiles.init('<your-url>',{
	API_KEY :  '<your-api-key>'
	API_SECRET : '<your-api-secret>'
});

//needs signing of transaction to matic network that stores multihash for provenance, before adding file to moibit
await  mfiles.add(file,'sample.txt')

Functions

new MoiBit(maticObject)

Bind your matic object to moibit

var  mFiles = new  MoiBit(maticObject)

mFiles.init(url,accessToken)

Initialize your MoiBit Object with matic. Get your MoiBit account here. After signing up you will be getting API_KEY , API_SECRET , URL

  • url you got after signing up

  • accessToken is a combination of API_KEY and API_SECRET

await  mFiles.init('<your-url>',{
	API_KEY :  '<your-api-key>' ,
	API_SECRET :  '<your-api-secret>'
});

mFiles.add(file,path,options)

Add file of any type which will be stored in MoiBit and the returned multi-hash will be stored in matic chain where you are expected to sign a transaction.

  • file can be window file object or stream
  • path is an absolute path in your files directory at which you want the file to be inserted.
  • options
    • createFolders is a boolean value which specifies to create a folder/not if it is not existing , that was mentioned in above path attribute (default : true)
    • pinVersion is a boolean value which tells to pin the file while adding.(default : false)
await  mFiles.add(fileObject,'parent1/folder2/file3.txt');

mFiles.read(path,responseType)

Returns file with specified return type only if the hash stored on-chain (ie., in Matic) and off-chain (ie., in MoiBit) are same, if not returns negative response

{
   	 validation : failed, 
   	 message : 'No record matching <off-chain hash>'
}
  • path is an absolute path

  • responseType can be anything among

    • arraybuffer , document , json , text , stream

    • blob - browser only

await  mFiles.read('parent1/folder2/file3.txt','blob');

to do more actions other than add & read with files module visit @moibitjs/core

Maintainers

  1. Vuppala Sai Prashanth
  2. Arunprakash

Reviewers

  1. Ayush Gupta
  2. Ganesh Prasad Kumble

Support

If you need more clarifications, feel free to join our Telegram or Slack community channels. You can also write us an email at [email protected]

License

GNU General Public License v3.0