Giter Club home page Giter Club logo

rizonjs's Introduction

RizonJS

A JavasSript Open Source Library for Rizon.

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/dogesa-dac/rizonjs

Import

NodeJS

const rizonjs = require("rizonjs");

ES6 module

import rizonjs from "rizonjs";

Browser script

  • You can see example file at /example/browser-example.html
<script src="../dist/rizon.js"></script>

Usage

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

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

const mnemonic = "..."
rizon.setPath("m/44'/1217'/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

  • If you need more message types, you can see /docs/msg_types

rizonjs's People

Contributors

dogesa-dac avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.