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

dpos-offline

v3.0.4

Published

Offline Signing Transactions for DPOS Blockchains

Downloads

59

Readme

npm Build Status Coverage Status

Offline signing DPOS utils 2.0

This library can ease adoption on offline transaction signing for some Dpos coins. Works both server-side (using sodium c++ bindings) and client-side (using tweetnacl lib).

Motivation

I've built this library cause there were no such library that had all the following :

  • uses c++ binding when in node environment leveraging native code execution speed
  • easy to use/understand
  • had proper tests for both node and browsers

Furthermore the library is written in TypeScript which also provide code assist utilities to developers making it even easier to use.

Quick Start

Install using npm i dpos-offline and use it with webpack or node by requiring it in your code

var dposOffline = require('dpos-offline').dposOffline

Or directly use it in your browser by including it:

<script type="text/javascript" src="https://gitcdn.xyz/cdn/vekexasia/dpos-offline/master/dist/browser/index.js"></script>
<script type="text/javascript">
  // use dposOffline variable.
</script>

What does this library do?

Create a Send Transaction

An example worths more than 100 words.

const Lisk = require('dpos-offline').Lisk;
const Rise = require('dpos-offline').Rise;
const tx = Lisk.txs.createAndSign(
  {
    kind: 'send',
    amount: 100000000, // Satoshi
    recipient: '1L'
  },
  'my Lisk secret'
);

// tx will now contain a postable (via API) transaction object

// It works the same for Rise (or the other supported coins)
const riseTx = Rise.txs.createAndSign(
  {
    kind: 'send',
    amount: 100000000, // Satoshi
    recipient: '1R'
  },
  'my RISE secret'
)

Create a Vote Transaction

const voteTx = Rise.txs.createAndSign(
  {
    kind: 'vote',
    preferences: [
      {
        delegateIdentifier: Buffer.from('pubKey of delegate to vote'),
        action: '+'
      },
      {
        delegateIdentifier: Buffer.from('pubKey of delegate to unvote'),
        action: '-'
      }
    ]
  },
  'my RISE secret'
);

Second signing existing signed transaction

// const signedTx;
signedTx.signSignature = Rise.txs.calcSignature(signedTx, 'second secret');

// Will recalc id and transform the transaction to a postable format via API.
const transformedTx = Rise.txs.toPostable(signedTx);

Registering a delegate

const tx = Rise.txs.createAndSign({
  kind: 'register-delegate',
  identifier: 'vekexasia'
});

Other transaction types.

The following transaction types are supported using the .createAndSign method:

  • send
  • vote
  • register delegate
  • add second signature (Lisk and all Lisk derived coins)
  • create multisignature (Lisk and all Lisk derived coins)

Raw transaction creation

Sometimes you want to decide fee and timestamp (also referenced as nonce within the library). The .createAndSign method allows to specify both fee and nonce.

If you want to create your own object you can use the .fromPostable method that converts a tx in postable-via-api format to an inner tx format that could be used with the majority of methods provided.

Verify transaction signature

the .txs.verify method allows checking the provided signature object is valid (against the given pubKey).

Message Signing and Verify

Signing and verifying a message is critical for some applications. The .msgs package will provide the methods:

  • sign(msg: Buffer | string, kp: IKeypair) => Buffer & As<'signature'>
  • verify(msg: Buffer | string, signature: Buffer & As<'signature'>, publicKey: Buffer & As<'publicKey'>) => boolean

That could be used to sign and verify messages using the format used for such coin.


FAQs

Where can I find the documentation?

vekexasia.github.io/dpos-offline

Is this library secure?

Well offline signing is considered a best practice in terms of security

Is this library tested?

The library is baked by over 1000 single tests. Most of them are equality checks between this library and original code.

Does this library work on any browser?

Should work on any modern browser. Feel free to report a bug if not.

What are the tested browsers?

Chrome and Firefox through karma library

Can I add support to another coin?

Yes the library is created with extendibility in mind. Adding a new (even very different) coin support should be really easy by extending and overriding the code.

Is this library fast as "equivalent" core-code routines?

Yes. When used in node.js it uses sodium-native native bindings for node (just like core code). Yeah it's fast.

Should I use this in production?

While it's tested, use it at your own risk!

Donations

If you like my work and would like to support my work. You could consider to donate me something at the following addresses:

  • LISK: 9102643396261850794L
  • SHIFT: 16159457535471071047S
  • RISE: 9857707766596718725R