The official Node.js library for the ScaleChain API.
npm install scalechain-nodejs
The first thing you'll need to do is sign up for ScaleChain Cloud.
Go to Manage API and click 'Add New API Key'.
// 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;
});
var block = ScaleChain.BlockController;
block.getBlock('latest', 'mainnet', function(err, res, req) {
console.log(res);
});
var block = ScaleChain.BlockController;
block.getBlock('latest', 'testnet', function(err, res, req) {
console.log(res);
});
Visit docs.scalechain.io.