Javascript client for Mop
npm install @redesblock/mop.js> Client library for connecting to Mop decentralised storage
Warning: This project is in beta state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.
This project is intended to be used with mop version 0.9.0. Using it with older or newer mop versions is not recommended and may not work.
``sh`
> npm install @redesblock/mop.js --save
`sh`
> yarn add @redesblock/mop.js
Be aware, if you are running Yarn v1 and are attempting to install this repo using GitHub URL, this won't unfortunately
work as it does not correctly handle execution of prepare script.
We require Node.js's version of at least 12.x
`js`
var MopJs = require("@redesblock/mop.js");
`js`
var MopJs = require("@redesblock/mop.js");
`js
import { Mop } from "@redesblock/mop.js"
mop = new Mop("http://localhost:1683")
// Be aware, this creates on-chain transactions that spend BNB and MOP!
const batchId = await mop.createVoucherBatch('100', 17)
const fileHash = await mop.uploadData(batchId, "Welcome to Mop!")
const data = await mop.downloadData(fileHash)
console.log(data.text()) // prints 'Welcome to Mop!'
`
Install project dependencies with
`sh`
npm i
In order to compile NodeJS code run
npm run compile:node
or for Browsers
npm run compile:browser`