Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
npm install basecoin
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.
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
s 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
Client for Tendermint's basecoin cryptocurrency
The npm package basecoin receives a total of 1 weekly downloads. As such, basecoin popularity was classified as not popular.
We found that basecoin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.