The ScaleChain API for Ruby
The official Ruby library for the ScaleChain API.
Installation
gem install scalechain
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
require 'scalechain'
key = "API-KEY"
secret = "API-SECRET"
auth = ScaleChain::AuthorizationController.new
config = ScaleChain::Configuration
response = auth.get_access_token_by_client_credential(key, secret)
config.o_auth_access_token = response["access_token"]
config.o_auth_refresh_token = response["refresh_token"]
Making API Calls
block = ScaleChain::BlockController.new
response = block.get_block("latest", "mainnet")
puts response
Switching to Testnet Blockchain
block = ScaleChain::BlockController.new
response = block.get_block("latest", "testnet")
puts response
Handling exception
block = ScaleChain::BlockController.new
begin
response = block.get_block("latest", "testnet")
puts response
rescue Exception => exception
puts exception.response_body
end
API Reference
Visit docs.scalechain.io.