Skip to content

BLOCd Daemon HTTP RPC API

BLOCd daemon provides a HTTP RPC API, used to receive informations from the blockchain allowing it to be controlled locally or remotely which makes it useful for integration with other software or in larger payment systems. Various commands are made available by the API described on this page.

BLOC-DEVELOPER

This page is only a short guide how to get you started with the BLOCd Daemon HTTP RPC API. Please visit the dedicated section on the BLOC-DEVELOPER website to view and test all the features available from the BLOCd Daemon HTTP RPC API.

Installing

Currently we support the following official client bindings:

npm install bloc-rpc
composer require github.com/furiousteam/BLOC-rpc-php
go get github.com/furiousteam/BLOC-rpc-go

Getting started

This section describes BLOCd Daemon integration process into your service with BLOCd HTTP RPC API. We also have available the BLOCd JSON RPC API if you need.

Make sure you have started BLOCd with the correct configuration to enable BLOCd JSON RPC API before using the following functions.

Interacting with the API

API endpoint example

http://localhost:2086

Configuration and Installation

const BLOCd = require('bloc-rpc').BLOCd

const daemon = new BLOCd({
  host: '0.0.0.0', // ip address or hostname of the BLOCd host
  port: 2086, // what port is the RPC server running on
  timeout: 2000, // request timeout
  ssl: false // whether we need to connect using SSL/TLS
})
<?php
use BLOC\BLOCd;

$config = [
    'rpcHost' => 'http://localhost',
    'rpcPort' => 2086,
];

$blocd = new BLOCd($config);
import (
  "fmt"
  trpc "github.com/furiousteam/BLOC-rpc-go"
)

rpcHost := "localhost"
rpcPort := 2086

daemon := trpc.BLOCd{
  URL: rpcHost,
  Port: rpcPort}

Example height

curl http://localhost:2086/height
daemon.getHeight().then((result) => {
  // do something
}).catch((error) => {
  // do something
})
response := daemon.Height()
fmt.Println(response)

Expected Output:

{
    "height":614214,
    "network_height":614218,
    "status":"OK"
}

height() returns the height of the daemon and the network

No Input.

Output

Argument Description Format
height Current daemon height int
network_height Current Network height int
status Status of request string

More

Make sure you check the complete features of BLOCd HTTP RPC API from the dedicated BLOC-DEVELOPER website.