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

@decent-bet/node-mpp

v1.3.9

Published

node library to perform multiparty protocol (MPP) functionality for contracts on the Vechain Thor blockchain

Downloads

46

Readme

Node MPP

Simple node library to setup Vechain's MPP for any deployed contract on a compatible Vechain Thor Blockchain.

Pre-requisites

Setting up

  1. Install npm

  2. Install Vechain Thor

  3. Clone this repository

  4. Install the repository packages

    npm install

Instructions

Initialize a new node MPP instance like below

const mpp = new MPP(
    contractAddresses,
    privateKey,
    thorUrl
)

Parameters

  • contractAddresses - Object containing name:address key-value pairs for contracts to perform MPP actions on
  • privateKey - Private key for contract address
  • Thor URL - Thor instance URL

Note: A node MPP instance is designed to handle one contract address on initialization. If you intend to handle multiple contract addresses, you would have to use multiple instances of node MPP.

You can now use the mpp instance to perform any of commands below. Node MPP performs checks before sending state changing transactions to reduce transaction reverts and wasted energy.

MPP transactions or calls on a contract would be made with the following format:

    await mpp.contractName.mppMethod

Transactions

sponsor()

await mpp.quest.sponsor()

Volunteers to sponsor the contract using the default account linked to the MPP instance' private key.

unsponsor()

await mpp.quest.unsponsor()

Removes the default account from being a sponsor of the contract if it had been a sponsor earlier.

selectSponsor(sponsor)

await mpp.quest.selectSponsor(sponsor)

Parameters

  • sponsor - Address of sponsor to be selected

Selects a sponsor address. The sponsor must have volunteered to be a sponsor by calling sponsor(). This can only be sent by the current contract master.

setMaster(master)

await mpp.quest.setMaster(master)

Parameters

  • master - Address of master to be selected

Selects a master address. This can only be sent by the current contract master.

addUser(address)

await mpp.quest.addUser(userAddress)

Parameters

  • address - Address of user to be added

Adds a new user to the MPP whitelist for the contract. Throws if the user has already been added. This can only be sent by the current contract master.

removeUser(address)

await mpp.quest.removeUser(userAddress)

Parameters

  • address - Address of user to be removed

Removes a user from the MPP whitelist of the contract. Throws if the user has not been added. This can only be sent by the current contract master.

setCreditPlan(credit, recoveryRate)

await mpp.quest.setCreditPlan(credit, recoveryRate)

Parameters

  • credit - the maximum amount of VTHO (in wei) that can be accumulated
  • recoveryRate - amount of VTHO (in wei) accumulated per block to pay for transactions for each user

Sets a new credit plan for the contract address as defined by the passed credit and recovery rate. This can only be sent by the current contract master.

Calls

isSponsor(address)

const isSponsor = await mpp.quest.isSponsor(address)

Parameters

  • address - Address to check sponsor status

Returns whether an address has volunteered to sponsor the contract.

isUser(address)

const isUser = await mpp.quest.isUser(address)

Parameters

  • address - Address to check user status

Returns whether an address has been added to the contract whitelist.

currentSponsor()

const currentSponsor = await mpp.quest.currentSponsor()

Returns the current selected sponsor for the contract.

currentMaster()

const currentMaster = await mpp.quest.currentMaster()

Returns the current master for the contract.

getCreditPlan()

const creditPlan = await mpp.quest.getCreditPlan()

Returns the active credit plan for the contract.