bdledger-sdk
v0.2.0-alpha
Published
BDLedger SDK for Node.js
Downloads
17
Maintainers
Readme
BDLedger SDK for Node.js
Installation
npm install --save bdledger-sdk
Set esModuleInterop to true
in your `tsconfig.json.
Usage
Example:
import { Bdledger, blockToHexView, transactionToHexView } from 'bdledger-sdk'
const bdledger = new Bdledger('localhost:2401')
test()
async function test() {
const version = await bdledger.clientVersion()
console.log(version)
const ledgers = await bdledger.getLedgers()
console.log(ledgers)
const tx = await bdledger.getTransactionByHash({
ledger: 'default',
hash: Buffer.from('52e050aa413dc5a3b32488c4fd0aefb103f8e667', 'hex'),
})
if (tx) {
console.dir(transactionToHexView(tx))
}
let b = await bdledger.getBlockByHash({
ledger: 'default',
hash: Buffer.from('572b7531addccbee30ebb5d9a77544a0f2229cb0', 'hex'),
fullTransactions: false,
})
if (b) {
console.dir(blockToHexView(b))
}
b = await bdledger.getBlockByHash({
ledger: 'default',
hash: Buffer.from('572b7531addccbee30ebb5d9a77544a0f2229cb0', 'hex'),
fullTransactions: true,
})
if (b) {
console.dir(blockToHexView(b))
}
}
Please refer to:
test/test.js
ortest/test.ts
- gRPC API
- gRPC examples for Node.js
grpc
packagegoogle-protobuf
package
Development
npm install
git submodule update --remote
Run in api/grpc
npm install
Generate gRPC code with:
npm run genGrpc
Generated gRPC code will be in src/grpc
Reference: gRPC examples for Node.js
Testing (TODO)
- Download mock server
- Run mock servers with
--port={{port}}
- Set the port in
test/client.test.js
- Run
npm test