0.4.0 • Published 7 years ago

@dadi/nano v0.4.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Node.js JSON-RPC Client for Nano

Overview

Install

$ npm install @dadi/nano

Usage

const Nano = require('@dadi/nano')

// configure connection options
const options = {
  host: '127.0.0.1',
  port: 3456
}

const nano = new Nano(options)

nano
  .accountInfo('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est')
  .then(accountInfo => {
    console.log(accountInfo)
  })

Optional arguments

Some calls accept optional parameters, as seen in the documentation for Account Info. There are two ways to call all methods, one is to specify all the arguments, in order (as specified in callSpec.js), or to pass an object containing properties for the arguments you need.

Specify all arguments

nano
  .accountInfo('xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est', null, true, true)
  .then(accountInfo => {
    console.log(accountInfo)
  })

Single object argument

nano
  .accountInfo({
    account: 'xrb_1ipx847tk8o46pwxt5qjdbncjqcbwcc1rrmqnkztrfjy5k7z4imsrata9est',
    weight: true
  }).then(accountInfo => {
    console.log(accountInfo)
  })

Configuration

PropertyDescriptionDefault
host'127.0.0.1'
port3456
protocol'http'
user'user'
password'pass'