BLOCd API

Daemon to synchronise the blockchain

BLOCd daemon provides a JSON-RPC interface, 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.

BLOC JSON RPC API

BLOC E-Commerce and automated services solution

The cryptocurrency BLOC has unfolded and advanced a set of key methods to portray universal and integrated access to act as an alternative or replace the current banking system in regards to the expensive and restricted POS contactless terminals. BLOC is providing an open platform that enables companies to build their own products using the BLOC API. Enter the URL of the API where to connect to. Make sure you enter it exactly like on the exemple, then enter the RPC password. Test the implementation in your application using the form and exemple provided below.


Example: http://0.0.0.0:2093/json_rpc



{API}
BLOC-DAEMON

BLOCd JASON RPC API

Use the form below to test the integration of the BLOCd API into your application. Make sure you have filled the connexion details at the top of this page.

BLOC integration process differes from other cryptocurrencies. Firstly, the coin has three separate binaries:


  • BLOCd — to synchronize with the block chain and mine BLOC coins.
  • simplewallet — to operate the funds and accept deposits using one address
  • Walletd — to operate the funds and accept deposits using multiple addresses

This section describes BLOCd daemon integration process into your service with BLOC e-commerce solution. BLOCd daemon synchronise the blockchain and provides a JSON-RPC interface, 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


BLOC reference client overview & integration guide with BLOCd

Setup and configuration with the BLOCd daemon

To start integration process you should first download BLOCd daemon, you can find it here: https://bloc.money/download

You may also build BLOCd from source code: https://github.com/furiousteam/BLOC


Install BLOCd

  1. Unzip the archive BLOCd to one separate folder
  2. Launch BLOCd to download the blockchain and start the synchronization
  3. Wait until BLOCd is synchronized. You will be notified with several green "SYNCHRONIZED OK" messages.

C:\Users\%user_name%\AppData\Roaming\bloc\ (Windows) 
./BLOCd (MacOS/Linux) 

BLOCd daemon configuration file

BLOCd can accept settings through a configuration file. This is the output of daemon help command on acceptable parameters:


Command line option Description
--help Produce help message
--version Output version information
--os-version Specify data directory
--data-dir arg use custom folder for blockchain datas
--config-file arg(=bloc.conf) Specify configuration file

Command line options and settings option


  • Almost all of the command line options can be defined through the configuration file.
  • If a parameter is defined in the config and was also indicated in the command line, two behaviors are possible. If the parameter accepts one value only (e.g., rpc-bind-ip), the command line value will be used, since it has a higher priority. If the parameter accepts several values (e.g., add-priority-node), then command line and configuration file values will be merged.
  • By default config file's name is "bloc.conf", which is located in the binaries folder. However, you may adjust the destination to the file via "--config-file" option in the command line.

If some of the options are not defined in the config, the default values will be applied. Here's the example of a possible configuration file:


Option Description Config Example Console Example
--log-file arg   log-file= --log-file=
--log-level   log-level=2 --log-level=2
--no-console Disable daemon console commands no-console=yes --no-console
--testnet Used to deploy test nets. Checkpoints and hardcoded seeds are ignored, network id is changed. Use it with --data-dir flag. The wallet must be launched with --testnet flag testnet=yes --testnet
--rpc-bind-ip arg   rpc-bind-ip=127.0.0.1 --rpc-bind-ip=127.0.0.1
--rpc-bind-port arg   rpc-bind-port=2086 --rpc-bind-port=2086
--p2p-bind-ip arg Interface for p2p network protocol p2p-bind-ip=0.0.0.0 --p2p-bind-ip=0.0.0.0
--p2p-bind-port arg Port for p2p network protocol p2p-bind-port=2082 --p2p-bind-port=2082
--p2p-external-port arg External port for p2p network protocol. (if port forwarding used with NAT) --allow-local-ip --p2p-external-port=0
--allow-local-ip Allow local ip add to peer list, mostly in debug purposes allow-local-ip=yes --allow-local-ip
--add-peer arg Manually add peer to local peerlist add-peer=ip --add-peer=ip
--add-priority-node arg Specify list of peers to connect to and attempt to keep the connection open add-priority-node=ip --add-priority-node=ip
--add-exclusive-node arg

Specify list of peers to connect to only. If this option is given the options add-priority-node and seed-node are ignored

add-exclusive-node=ip --add-exclusive-node=ip
--seed-node arg Connect to a node to retrieve peer addresses, and disconnect seed-node=ip --seed-node=ip
--hide-my-port Do not announce yourself as peerlist candidate hide-my-port=yes --hide-my-port
--db-threads arg Nuber of background threads used for compaction and flush db-threads=2 --db-threads=2
--db-max-open-files arg Number of open files that can be used by the DB db-max-open-files=100 --db-max-open-files=100
--db-write-buffer-size arg Size of data base write buffer in megabytes db-write-buffer-size=256 --db-write-buffer-size=256
--db-read-cache-size arg Size of data base read cache in megabytes db-read-cache-size=10 --db-read-cache-size=10

Example of bloc.conf (configuration file)


log-level=4
no-console=yes
rpc-bind-ip=0.0.0.0
rpc-bind-port=8081
p2p-bind-ip=0.0.0.0 
p2p-bind-port=8080
p2p-external-port=9000
hide-my-port=yes


{API}
BLOC-DAEMON

BLOCd JASON RPC API

Use the form below to test the integration of the BLOCd API into your application. Make sure you have filled the connexion details at the top of this page.

This section describes BLOCd integration process into your service. BLOCd RPC is a HTTP server which provides JSON 2.0 RPC interface for BLOC blockchain operations. To start Daemon JSON RPC API server you should specify an ip which server binds (local or to be accessible from other computers) (additionally a different port than the default one 2053). You can choose any free port. To do that execute the following command from the command line:


./BLOCd --rpc-bind-ip 0.0.0.0

Having done that you are ready to operate with the daemon through the following API URLs (e.g., your IP address is 127.0.0.1):


http://127.0.0.1:2053/json_rpc
http://localhost:2053/json_rpc

 

On this page you will find description of every method in BLOCd JASON RPC API. Each method has its own exemple that can be found by clicking on this method. To make a JSON PRC request to your BLOC RPC Wallet you should use POST request that looks like this: 


http://<service address>:<service port>/json_rpc 

where:


  • <service address> is an IP of BLOCd RPC server, if BLOCd is located on local machine it is either 127.0.0.1 or localhost,
  • <service port> is BLOCd RPC server port, by default it is binded to 2086 port, but it can be manually binded to any port you want, scroll up on this page for more details.



Implementation Notes

f_block_json() - Returns block details by given block hash


Input Parameters

Argument Mandatory Description Format Example
hash yes a block hash string


Implementation Notes

f_blocks_list_json() - Returns last 30 blocks info by given block height


Input Parameters

Argument Mandatory Description Format Example
height yes a block height uint64 2063


Implementation Notes

f_on_transactions_pool_json() - Returns a list of pool transactions waiting to be included in a block


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

f_transaction_json() - Returns transaction details by given hash. (Confirmed transactions only)


Input Parameters

Argument Mandatory Description Format Example
hash yes Transaction hash (confirmed only) string


Implementation Notes

getblockcount() - Returns current blockchain height


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

getblockheaderbyhash() - Returns last block header by given block hash


Input Parameters

Argument Mandatory Description Format Example
hash yes block hash string 7f0f9728d7a808cabec53af09454d12343eeaadfceecc39e0eb6e0d650f0db22


Implementation Notes

getblockheaderbyheight() - Returns block header by given block height


Input Parameters

Argument Mandatory Description Format Example
height yes block height uint64 2063


Implementation Notes

getblocktemplate() - Returns blocktemplate with an empty "hole" for nonce


Input Parameters

Argument Mandatory Description Format Example
wallet_address yes an BLOC address string abLoc99iQ78aaoxJtQJYewP7q6wg2VCg18D4Fx6dRy2qE9FqFhdrYCYXA9DRYsZpeFTVhQYXTmugL78ww6hCq4pzQeuL3VkvgLC


Implementation Notes

getcurrencyid() - Returns unique currency identifier


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

getinfo() - Retrieves the general information about the BLOC node


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

getlastblockheader() - Returns last block header


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

gettotalcoins() - Retrieves the total number of already generated BLOC coins


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters


Implementation Notes

gettransactions() - Retrieves missed_tx and txs_as_hex as an array


Input Parameters

Argument Mandatory Description Format Example
txs_hashes no an array with tx hashes array


Implementation Notes

on_getblockhash() - Returns block hash by its height


Input Parameters

Argument Mandatory Description Format Example
height yes a block height array [1]


Implementation Notes

sendrawtransaction() - Submit a raw transaction


Input Parameters

Argument Mandatory Description Format Example
tx_as_hex yes the tx as hex format string


Implementation Notes

stop_daemon() - Stops the BLOCd daemon. THIS METHOD HAS NO EXAMPLE FOR AN OBVIOUS REASON!


Input Parameters

Argument Mandatory Description Format Example
it requires no extra parameters

Implementation Notes

submitblock() - Submits mined block


Input Parameters

Argument Mandatory Description Format Example
blob yes blob data as numeric key zero array [4563453455342542353245]


Implementation Notes

autoOptimize() - Optimize Wallet ?


Input Parameters

Argument Mandatory Description Format Example