bc-sdk-community
TypeScript icon, indicating that this package has built-in type declarations

0.0.16 • Public • Published

BC RPC SDK

Tests

Tests are written in Jest framework. Run them using yarn run test.

Examples

examples/get-balance.ts:

import RpcClient from '../src/client';
import {
    GetBalanceRequest
} from '../src/protos/bc_pb';
 
const address = process.env.BC_RPC_ADDRESS || 'https://localhost:3000'
const scookie = process.env.BC_RPC_SCOOKIE
 
const client = new RpcClient(address, scookie);
const req = new GetBalanceRequest();
req.setAddress('<your address>');
client.getBalance(req).then(balance => {
    console.log(balance);
})

Before running install ts-node with yarn global add ts-node

Then run like NODE_TLS_REJECT_UNAUTHORIZED=0 BC_RPC_ADDRESS=https://localhost:3001 BC_RPC_SCOOKIE=trololo ts-node examples/get-balance.ts

And you should get response similar to this:

{ confirmed: '7536',
  unconfirmed: '0',
  collateralized: '96',
  collateralizedspendable: '0',
  unit: 'nrg' }

Dependents (0)

Package Sidebar

Install

npm i bc-sdk-community

Weekly Downloads

0

Version

0.0.16

License

none

Unpacked Size

914 kB

Total Files

79

Last publish

Collaborators

  • cryptosmileee