1.4.6 • Published 2 months ago

bch-consumer v1.4.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

bch-consumer

bch-consumer is a JS library for retrieving eCash or BCH blockchain data from ipfs-bch-wallet-consumer, which in turn gets its information from ipfs-bch-wallet-service. Read the article Realizing the Web3 Cash Stack to learn more about this software stack.

Installation

npm install --save bch-consumer

Instantiation

// Configure this constant for your infrastructure.
const RESTURL = 'https://free-bch.fullstack.cash'
// const RESTURL = 'http://localhost:5005'
console.log(`Using this REST URL for bch-consumer: ${RESTURL}`)

// Instantiate bch-consumer
const BchConsumer = require('bch-consumer')
const bchConsumer = new BchConsumer({ restURL: RESTURL })

Examples

Here are some simple examples illustrating how to use this library. These examples assume the BCH blockchain.

Get a Balance for an Address

const addr = 'bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7'
const result = await bchConsumer.bch.getBalance(addr)
console.log('result: ', result)

Get UTXOs for an Address

const addr = 'bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7'
const result = await bchConsumer.bch.getUtxos(addr)
console.log('result: ', result)

Send a Transaction

const hex = '0100000001000000000000abcdef'
const result = await bchConsumer.bch.sendTx(hex)
console.log('result: ', result)

Get Transaction History for an Address

const addr = 'bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7'
const result = await bchConsumer.bch.getTxHistory(addr)
console.log('result: ', result)

Get Transaction Details for a TXID

const txids = [
  '01517ff1587fa5ffe6f5eb91c99cf3f2d22330cd7ee847e928ce90ca95bf781b'
]
const result = await bchConsumer.bch.getTxData(txids)
console.log('result: ', result)

Lookup the Public Key for an Address

const addr = 'bitcoincash:qp3sn6vlwz28ntmf3wmyra7jqttfx7z6zgtkygjhc7'
const result = await bchConsumer.msg.getPubKey(addr)
console.log('result: ', result)

Licence

MIT

1.4.6

2 months ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

2 years ago

1.3.1

2 years ago

1.2.3

2 years ago

1.3.0

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago