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

remme

v1.1.3

Published

REMME Javascipt API

Downloads

33

Readme

REMME JavaScript Client

npm

An open source JS integration library for REMChain, simplifying the access and interaction with REMME nodes both public or permissioned.

How to use

1. Install and run REMME node with required REST API methods enabled.

You can check out how to do that at REMME core repo. Note: you can enable/disable methods by modifying REMME_REST_API_AVAILABLE_METHODS eviroment variable at the .env file.

2. Install the latest version of library to your JS project

Node

npm install remme

Yarn

yarn add remme

In the Browser

Use the prebuild dist/remme.min.js, or build using the [remme][repo] repository:

npm run build

Then include dist/remme.min.js in your html file. This will expose Remme on the window object.

3. Run methods of RemmeClient class to interract with REMME node.

4. Possible errors and solutions

Can't find name "Long"

Describe: Our library use protobuf.js to work with protobufs. So for usage with Typescript you may get this error. Solution:

  1. You need to install @types/long.
  2. You need to import Long before import remme library

Can't resolve 'crypto' | Can't resolve 'stream'

Describe: Our library use crypto nodejs package for working with hash. So for usage with Typescript you may get this error. Solution: https://github.com/ethereum/web3.js/issues/1555#issuecomment-388113909

  1. open node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js
  2. Find "node: false", and change it to "node: {crypto: true, stream: true}"

Failed to minify

Describe: Our library use sawtooth-sdk package. So for usage with React you may get this error if you build app. Issue: https://github.com/hyperledger/sawtooth-sdk-javascript/issues/4 Solution:

  1. npm run eject
  2. npm i [email protected]
  3. In webpack.config.prod.js you need import this package and use it:
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
// ...

// Find string: "Minify the code."
// Comment or remove new webpack.optimize.UglifyJsPlugin with all configuration after this string.
// And provide next string:
new UglifyJsPlugin(),

Examples

Implement Remme client

const Remme = require("remme");
// import Remme from "remme";

const privateKeyHex = "7f752a99bbaf6755dc861bb4a7bb19acb913948d75f3b718ff4545d01d9d4f10";
const networkConfig = {
    nodeAddress: "localhost:8080",
    sslMode: false,
};
const remme = new Remme.Client({ privateKeyHex, networkConfig });

Tokens

const { RemmeFamilyName } = require("remme-utils");
const someAccountPublicKeyInHexFormat = "0306796698d9b14a0ba313acc7fb14f69d8717393af5b02cc292d72009b97d8759";
const someRemmeAddress = generateAddress(RemmeFamilyName.Account, someAccountPublicKeyInHexFormat);
console.log(`Account ${someRemmeAddress} balance - ${balance} REM`);

const transactionResult = await remme.token.transfer(someRemmeAddress, 100);
console.log(`Sending tokens...BatchId: ${transactionResult.batchId}`);

const transactionCallback = async (err, result) => {
    if (err) return;
    console.log("token", result);
    const newBalance = await remme.token.getBalance(someRemmeAddress);
    console.log(`Account ${someRemmeAddress} balance - ${newBalance} REM`);
    transactionResult.closeWebSocket()
};

transactionResult.connectToWebSocket(transactionCallback);

Certificates

const certificateTransactionResult = await remme.certificate.createAndStore({
    commonName: "userName1",
    email: "[email protected]",
    name: "John",
    surname: "Smith",
    countryName: "US",
    validity: 360,
    serial: "some serial"
});

const certificateTransactionCallback = async (err, response) => {
    if (err) return;
    console.log("certificate", response);
    console.log(`Certificate was saved on REMchain at block number: ${response.block_number}`);
    const certificateStatus = await remme.certificate.check(certificateTransactionResult.certificate);
    console.log(`Certificate IsValid = ${certificateStatus.valid}`);
    certificateTransactionResult.closeWebSocket();
};

certificateTransactionResult.connectToWebSocket(certificateTransactionCallback);

Subscribing to Events

RemmeEvents is enums which describe all available events.

import { RemmeEvents } from "remme-web-socket-events";

remme.events.subscribe({
    events: RemmeEvents.SwapInit
}, (err, res) => {
    if (err) {
        console.log(err);
        return;
    }
    console.log(res);
})

Also we give a possibility to start listen events from previous block by providing last known block id

import { RemmeEvents } from "remme-web-socket-events";

remme.events.subscribe({
    events: RemmeEvents.SwapInit,
    lastKnownBlockId: "db19f0e3b3f001670bebc814e238df48cef059f3f0668f57702ba9ff0c4b8ec45c7298f08b4c2fa67602da27a84b3df5dc78ce0f7774b3d3ae094caeeb9cbc82"
    }, (err, res) => {
        if (err) {
          console.log(err);
          return;
        }
        console.log("events", res);
});

Unsubscribe from listening events

remme.events.unsubscribe();

License

REMME software and documentation are licensed under Apache License Version 2.0 <LICENSE>_.