In order to begin calling the Overline RPC Interface, make sure to run your miner using the --rpc and --scookie=testCookie123 flags. You need to replace testCookie123 with any string (must be unique). Save the following code in a file (say rpc.js) and execute any of the methods below by executing something like node rpc.js getBlockByHeight 20

// run these commands in the folder you intend to run the script in
// npm install --save node-fetch
// npm install --save btoa

'use strict';

const fetch = require('node-fetch');
const btoa = require('btoa');
const util = require('util')
const fs = require('fs')

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
if(process.argv.length < 3) return console.log('err - rpc method not provided')

let urls = [
  'http://localhost:3000/rpc',
]

let headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic ' + btoa(':testCookie123')
}

let body = JSON.stringify({
  jsonrpc: '2.0', id: 1234,
  method: process.argv[2],
  params: process.argv.slice(3,process.argv.length)
})

urls.forEach(url => {
  fetch(url, {method: 'post', headers, body}).then((response) => {
    response.json().then(function(data) {
      data.url = url;
      delete data.jsonrpc
      delete data.id
      console.log(util.inspect(data, false, null, true))
    }).catch((err)=>{
    })
  }).catch((err) => {
  })
})

📘

NOTE:

For RPC Calls Below, all BC_ADDRESS inputs must be in lowercase format.

Get Block By Height

This will return the Overline block at the specified height

node rpc.js getBlockHeight HEIGHT_NUMBER 

Get Block By Hash

This will return the Overline block with the specified header hash

node rpc.js getBlockHash HEADER_HASH

Get Blocks

This will return Overline blocks from the start height to the end height - inclusive.

node rpc.js getBlocks START_HEIGHT END_HEIGHT 

Get Latest Block

This will return the latest Overline block.

node rpc.js getLatestBlock

Get Rovered Block By Height

This will return the specified rovered block at the specified height

node rpc.js getRoveredBlockHeight BLOCKCHAIN BLOCK_HEIGHT_NUMBER

Get Rovered Block By Hash

This will return the specified rovered block with the specified header hash

node rpc.js getRoveredBlockHash BLOCKCHAIN HASH_OF_BLOCK

Get Rovered Blocks

This will return specified rovered blocks from the start height to the end height - inclusive.

node rpc.js getRoveredBlocks BLOCKCHAIN START_BLOCK_HEIGHT END_BLOCK_HEIGHT

Get Latest Rovered Blocks

This will return the latest rovered blocks of all chains

node rpc.js getLatestRoveredBlocks

New Transaction

This will send a transaction to the Overline network and be added to the mempool if the tx is correctly validated.

node rpc.js newTx FROM_BC_ADDRESS TO_BC_ADDRESS OL_AMOUNT TX_OL__FEE FROM_BC_ADDRESS_PRIVATE_KEY

Get Transaction

This will return the Overline transaction with the specified hash

node rpc.js getTx HASH

Get Raw Mempool

This will return the Overline txs currently waiting to be accepted in a BC Block.

node rpc.js getRawMempool

Get Marked Transaction

This will return the specified rovered transaction with the specified hash

node rpc.js getMarkedTx BLOCKCHAIN HASH_OF_TX

Get Balance

This will return the unconfirmed, confirmed, collateralized, and unlockable OL balances of the specified address.

node rpc.js getBalance BC_ADDRESS

Get Wallet

This will return the unconfirmed, spendable, collateralized, and unlockable outpoints for the specifieid addresses.

node rpc.js getWallet BC_ADDRESS

Get Unmatched Orders

This will return all the open orders that were never taken

node rpc.js getUnmatchedOrders BC_ADDRESS

Get Transfers

This will return the transfer history for the specified address.

node rpc.js getTransfers BC_ADDRESS

Get Spendable Outpoints

This will only return the spendable outpoints for the specifieid addresses.

node rpc.js getSpendableOutpoints BC_ADDRESS

Get Spendable Collateral

This will only return the unlockable outpoints for the specifieid addresses.

node rpc.js getSpendableCollateral BC_ADDRESS

Get Open Orders

This will return all open orders

node rpc.js getOpenOrders

Get Matched Orders

This will return all matched orders

node rpc.js getMatchedOrders

Get Sync Status

This will return the sync status of the node

node rpc.js getSyncStatus

Get Overline Supply

This will return the number of Overline mined so far

node rpc.js getNRGSupply

Get Current Work

This will return current or latest mined block's work

node rpc.js getCurrentWork

Get Settings

If you set BC_TUNNEL_HTTPS=true to set up an http tunnel via ngrok, this call returns you the address of the tunnel

node rpc.js getSettings