Libra gRPC: the Libra client for JavaScript lovers

Hey devs,

I’ve released Libra gRPC a JavaScript client to connect to Libra testnet node. You can use it to query data from Libra blockchain.

On GitHub

On NPM

To install Libra gRPC on Node.js, open your terminal and run:

npm install libra-grpc --save

Usage

var libra = require('libra-grpc');

// Init gRPC client
var client = new libra.Client('ac.testnet.libra.org:8000');

// Get account state
var params = {
  address: Buffer.from('435fc8fc85510cf38a5b0cd6595cbb8fbb10aa7bb3fe9ad9820913ba867f79d4', 'hex')
};
client.request('get_account_state', params, function(err, result) {
  console.log(err, result);
});

// If a callback is not provided, a Promise is returned
client.request('get_account_state', params).then(function(result) {
  console.log(result);
});

API methods

Here are the methods you can use from the API:

get_account_state
get_account_transaction_by_sequence_number
get_events_by_event_access_path
get_transactions

Utils

The last release include function to deserialize raw transaction bytes which are returned by “get_transactions” API method.

Have it a try and let me know if you got suggestions!

Best,

6 Likes

how does the “deserialize raw transactions” work?

I appear to be getting

var rawTx = libra.utils.deserializeRawTxnBytes(rawTxnBytes);
^
TypeError: Cannot read property ‘deserializeRawTxnBytes’ of undefined

thanks

Did you try yarn test? Test worked well for me.

How do you import libra-grpc? Does it work if you import libra-grpc/dist/libra.cjs instead? I think your environment load the esm version.