Skip to content

rizon-world/rizonjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RizonJS

A JavasSript Open Source Library for RIZON Blockchain.

Installation

In order to fully use this library, you need to run a local or remote full node and set up its rest server, which acts as an intermediary between the front-end and the full-node.

Git

git clone https://github.com/rizon-world/rizonjs.git

Import

NodeJS

const rizonjs = require("rizonjs");

ES6 module

import rizonjs from "rizonjs";

Browser script

  • You can see example file at /example/browser-example.html
  • You need to setup rizon blockchain node in local or remote
<script src="../dist/rizon.js"></script>

Usage

  • Rizon: Generate Rizon address from mnemonic
const rizonjs = require("rizonjs");

const chainId = "groot-14";
const rizon = rizonjs.network(lcdUrl, chainId);

const mnemonic = "..."
rizon.setPath("m/44'/118'/0'/0/0");
const address = rizon.getAddress(mnemonic);
const ecpairPriv = rizon.getECPairPriv(mnemonic);

Generate ECPairPriv value that is needed for signing signatures

const ecpairPriv = rizon.getECPairPriv(mnemonic);

Transfer ATOLO to designated address.

  • Make sure to input proper type, account number, and sequence of the rizon account to generate StdSignMsg. You can get those account information on blockchain
rizon.getAccounts(address).then(data => {
	let stdSignMsg = rizon.newStdMsg({
		msgs: [
			{
				type: "cosmos-sdk/MsgSend",
				value: {
					amount: [
						{
							amount: String(100000),
							denom: "uatolo"
						}
					],
					from_address: address,
					to_address: "rizon1xjdla8awqz8kw74sakdh969t7mm4ypwdwnj435"
				}
			}
		],
		chain_id: chainId,
		fee: { amount: [ { amount: String(5000), denom: "uatolo" } ], gas: String(200000) },
		memo: "",
		account_number: String(data.account.account_number),
		sequence: String(data.account.sequence)
	});

	...
})

Sign transaction by using stdSignMsg and broadcast by using the Rizon REST API(LCD)

const signedTx = rizon.sign(stdSignMsg, ecpairPriv);
rizon.broadcast(signedTx).then(response => console.log(response));

Supporting Message Types

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published