How to Publish/Retrieve data records in RecordsKeeper Blockchain?

RecordsKeeper offers a solution where you can publish your data in key-value based pairs over the RecordsKeeper Blockchain and then retrieve it using the key. In this post, we will show you how to use curl commands in the shell to publish and retrieve data records from the streams in RecordsKeeper Blockchain.

Before we start you need to set up your own node by following this documentation: https://docs.recordskeeper.co/en/latest/gettingstarted.html

You also need the proper authorization for your node. You have to provide Base64 conversion of node’s Username and Password, which you can access through RK.conf built in your RecordsKeeper directory. Check below to get the Username and Password for your node and then convert them into Basic Authorization in Base64 using any tool.

Linux (Ubuntu):
From your terminal run following commands:

cd ~/.rk/recordskeeper/
cat rk.conf

It will open the configuration file from where you can copy rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Windows:
Go to the directory:
AppData > Roaming > Rk > RecordsKeeper

Then look for the rk.conf file and open it in any text editor. It will display rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Let’s start with How to publish your data in a stream:
RecordsKeeper offers a solution where you can publish your data in key-value based pairs over the RecordsKeeper Blockchain and then retrieve it using the key. In this post, we will show you how to use curl commands in the shell to publish and retrieve data records from the streams in RecordsKeeper Blockchain.

Before we start you need to set up your own node by following this documentation: https://docs.recordskeeper.co/en/latest/gettingstarted.html

You also need the proper authorization for your node. You have to provide Base64 conversion of node’s Username and Password, which you can access through rk.conf built in your RecordsKeeper directory. Check below to get the Username and Password for your node and then convert them into Basic Authorization in Base64 using any tool.

Linux (Ubuntu):
From your terminal run following commands:

cd ~/.rk/recordskeeper/
cat rk.conf

It will open the configuration file from where you can copy rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Windows:
Go to the directory:
AppData > Roaming > Rk > RecordsKeeper

Then look for the rk.conf file and open it in any text text editor. It will display rpcuser and rpcpassword of your node. Convert this username and password to Base64.

Let’s start with How to publish your data in a stream:

Publish

You can use the publish command which is provided as JSON RPC API to publish the data over the RecordsKeeper Blockchain

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”publish”,”params”:[“root”, “testkey1”, “787676”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

 

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the transaction id which can be see through RecordsKeeper Blockchain explorer. Here we are showing you the example to publish to the RecordsKeeper Testnet, you can also use the same steps to publish over the RecordsKeeper Mainnet.

Retrieve

Get Stream Item

You can use this command to get the exact stream item from the RecordsKeeper Blockchain. You need to pass the stream name and transaction id as the parameters.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”getstreamitem”,”params”:[“root”, “43878d92e64077d300e70d6e7e99914a8b4732b513ce0f35fbb26fe4a7a5b37e”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the exact details about the stream item published over the RecordsKeeper Blockchain

List Stream Key Items

You can use this command to list the value against the key stored in the stream over the RecordsKepper Blockchain. You need to pass the stream name and the key for the data as the parameters.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

 -d ‘{“method”:”liststreamkeyitems”,”params”:[“root”, “testkey1″],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the data corresponding to the key stored in the stream item published over the RecordsKeeper Blockchain.

List Stream Items

This command is used to list all the stream items inside a single stream. By passing the stream name you can get all the records stored inside the specific stream.

Example:

curl -X POST \  http://35.170.xxx.xx:83XX/ \

 -H ‘authorization: Basic cmtycGM6M1c0aHByUUx3c2h4Nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ \

 -H ‘cache-control: no-cache’ \

 -H ‘content-type: text/plain’ \

  -d ‘{“method”:”liststreamitems”,”params”:[“root”],”id”:”curltext”,”chain_name”:”recordskeeper-test”}’

You have to provide your node’s ip address with port and your node’s basic authorization in the curl command. This command will return you the JSON object with all the records inside a single stream.

Curl commands are very effective to make JSON RPC calls, you can also use any programming language to create a request for the RecordsKeeper Blockchain. If you are not familiar with Curl then you can directly see the stream details and stream items through the RecordsKeeper Blockchain Explorer (https://www.recordskeeper.co/blog/use-recordskeeper-blockchain-explorer/)

How to use RecordsKeeper Blockchain Explorer?

RecordsKeeper Blockchain Explorer provides you the details about what is happening inside the RecordsKeeper Blockchain.RecordsKeeper Blockchain explorer shows the latest blocks in the blockchain. Let’s take an example if a new block is discovered by miners and transactions are either in the memory pool or confirmed in the block, then the RecordsKeeper Blockchain explorer will show you the live details about the block and when the transactions are in memory pool or confirmed in the block. You can also view the specific details about the block by clicking on it. Clicking on a specific network block will provide you with more information regarding its size, fees, when it was found in the Blockchain, and more importantly, which all transactions it contains. It also provides the details like the hash of every block which is linked to the previous network blocks, all of which have a unique hash and a unique set of transactions.

The RecordsKeeper has access to 2 types of Blockchain explorer:

  1. RecordsKeeper Mainnet Blockchain Explorer (https://explorer.recordskeeper.co/)
  2. RecordsKeeper Testnet Blockchain Explorer (https://test-explorer.recordskeeper.co/)

RecordsKeeper Blockchain Explorer Home

At the homepage of the explorer you can view the following details:

  • Status of the Blockchain – This shows whether the Blockchain is running or not.
  • Blockchain Name – In our case the public Blockchain available is named RecordsKeeper.
  • Total number of Blocks confirmed in RecordsKeeper – These are the total number of Blocks found in the RecordsKeeper Blockchain.
  • The total number of transactions in RecordsKeeper – These are the total transactions in the RecordsKeeper Blockchain.
  • The total number of addresses in RecordsKeeper – These are the total number of addresses recognized in the RecordsKeeper Blockchain.
  • The total number of streams in RecordsKeeper – These are like the data objects in the RecordsKeeper on which you can store your key-value based data. The “root” stream in RecordsKeeper is open to everyone.
  • The total number of peer – This is the total number of nodes connected to the RecordsKeeper Blockchain.

After the information described above it shows the latest transactions inside the RecordsKeeper Blockchain, where you can click on the transaction id in the table to direct you to the specific transaction page. The transaction table also shows you the type of transaction (Metadata, stream etc.), transaction status (total number of confirmations for the transaction or whether it is in memory pool) and the time when the transaction was made in the RecordsKeeper Blockchain.

RecordsKeeper Blockchain Summary

You can view the RecordsKeeper Blockchain information by clicking on the chain name in the homepage. It will show the summary and the general information about the RecordsKeeper Blockchain. You can view different parameters like the difficulty of the RecordsKeeper Blockchain, version of the RecordsKeeper Blockchain and the protocol being used for the RecordsKeeper Blockchain. You will see the information page as shown below:

RecordsKeeper Blockchain Blocks Information

You can also view the blocks in the RecordsKepper Blockchain by clicking on the block numbers at the homepage of the explorer. The following page will be displayed to you:

Here you can see the basic Block details like the recent block numbers. A miner who confirmed the block, the time of confirmation and the number of transactions inside the block. You can click on the individual Block number to view the details about the specific block:

At the Block Summary page, you can see the hash of the block and how it is linked with the previous and the next block, you will also see the number of transactions and the transaction fees utilized in the block. Clicking on the Transaction link will take you to the transaction detail page.

RecordsKeeper Blockchain Streams

You can also view the streams in the RecordsKepper Blockchain by clicking on the stream numbers at the homepage of the explorer. The following page will be displayed to you:

Here you can see the stream names with the corresponding total number of items in the stream. You can also see the permissions for the respective stream. Clicking on the stream name will take you to the stream summary page:

Stream summary page gives you the detailed information about the stream, here you can also see the latest stream items published in the stream and all the publishers for the stream.

The details about the stream items can be accessed from the stream homepage by clicking on the total steam item number. The following page will be displayed:

The time is displayed in UTC and gives you the time when the item was published, you can also see the key and corresponding data to the key. The entries are displayed as the latest entry first for the stream items. On click of the specific stream item, you can view all the entries for the corresponding stream item.

As you can see in the image above the entry key has multiple data entries, which are displayed here. You can view the time of publish for the entry, data recorded, size of data and the corresponding publisher for the stream item.

RecordsKeeper Blockchain Transactions

RecordsKeeper Blockchain Explorer provides the transactions as hyperlinks on all the pages, you can click on the specific transaction id to check the details about the specific transaction. You can also click on the transaction link on the homepage to view the transaction details:

Transaction details give you all the data needed to see how the transaction got executed over the RecordsKeeper Blockchain. Following data can be seen on the transaction details page:

  • Hash of the transaction
  • Block in which transaction appeared
  • Number of inputs for the transaction
  • Number of outputs for the transaction
  • Size of the transaction
  • Input points and the Script signature for the transaction.
  • Output points and the verification Script for the transaction.

 

RecordsKeeper Blockchain Addresses

You can click on any of the addresses on the explorer to view the total balance and the permissions of the address:

RecordsKeeper Blockchain Addresses

RecordsKeeper provides the functionality of search on every page for the users to search by address, block number, hash, transaction or chain name. By providing with the correct input, you can directly see the corresponding page for the entity.

Please Note: All the entities used in this blog are present for the only demo, please do not make use of them in your applications.

How to request for XRK Mining Permission for RecordsKeeper Blockchain?

This blog will help you to get the required permissions to start mining the XRK tokens at your local node. The mining permissions for both RecordsKeeper Testnet and RecordsKeeper Mainnet is explained below:

RecordsKeeper Testnet

The mining for RecordsKeeper Testnet is open for everyone so when you connect to RecordsKeeper Testnet, you will receive all the permissions for your default address.

RecordsKeeper Mainnet

For Mainnet when your node gets connected, you will receive the permissions to connect, send and receive. To get the permissions to mine at you node follow the steps mentioned below:

Step 1: Look for your default XRK address from the command given below, which will display your node’s wallet address. This address is your “default XRK address” or “public address” of the Recordskeeper Blockchain in which you will receive XRK coins. To check the address, run the following command:

rk-cli recordskeeper getaddresses
./rk-cli recordskeeper getaddresses                        #(for Mac Users)

Step 2: Copy this address and open up the following link in a new window to receive Mining Permissions for RecordsKeeper Mainnet.

https://docs.google.com/forms/d/e/1FAIpQLSd1Dd2GAggCyom23HgiBhnQIjlLjMgRwf_UOQrHp9BUTRPEYA/viewform

You will see the following form:

Step 3: In the form provide us the details with following:

  • Email address
  • Name
  • Miner Code Name (This will be displayed on http://miner.recordskeeper.co/)
  • XRK Address (The node address you copied in the last step)
  • Message (Additional comments for the RecordsKeeper Team)

Step 4: The RecordsKeeper team perform common due diligence before providing the permissions to you. It could take from 24-48 hours.

After RecordsKeeper team grant mining permissions to your node address, only after that you would be able to mine XRK coins into your default address.

Addition Steps and Information

You can retrieve your private key from the node. To retrieve private key for your node address run this command:

rk-cli recordskeeper dumpprivkey {default_XRK_address}        #(input node_address without braces)
./rk-cli recordskeeper dumpprivkey {default_XRK_address}        #(for Mac Users)

Note

Please store this private key safely, losing this will result in loss of XRK coins.

After completing the above process, you can check for your node’s information (best block and synced block) by running following commands:

rk-cli recordskeeper getinfo                 #(for synced block)
rk-cli recordskeeper getblockchaininfo       #(for best block)

./rk-cli recordskeeper getinfo                 #(for Mac Users)
./rk-cli recordskeeper getblockchaininfo       #(for Mac Users)

Your node will sync up to the best block, and then only your node can start mining and your balance will get updated with the mined XRK coins.

If you have already created a wallet address and you want to add it as your miner address then run this command from the command line terminal:

rk-cli recordskeeper importaddress {address}      #(include address without braces)
./rk-cli recordskeeper importaddress {address}      #(for Mac Users)
rk-cli recordskeeper importprivkey {private_key}      #(include private key without braces)
./rk-cli recordskeeper importprivkey {private_key}      #(for Mac Users)

Then you can follow the above steps to get the mining permissions for the imported address.

Data security on Recordskeeper

Documents or records stored on RecordKeeper are very safe due to Blockchain & Asymmetric Key Cryptography (aka Public-Key Cryptography). This pair (Blockchain & Asymmetric Key Cryptography) help us achieving the 4 major aspects of security with high confidence in lesser cost. While in traditional technology you have to invest a lot to achieve these below 4 aspects of security.:

Also, all 4 major aspects of security can be achieved in RecordsKeeper’s Blockchain

  • Confidentiality.
  • Integrity.
  • Availability.
  • Non-repudiation.

Blockchain: Since Blockchain is a decentralized ledger & store everything immutably, it is highly secured. In short, it means it is very very difficult as well as expensive to forge or modify a transaction and it is extremely easy to detect the inconsistency & forged data/transaction/stored information. So nobody can modify or forge the data stored in Blockchain. Hence Integrity, Availability & Non-repudiation can be achieved with Blockchain easily. But What if someone read my documents? The answer to this question is in Cryptography.

Asymmetric Key Cryptography: It is a method of locking digital documents using two different Keys. Everything you store in Blockchain is locked with your one key (Public-Key) hence It can only be unlocked using your another key which will be in your mind. Until unless you share your passphrase with the hacker, computationally it is impossible to hack/guess the keys & unlock your stored files.

This above set of technology makes your documents unchangeable, incorruptible, undeletable, and unreadable for anyone except you. Isn’t it cool?  🙂