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

basecoin

v2.3.1

Published

Client for Tendermint's basecoin cryptocurrency

Downloads

31

Readme

basecoin

npm install basecoin

API

NOTE: For all functions in this document which take a callback, you may choose to not pass in a callback and the function will return a Promise instead.


Basecoin

let bc = Basecoin('ws://localhost:46657')

Creates a Basecoin client, connecting to the Tendermint RPC server at localhost:46657.

bc.getAccount(address, cb)

Queries for info about an account. Note that any account can be queried, not only ones created locally.

address should be a Buffer or array of bytes.

bc.sendTx(tx, cb)

Broadcasts a transaction.

tx should be a Transaction object.

bc.fetchTxs(addresses, [startHeight], cb)

Fetches all transactions from the blockchain which are relevant to the given addresses (e.g. they send to or from one or more of the given addresses). Returns (err, transactions) (an array of transaction objects) to the callback.

addresses should be an array of addresses (where each address is a Buffer or array of bytes).

startHeight is optional, and if specified only transactions which came in blocks with a height greater than startHeight will be returned. If not specified, we fetch starting at the chain's genesis.

bc.on('block', listener)

Calls listener with a Block object whenever a new block is added to the blockchain.

bc.wallet(path, cb)

Creates or loads a wallet at the given file path. Returns a Wallet, which has the methods described below.


Wallet

Wallets store a collection of accounts/addresses in a local LevelDB database, and watch for incoming transactions to any of those accounts. It also tracks the balances for all of its accounts and can be used to generate outgoing transactions.

wallet.createAccount(cb)

Generates a new Account which can be used to receive funds, and saves it in the wallet database. Returns an Account object to the callback.

wallet.getBalances()

Gets the total balance for all accounts in the wallet. The return value will look like this:

[
  { denom: 'btc', amount: 1234 },
  { denom: 'atom', amount: 567890 }
]

wallet.getAccount(address)

Returns the Account object with the given address.

wallet.on('tx', listener)

Calls listener whenever a transaction is seen which sends funds to or from an account in the wallet.

wallet.on('receive', listener)

Calls listener whenever a transaction is seen which sends funds to an account in the wallet.

wallet.on('send', listener)

Calls listener whenever a transaction is seen which sends funds from an account in the wallet.

wallet.accounts

An array containing all account objects in the wallet.

wallet.addresses

An array containing all addresses of accounts in the wallet.

wallet.txs

An array containing all relevant transactions seen by the wallet. Each transaction has the following structure:

{
  tx: Transaction, // Transaction type
  time: Number // Unix timestamp (in milliseconds)
}

wallet.state

An object containing information about the wallet's sync state:

{
  // the height of the block the wallet has synced to
  syncHeight: Number
}