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

eosjs-node-cli

v0.1.1

Published

basic cleos as nodejs version using eosjs

Downloads

6

Readme

eosjs-node-cli js-standard-style npm version

eosjs-node-cli made by Marcel Morales
using eosjs

Versions

| MarcelBlockchain/eosjs-node-cli | Npm | | --- | --- | | tag: 0.1.1 | npm install eosjs-node-cli |

Usage

  • Using standard private key on test net by default. Change config in ./eos.js
  • Make sure to have docker running as explained here
  • Uncomment lines to enable functions in ./app.js
  • Functions print and return all of their values, see ./eos.js

Blockchain

eos.getBlockHeight()
eos.getCurrentBlockInfo()

Keys

  • more infos: https://github.com/EOSIO/eosjs-ecc/blob/master/src/key_private.js
  • seed: any length string. This is private. The same seed produces the same private key every time. At least 128 random bits should be used to produce a good private key.
//  src: https://github.com/bitcoinjs/bip39/blob/master/index.js
//  Generates a random mnemonic (uses crypto.randomBytes under the hood), defaults to //  128-bits of entropy
//  strength = 256 for 24 words, 128 for 12
eos.generateMnemonic(128)
//  derives the master, owner & active private and public keys from mnemonic
eos.deriveFromMnemonic(eos.generateMnemonic(128))
eos.generateRandomPrivKey()
console.log(eos.generatePrivKeyFromSeed('SEED123'))
eos.fromPrivToPub(privKeyTest)
eos.isPubKeyValid(pubKeyTest)
eos.isPrivKeyValid(privKeyTest)

Accounts

EOS public and private keys can be generated off the chain, but EOS users need to create an account before they can operate on the chain. So activated users are needed to send on-chain transactions to new users in order to help them create accounts. By default users need to find tripartite help.

//  main net only:  
eos.getAccountNamesFromPubKey(pubKeyTest2)
//  main net only: (i.e. 'binancecleos'):
eos.getAccSystemStats(accBinance)
//  account name must be less than 13 characters
//  can only contain the following symbols: .12345abcdefghijklmnopqrstuvwxyz:
//  default: bytes = 8192, stake_net_quantity = '10.0000 SYS', stake_cpu_quantity = '10.0000 SYS', transfer = 0:
//  ownerPubKey and activePubKey can be the same, but is less secure
//  optional: bytes, stake_net_quantity, stake_cpu_quantity, transfer
eos.createAccountPackage('ownerPubKey', 'activePubKey', 'accountName', bytes, stake_net_quantity, stake_cpu_quantity, transfer)
//  args: 'accountName', ownerPubKey, activePubKey
eos.createSingleAccount('accountName', pubKeyTest, pubKeyTest)

Transactions

  • Transactions can be considered confirmed with 99.9% certainty after an average of 0.25 seconds from time of broadcast.
  • The EOS aBFT algorithm provides 100% confirmation of irreversibility within 1 second.
//  sender, receiver, quantity in format: '50.0000 SYS' , memo, | + optional: sign = true, broadcast = true
eos.transfer(acc1, acc2, '4.0000 SYS', 'myMemo1', true, true)
//  first creates an unsigned transaction, signs it and then broadcasts it. All separately. See logs()
eos.transferSignPushTransaction(acc1, acc2, '5.0000 SYS', 'myMemo2', privKeyTest)
//  just signs the transaction and returns it:
//  returns signature. Args: (from, to, quantity, memo = '')
eos.getSignature(acc1, acc2, quantityTest, memo = 'myMemo7')
//  signs transaction and returns it. Args: (transaction, from, to, quantity, memo = '')
eos.signTr(tr, from, to, quantity, memo = 'otherMemo')
//  insert return value from eos.transfer(..., signed = true, broadcast = false);
eos.pushTransaction(returnValueFrom.eos.transfer)
//  accountName, (+ int allAboveBlockHeightX --> optional)
eos.getOutgoingTransactions(accBinance)
//  get transaction info. Optionally with a block number hint (trBlockHeight)
//  note: example tr only visible when switching to main net
eos.getTransaction(exampleTrxMainNet, trBlockHeight) // sender e.g.: 'binancecleos' on main net
//  was tr executed? Optionally pass a block number hint (trBlockHeight). Returns bool
eos.isTransactionExecuted(exampleTrxMainNet, trBlockHeight)

Currency

// If you look at the result value, you can see an array in the form of a string.
// This is because there could be tokens with many different symbols in the account
eos.getCurrencyBalance(acc1) //  using EOS account name
// works for tokens as well, see https://github.com/eoscafe/eos-airdrops
// 'SYMBOL', 'eos.contractName'. E.g. 'EOS', 'eosio.token' (main net) / 'SYS', 'eosio.token' (local test net)
eos.getCurrencyStats('IQ', 'everipediaiq') // IQ on main net
//  amount in format '1000.0000 XYZ', receiver, memo:
eos.createToken('1000.0000 XXZX', acc1, 'new token memo')

Other

//  converts '1.3000 EOS' --> 1.3, see floatRegex in eosjs.js
console.log('tofloat: ', eos.toFloat('1.03002000'))