Neopolitan Pizza Maker

    @moibitjs/matic

    1.0.1 • Public • Published

    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 hello@moibit.io

    License

    GNU General Public License v3.0

    Install

    npm i @moibitjs/matic

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    none

    Unpacked Size

    46.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • its_vsp
    • aicumen