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

@kunroku/iost

v2.2.0

Published

new iost.js sdk

Downloads

71

Readme

JS SDK of IOST,helps developers interact with iost blockchain node, including geting block data, sending transactions, etc. It can be used in browsers and also on nodejs platform.

Installation

Using npm in your project

npm install @kunroku/iost

CDN

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@kunroku/[email protected]/dist/iost.min.js"></script>

exports to window.IOST global.

Sign up example

const IOST = require('@kunroku/iost');

// init iost sdk (default is for localhost network)
const iost = new IOST({
    host: 'http://127.0.0.1:30001',
    chainId: 1020,
    gasLimit: 1000000
});

const creatorId = 'admin';
const secretKey = '2yquS3ySrGWPEKywCPzX4RTJugqRh7kJSo5aehsLYPEWkUxBWA39oMrZ7ZxuM4fgyXYs2cPwh5n8aNNpH5x2VyK1';
const account = new IOST.Account(creatorId);
const kp = new IOST.KeyPair.Ed25519(IOST.Bs58.decode(secretKey));
account.addKeyPair('active', kp);
account.addKeyPair('owner', kp);

const newId = 'test001';
const newKp = IOST.KeyPair.Ed25519.randomKeyPair();
// show secret key of new account
console.log(IOST.Bs58.encode(newKp.secretKey));

const tx = iost.contract.auth.signUp(newId, IOST.Bs58.encode(newKp.publicKey), IOST.Bs58.encode(newKp.publicKey));
iost.contract.gas.pledge(creatorId, newId, 20, tx);
iost.contract.ram.buy(creatorId, newId, 1024, tx);

iost.setPublisher(account);

const handler = iost.signAndSend(tx);
handler.listen();
handler.onPending(console.log);
handler.onSuccess(console.log);
handler.onFailed(console.log);

Usage

Encoding

IOST.Bs58.encode(buf)

buffer to base58string

IOST.Bs58.decode(buf)

base58string to buffer

IOST.KeyPair instance

Ed25519 Algorithm

new IOST.KeyPair.Ed25519(secretKey)

initialize with buffer or uint8array type secret key

Secp256k1 Algorithm

new IOST.KeyPair.Secp256k1(secretKey)

initialize with buffer or uint8array type secret key

IOST.Account instance

new IOST.Account(id)

initialize with iost account id

account.addKeyPair(permission, keyPair)

add keyPair to account instance

IOST instance

new IOST(config?)

config type

{
	host?: string,
	chainId?: number,
	gasRatio?: number,
	gasLimit?: number,
	delay?: number,
	expiration?: number,
	defaultLimit?: 'unlimited' | number
}
setServerTimeDiff()

set the time difference between your environment and the node

iost.createTx()

create empty transaction instance

iost.call(contract, abi, args, tx?)

returns tx of calling smart contract

if you want to add action to already exist tx instance, you can set it the end of args

iost.setPublisher(account)

set IOST.Account to IOST instance

iost.addSigner(account, permission)

for multi signature

iost.signAndSend(tx, log?)

add signature of publisher and signer to tx and then send it

if you want to check processing time in the console, set log true

const handler = signAndSend(tx);
handler.listen();
handler.onPending(res => { console.log(res) });
handler.onSuccess(res => { console.log(res) });
handler.onFailed(res => { console.log(res) });
handler.listen(config?)

if you want to change listen config, you can set like this

handler.listen({ interval: 1000, times: 50, irreversible: true });