diff --git a/README.md b/README.md index 6310c79..3bb0b3c 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,16 @@ A helper library for interacting with QRL nodes via GRPC import the helper class: ```javascript -import QrlNode from '@theqrl/node-helpers' +var QrlNode = require("@theqrl/node-helpers") +// or for ES6 style imports: import QrlNode from '@theqrl/node-helpers' ``` instantiate a new class object: ```javascript -const ip = 'testnet-1.automated.theqrl.org' -const port = '19009' -const testnet = new QrlNode(ip, port) +var ip = 'testnet-1.automated.theqrl.org' +var port = '19009' +var testnet = new QrlNode(ip, port) ``` make a connection to the node: @@ -40,6 +41,26 @@ testnet.api('GetStats').then((result) => { }) ``` +Complete example: + +```javascript +// example.js (requires node v10) + +var QrlNode = require("@theqrl/node-helpers") + +var ip = 'testnet-1.automated.theqrl.org' +var port = '19009' +var testnet = new QrlNode(ip, port) + +testnet.connect().then(() => { +console.log(testnet.connection) // true if connection successful +}) + +testnet.api('GetStats').then((result) => { + console.log(result) +}) +``` + ## Development of this module Development requires node version > 10. If using nvm (which is recommended) then `nvm use` inside the cloned repo will set a correct node version.