All Projects → cosmostation → Cosmosjs

cosmostation / Cosmosjs

Licence: mit
⭐️ CosmosJS - Cosmos JavaScript Library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cosmosjs

Akash
a secure, transparent, and peer-to-peer cloud computing network
Stars: ✭ 229 (+151.65%)
Mutual labels:  blockchain, tendermint
Etgate
Ethereum-Tendermint token sending gateway
Stars: ✭ 23 (-74.73%)
Mutual labels:  blockchain, tendermint
Go Cyber
Your 🔵 Superintelligence
Stars: ✭ 270 (+196.7%)
Mutual labels:  blockchain, tendermint
Mint
Mint Blockchain — Build blockchain powered social apps
Stars: ✭ 148 (+62.64%)
Mutual labels:  blockchain, tendermint
Clearchain
Cosmos app for clearing and settlements
Stars: ✭ 42 (-53.85%)
Mutual labels:  blockchain, tendermint
Starport
The easiest way to build a blockchain.
Stars: ✭ 204 (+124.18%)
Mutual labels:  blockchain, tendermint
Abci Host
Clojure host/server for Tendermint's ABCI protocol.
Stars: ✭ 18 (-80.22%)
Mutual labels:  blockchain, tendermint
Rust Abci
A rust implementation of the ABCI protocol for tendermint core
Stars: ✭ 115 (+26.37%)
Mutual labels:  blockchain, tendermint
Dawn
global hosting, financial automation, server-less web components
Stars: ✭ 40 (-56.04%)
Mutual labels:  blockchain, tendermint
Lotion
✨ Smooth, easy blockchain apps ✨
Stars: ✭ 882 (+869.23%)
Mutual labels:  blockchain, tendermint
Secretnetwork
𝕊 The Secret Network
Stars: ✭ 138 (+51.65%)
Mutual labels:  blockchain, tendermint
Jabci
Java implementation of the Tendermint ABCI
Stars: ✭ 48 (-47.25%)
Mutual labels:  blockchain, tendermint
Tendermint code analysis
通用区块链平台tendermint源码分析
Stars: ✭ 134 (+47.25%)
Mutual labels:  blockchain, tendermint
Ethermint
Ethermint is a scalable and interoperable Ethereum, built on Proof-of-Stake with fast-finality using the Cosmos SDK.
Stars: ✭ 207 (+127.47%)
Mutual labels:  blockchain, tendermint
Chainkit
ChainKit is a toolkit for blockchain development. It includes primitives for creating, building and running decentralized applications.
Stars: ✭ 121 (+32.97%)
Mutual labels:  blockchain, tendermint
Ethermint Archive
Ethereum on Tendermint using Cosmos-SDK!
Stars: ✭ 667 (+632.97%)
Mutual labels:  blockchain, tendermint
Cosmos
Internet of Blockchains ⚛
Stars: ✭ 938 (+930.77%)
Mutual labels:  blockchain, tendermint
Py Abci
Python based ABCI Server for Tendermint
Stars: ✭ 48 (-47.25%)
Mutual labels:  blockchain, tendermint
Weave
Easy-to-use SDK to build Tendermint ABCI applications
Stars: ✭ 1,122 (+1132.97%)
Mutual labels:  blockchain, tendermint
Atom Supercollider
SuperCollider development environment for Atom.io
Stars: ✭ 85 (-6.59%)
Mutual labels:  atom

NPM Downloads

Cosmostation logo

CosmosJS - Cosmos JavaScript Library

⭐️ Developed / Developing by Cosmostation

A JavasSript Open Source Library for Cosmos Network, IRISnet, Kava, Band Protocol, Starname, Secret Network, Akash Network, and CertiK.

This library supports cosmos address generation and verification. It enables you to create an offline signature functions of different types of transaction messages. It will eventually support all the other blockchains that are based on Tendermint in the future.

⚠️ If you are using under @cosmostation/[email protected]: Be very careful! @cosmostation/[email protected]+ will supports protobuf signing for cosmos-sdk 0.40.0+. You can download it from protobuf-test branch.

License Latest Stable Version NPM Downloads

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

NPM (Amino)

npm install @cosmostation/cosmosjs

Yarn (Amino)

yarn add @cosmostation/cosmosjs

Warning

  • If you use a version under 0.9.x, it will be deprecated. You can download protobuf version from the branch of protobuf-test.

Import

NodeJS

const cosmosjs = require("@cosmostation/cosmosjs");

ES6 module

import cosmosjs from "@cosmostation/cosmosjs";

CDN

<script src="https://cdn.jsdelivr.net/npm/@cosmostation/[email protected]/dist/cosmos.min.js"></script>

Usage

  • Cosmos: Generate Cosmos address from mnemonic
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "cosmoshub-4";
const cosmos = cosmosjs.network(lcdUrl, chainId);

const mnemonic = "..."
cosmos.setPath("m/44'/118'/0'/0/0");
const address = cosmos.getAddress(mnemonic);
const ecpairPriv = cosmos.getECPairPriv(mnemonic);
  • Iris
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "irishub-1";
const iris = cosmosjs.network(lcdUrl, chainId);
iris.setBech32MainPrefix("iaa");
  • Kava
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "kava-6";
const kava = cosmosjs.network(lcdUrl, chainId);
kava.setBech32MainPrefix("kava");
  • Band
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "band-guanyu-mainnet";
const band = cosmosjs.network(lcdUrl, chainId);
band.setBech32MainPrefix("band");
  • Starname
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "iov-mainnet-2";
const iov = cosmosjs.network(lcdUrl, chainId);
iov.setBech32MainPrefix("star");
  • Secret Network
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "secret-2";
const scrt = cosmosjs.network(lcdUrl, chainId);
scrt.setBech32MainPrefix("secret");
  • Akash Network
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "akashnet-2";
const akash = cosmosjs.network(lcdUrl, chainId);
akash.setBech32MainPrefix("akash");
  • Certik
const cosmosjs = require("@cosmostation/cosmosjs");

const chainId = "shentu-1";
const certik = cosmosjs.network(lcdUrl, chainId);
certik.setBech32MainPrefix("certik");

Generate ECPairPriv value that is needed for signing signatures

const ecpairPriv = cosmos.getECPairPriv(mnemonic);

Transfer ATOM to designated address.

  • Make sure to input proper type, account number, and sequence of the cosmos account to generate StdSignMsg. You can get those account information on blockchain
  • Above 0.5.0 version, CosmosJS follows the exact same json format as Cosmos SDK defines.
cosmos.getAccounts(address).then(data => {
	let stdSignMsg = cosmos.newStdMsg({
		msgs: [
			{
				type: "cosmos-sdk/MsgSend",
				value: {
					amount: [
						{
							amount: String(100000),
							denom: "uatom"
						}
					],
					from_address: address,
					to_address: "cosmos18vhdczjut44gpsy804crfhnd5nq003nz0nf20v"
				}
			}
		],
		chain_id: chainId,
		fee: { amount: [ { amount: String(5000), denom: "uatom" } ], 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 /tx REST API

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

Cosmostation offers LCD url is deprecated. In order to maintain stable blockchain service, it is recommended to prepare your rest server.

Supporting Message Types (Updating...)

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

When opening a PR with a minor fix, make sure to add #trivial to the title/description of said PR.

Cosmostation's Services and Community

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Booyoun

💻 🐛 🚧

JayB

💻 📖 🚧

billy rennekamp

💻 🐛

Tony Phuong Nguyen

💻

Tobias Schwarz

💻

Scott Burch

🚧

billy rennekamp

🚧

Pierre Grimaud

🚧

Taariq Levack

🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].