Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

basecoin

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basecoin

Client for Tendermint's basecoin cryptocurrency

  • 2.3.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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
}

FAQs

Package last updated on 06 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc