Git Product home page Git Product logo

grin-client-js's Introduction

grin-client-js

A JavaScript client for Grin's V1 API.

Install

$ npm install grin-client

Usage

Example

const GrinClient = require('grin-client');

(async function () {
  const API_SECRET = '...';
  const grin = new GrinClient({
    protocol: 'http',
    hostname: '127.0.0.1',
    port: 3413,
    username: 'grin',
    password: API_SECRET,
  });

  try {
    const status = await grin.status();
    const block = await grin.blocks(13474);
    // ...
  } catch(e) {
    console.log(e);
  }
})();

API

new GrinClient(options)

Creates a new instance of a GrinClient.

options

options.protocol

Either http or https
Type: string

options.hostname

Type: string

options.host

Type: string

options.port

Type: number

options.username

Type: string

options.password

The Grin node's .api_secret. Can be found in ~/.grin/main/.api_secret.
Type: string

Instance methods

grin.blocks(id)

id: <string> can be hash, height or commit.

grin.headers(id)

id: <string> can be hash, height or commit.

grin.chain()

grin.chainValidate()

grin.chainOutputsByIds(ids)

ids: <string[]>

grin.chainOutputsByHeight(obj)

obj: <Object>
obj.startHeight: <integer>
obj.endHeight: <integer>

grin.status()

grin.txhashsetRoots()

grin.txhashsetLastOutputs(n)

n: <integer>

grin.txhashsetLastRangeProofs(n)

n: <integer>

grin.txhashsetLastKernels(n)

n: <integer>

grin.txhashsetOutputs(n)

obj: <Object>
obj.startIndex: <integer>
obj.max: <integer>

grin.txhashsetMerkleProof(n)

id: <string>

grin.pool(n)

id: <string>

grin.peersBan(addr)

addr: <string>

grin.peersUnban(addr)

addr: <string>

grin.peersAll()

grin.peersConnected()

grin.peers(addr)

addr: <string>

Related

grin-ql-js
mimblewimble/grin REST API

License

MIT

grin-client-js's People

Contributors

nijynot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lokialice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.