npm.io
1.0.5 • Published 9 years ago

scalechain-nodejs

Licence
Version
1.0.5
Deps
2
Vulns
2
Weekly
0

The ScaleChain API for Node.js

The official Node.js library for the ScaleChain API.

Installation

npm install scalechain-nodejs

Quick Start

Sign Up

The first thing you'll need to do is sign up for ScaleChain Cloud.

Get API Key

Go to Manage API and click 'Add New API Key'.

Get an Access Token
// Import ScaleChain SDK
var ScaleChain = require('scalechain-nodejs');

var apiKey = "API-KEY";
var apiSecret = "API-SECRET";

var config = ScaleChain.configuration;
var auth = ScaleChain.AuthorizationController;

auth.getAccessTokenByClientCredential(apiKey, apiSecret, function(err, res, req) {
  config.oAuthAccessToken = res.access_token;
  config.oAuthRefreshToken = res.refresh_token;
});

Making API Calls

var block = ScaleChain.BlockController;

block.getBlock('latest', 'mainnet', function(err, res, req) {
  console.log(res);
});

Switching to Testnet Blockchain

var block = ScaleChain.BlockController;

block.getBlock('latest', 'testnet', function(err, res, req) {
  console.log(res);
});

API Reference

Visit docs.scalechain.io.