Hive application development guide

Hi Everyone ❗❗

Especially HiveFest 2024 visitors who are interested in simplified and efficient application development for Hive Platform.

During many talks with you we promised to provide you with some tips how to start designing your application architecture to match all the tools currently available on the Hive Development stack.

In our vision of the current stack, at an application high level design, we have a few cases which determine used technologies, tools and required resources. Such use of the cases is ideally matching a:


H like a History: your workload requires you to analyze blockchain operations from the past.
To do it you will probably need a local instance of HAF node holding all blockchain operations or just part of it due to filtering capabilities supported by HAF.
Next sections will bring you some details related to HAF configuration details..
Alternatively - your application can refer to some API results taken from a remote endpoint. In this case, you can use a new set of REST API providing results specific to account history, regular block contents. You can find such APIs at: https://api.syncad.com . There is also available swagger documentation describing specific API calls.

IV.png
I V like a Initiate a Venture ( a little word game 😀 ) to perform a blockchain activity by pushing new operations to it.
If your application doesn't really care about the past and only wants to use a Hive platform as a secure transport layer, you can easily create the app just by using a BeeKeeper and Wax libraries to prepare, sign and broadcast transactions.
Below we are also presenting in greater detail an example application being able to
push own operations to the blockchain.
E.png E like Event consuming 😀 In Hive Platform can be also a lightweight and simple process.

The idea behind it is to make the process of catching blockchain data natural and easy to understand for regular programmers. To do it, we prepared another frontend library: WorkerBee, which allows you to write your own bots. The third part of this article will show you an example that is very easy to understand without any specific knowledge of blockchain.

Using HAF instance to process blockchain data


haf.png

Local HAF-node will allow the direct use of a SQL database holding relational representation of blockchain operations, divided into blocks and transactions.This solution gives you best ability for massive data processing (since you have direct access to them in local database), but it also brings the biggest resource needs - full deployment can even need 4TB of disk space.

Beside HAF-node, you will also need your backend application - SQL based - which will be continuously processing the operations incoming into HAF database and collecting data specific to your application schema.
During this process the whole interaction to blockchain is hidden by HAF - your task is just to program SQL data processing.

We will describe setup steps soon in a separate article (including example deployment of small HAF lab and some simple HAF application). The impatient ones please go to HAF deployment

Performing blockchain activity - broadcasting transactions


beekeeper_wax.png

Execution of operations on blockchain requires specific steps and a little knowledge of Hive blockchain technical side.
The first thing that you need to know is a set of operations supported by the Hive platform. You can find them in the Hive repository

It is also worth mentioning that you are not limited to the set of operations already included in the Hive Protocol. The Hive Protocol allows you to push operations being really unknown for blockchain itself, but being recognized by your application. To use this magic feature, you just should use a custom_json operation.

Finally, to send operations to the blockchain, they must be wrapped in a transaction and then signed using authority used to perform the operation. Transaction is an envelope holding multiple operations and account authority data, needed by blockchain processing algorithms.

To materialize this workload, you don't even need ANY backend services nor data storage: just the frontend part (using Beekeeper & Wax Typescript features) of your application could be sufficient to perform such activity. Wax hides all blockchain complexity and makes transaction creation process easy.
Beside web browsers, both libraries can be also used as a part of NodeJS deployments, so without touching other technologies than JavaScript, you can make fully functional applications, holding your own data and performing some server-side data processing.
Here is a link to TS example preparing some transaction: pushing a comment reply

Watching for blockchain events


workerbee.png

To make this process easy to understand for frontend programmers, we decided to use some well known libraries: events and RxJS to build observable model on. The WorkerBee library hides some blockchain specifics (i.e. a need to call some APIs) and allows you to focus only on processing events when:

  • some property of interested account will change
  • interesting transaction will be detected in blockchain
  • you can also be tied to each produced block

Here is an example application watching some Hive account and sending notifications to the Telegram bot (created separately). It is worth mentioning that the amount of code specific to Hive (actually calls to the WorkerBee library) is just a small part of this program: the rest is specific to Telegram protocol handling.

Event notifier talking to telegram

Thanks for reading and we are waiting for your feedback.

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center