kuchainjs

0.0.12 • Public • Published

Kuchain JavaScript Library

This library supports kuchain address generation and verification. It enables you to create an offline signature functions of different types of transaction messages.

[WARNING] This library is under ACTIVE DEVELOPMENT and should be treated as alpha version. We will remove this warning when we have a release that is stable, secure, and propoerly tested

NPM

Installation

NPM

npm install kuchainjs

Import

NodeJS

const kuchainjs = require("kuchainjs");

Usage

  • Kuchain: Generate Kuchain address from mnemonic
const kuchainjs = require("kuchainjs");

const chainId = "testing";
const lcdUrl = "http://127.0.0.1:1317";
const kuchain = kuchainjs.network(lcdUrl, chainId);

const mnemonic = "...";
const address = kuchain.getAddress(mnemonic);
const ecpairPriv = kuchain.getECPairPriv(mnemonic);
  • Kuchain: Generate Kuchain address from base64
const kuchainjs = require("kuchainjs");

const chainId = "testing";
const lcdUrl = "http://127.0.0.1:1317";
const kuchain = kuchainjs.network(lcdUrl, chainId);

const priBase64 = "...";
const prikey = kuchain.importPriKeyBase64(priBase64);
const auth = kuchain.getAddressFromPriKey(prikey);
  • Kuchain: Generate Kuchain address from uint8 array
const kuchainjs = require("kuchainjs");

const chainId = "testing";
const lcdUrl = "http://127.0.0.1:1317";
const kuchain = kuchainjs.network(lcdUrl, chainId);

const priUint8Arr = "...";
const prikey = kuchain.importPriKeyUint8Arr(priUint8Arr);
const auth = kuchain.getAddressFromPriKey(prikey);
  • Create an account with a specialized auth.
kuchain.newCreateAccMsg("validator", "acc1", auth).then(Msg => {
	console.log(JSON.stringify(Msg))
})
	...
})
  • Sign transaction by using sign and broadcast which use REST API of Kuchain
const signedTx = kuchain.sign(Msg, ecpairPriv);
kuchain.broadcast(signedTx).then(response => console.log(response));
  • See more examples of how this library works, see examples.

Supporting Message Types (Updating...)

  • If you need more message types, you can commit issues

Documentation

This library is simple and easy to use. We don't have any formal documentation yet other than examples. Ask for help if our examples aren't enough to guide you

Contribution

  • Contributions, suggestions, improvements, and feature requests are always welcome

Package Sidebar

Install

npm i kuchainjs

Weekly Downloads

1

Version

0.0.12

License

none

Unpacked Size

45.6 kB

Total Files

6

Last publish

Collaborators

  • kuchainnetwork