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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@coschain/cosjs

v1.2.8

Published

a js sdk to interact with coschain for human beings

Readme

cosjs

A js sdk to interact with coschain for human beings.

install

npm i @coschain/cosjs --save

In browser:

<script src="https://cdn.jsdelivr.net/npm/@coschain/cosjs/dist/cosjs.min.js"></script>
<script>
    let cos = new Cos("test", "https://testnode.contentos.io");

    (async () => {
      let result = await cos.wallet.accountInfo("initminer");
      console.log(result);
    })();
</script>

Usage

choose different environment

for testnode

const Cos = require('@coschain/cosjs');

let cos = new Cos("test", "https://testnode.contentos.io");

for mainnode

const Cos = require('@coschain/cosjs');

let cos = new Cos("main", "https://mainnode.contentos.io");

Example: transfer

const Cos = require('@coschain/cosjs');

let cos = new Cos("test", "https://testnode.contentos.io");

cos.wallet.addAccount("alice", "herPrivKey");


(async() => {
    let result = await cos.wallet.transfer("alice", "bob", "1.000000", "memo");
    console.log(result);
})();

Example: contract call

I have deployed a simple hello contract on testnode. The contract source

const Cos = require('@coschain/cosjs');

let cos = new Cos("test", "https://testnode.contentos.io");

cos.wallet.addAccount("alice", "herPrivKey");


(async() => {
  let result = await cos.wallet.contractCall("alice", "initminer", "hello", "greet", "[]", "0.000000");
  console.log(result.invoice);
})();

tips

  1. When trying to call a method of contract, the contract's creator should be known.
  2. The parameter args is a stringify json. Just like "[\"COC\", \"COC\", 10000000, 3]".
  3. Deploying or calling a contract is a stamina-bound operation. You can stake some cos to acquire more stamina before calling a contract.

For stake cos

(async() => {
  await cos.wallet.cosToStake("initminer", "1.000000", "initminer");
})();

Example: query table

const Cos = require('@coschain/cosjs');

let cos = new Cos("test", "https://testnode.contentos.io");

(async () => {
  let result = await cos.wallet.queryTable("liuxingfeiyu", "kryptontest", "arenas", "creator", '', 30, false);
  console.log(result);
})();

Example: generate a key-pair with a mnemonic

const Cos = require('@coschain/cosjs');
let cos = new Cos("", "");

let [pubkey, privkey, mnemonic] = cos.wallet.generateKeysWithMonemonic();
console.log(pubkey, privkey, mnemonic);

Example: generate a key-pair from a mnemonic

const Cos = require('@coschain/cosjs');
let cos = new Cos("", "");

let [pubkey, privkey] = cos.wallet.generateKeysFromMnemonic("foil confirm transfer resource use outer rack earth present lawsuit flock clay post unlock zoo muffin truck pretty across sibling wild next man fresh");
console.log(pubkey, privkey);

About

It is a wrapper for cos-grpc-js. The module is designed for Node.js and browser.

Wallet Apis

  • addAccount(name: string, privateKey: string)
  • generateKeysFromMnemonic(words: string): [string, string]
  • generateKeysWithMonemonic(): [string, string, string]
  • accountInfo(name: string, raw: ?boolean)
  • bpInfo(bp: string, raw: ?boolean)
  • transactionInfo(trxId: string, raw: ?boolean)
  • chainInfo(raw: ?boolean)
  • blockProducerList(start: raw_type.vest, limit: number, lastBlockProducer: grpc.BlockProducerResponse, raw: ?boolean)
  • createAccount(creator: string, newAccount: string, pubkey: string)
  • transfer(sender: string, receiver: string, amount: string, memo: string)
  • cosToVest(account: string, amount: string)
  • vestToCos(account: string, amount: string)
  • cosToStake(account: string, amount: string, toAccount: string)
  • stakeToCos(account: string, amount: string, toAccount: string)
  • post(sender: string, title: string, content: string, tagsStr: string)
  • reply(sender: string, parent_uuid: string, content: string)
  • vote(sender: string, idx: string)
  • contractCall(caller: string, owner: string, contract: string, method: string, args: string, payment: string)
  • voteToBlockProducer(voterValue: string, bpValue: string, cancel: boolean)
  • queryTable(owner: string, contract: string, table: string, field: string, begin: string, limit: number, reverse: boolean)
  • delegateVest(sender: string, receiver: string, amount: string, expiration: number)
  • unDelegateVest(sender: string, orderId: number)
  • vestDelegationOrderList(account: string, limit: number, is_lender: boolean)