Intro to Rell: Basics

Alex Zecevic
7 min readAug 1, 2021

Hello again readers! Thanks for swinging by and taking a look at my 2nd blog post! In this blog post we are going to be taking a deeper dive into Chromia which was the cool blockchain which featured that new Relational Blockchain technology that I briefly covered in my first blogpost. I am first going to go through the installation of the dev environment with you first so if you would like to try out Rell and Chromia for yourself you will have all you need to get started. Once I go through the install, I will give you guys a run down of some basics of the Rell language then finally I will show you guys a mini demonstration of a small application I made using Rell and JavaScript.

Dev Environment Setup

As I mentioned before the first thing, I am going to cover is the install of the dev environment. In the last blog post I mentioned that the dev environment is a little janky and you will notice that here. Currently on their website they have 2 ways to develop Rell applications. First way is through Eclipse using their custom Eclipse setup. When I was originally learning Rell I was trying to get this version of the dev environment running since it uses Eclipse which I am already familiar with, and it would give me an offline dev setup so that I can take it anywhere and I would not need internet to be able to code. However, this version, as of this blogpost, is currently not working properly and seems to not be giving me the correct launch options when it comes to running the application on locally. I am hoping this gets fixed in the future however like I said this project is very small with only a small number of developers working on it so don’t expect much for at least a few years. If you would like to try this version for yourself the link to their setup guide is linked here.

The 2nd version of their dev environment involves using a Web IDE. This was something new to me as I never used a Web IDE but the IDE isn’t too bad and the biggest plus is that you are actually running your Rell code on their TestNet, well at least early stages of their TestNet. For those who are unfamiliar with what a TestNet is it is basically a Blockchain that isn’t connected to anything that is there for the purposes of developing applications and testing out the blockchain before you go ahead and invest into actual coins for your applications. Another nice advantage of the Web IDE is all of the things required to get the backend started is already there for you so there is no setup in terms of backend stuff. The first video will walk you through the Web IDE while the 2nd video will show you how to install NodeJS which will be needed if you plan on making a front end client.

Link to the Web IDE here.

Link to NodeJS here.

Intro to Rell

Entities

Entities are probably the most important element in Rell. Without entities you have zero data models and no way to store data in an organized way. Entities are equivalent to tables in other Relational languages such as Oracle or MySQL. Below is a sample form my mini project of how an entity in Rell looks like.

Entity Sample

In Rell attributes that are meant to be unique are always marked with “key” keyword. Another important note, In Rell all attributes are immutable by default so every attribute you want to be mutable it would require the “mutable” keyword. One attribute you might be wondering about is the pubkey, pubkeys are important parts of entities and are used to help verify the data that is going into the blockchain and can also be used to help query for a specific block however these pubkeys are not required to be in an entity and are generally used for important entities such as accounts and users.

Operations and Queries

Now that we went through how to model data in Rell now I am going to show you how that data is manipulated in Rell. Rell has 2 types of requests one being an operation which is a function used to modify data and the other are queries which is a function used to retrieve data. First, I want to look at a couple relational operators which will be useful for the operations and queries.

Create Sample

The create operator is essentially your insert statement which can be found in out SQL languages. Account is the name of the entity object you are creating; this will be changed depending on the name of the entity you are creating. The arguments in the brackets match the attributes in the entity. A neat thing about the create operator is the fact that the placement of each argument doesn’t matter as Rell is smart enough to determine the connection between the arguments and entity attributes based on their types.

Data Retrieval Sample

This above sample is how you retrieve a single record. This is like a select statement with a where clause. If there are no records or more then one record exists an error will be thrown. The @ symbol which is used for a single record can be changed to a @* to retrieve a list of records. Account is the name of the entity being searched for and the .pubkey is the specific object you are looking for. The sample above is specifically retrieving the account balance using the .account_balance.

Update Sample

The update operator is used for updating an entity and yes you guessed it, it’s the same as update from other SQL languages! The update operator uses the same formatting as the select operator from above. Now that we got some of the basic operators out of the way I will show you how to use them in operations and queries.

Operation Sample

Ok so the above sample code shows you what a simple operation looks like in Rell. Like I mentioned before an operation is a function in a way but can only be used to manipulate data like creating and updating entity objects, Rell also has general functions that are similar to methods however those are specified with the function keyword instead of operator and the arguments follow the same format. But back to operations, the main use of an operation is to encapsulate the data modifying operators as well as allow for input checking/validation. In the above example we are requiring that before the create operator is called the input into the operation has a public key and the public key belongs to the user creating the account, this is to ensure that we aren’t making an account for someone else, and we are also requiring that the account number sits between 1 and 999999. Assuming the 3 requirements are met the create operator would be called and an account for the user would be created.

Query Sample

And finally, the last piece of Rell I am going to talk about is queries. Above is a sample of a very simple query that I used in my mini demo. Like I mentioned before queries are functions that are used to retrieve data. They work in the exact same way as operations however in my example I did not bother with any error checking first to show you what a operation/query looks like without any requirements and 2nd I was just too lazy. This concludes the basics of Rell that I want to show you, hopefully this section will help you better understand my mini demo which is coming up next!

Demo Simple Banking App

Below is my video of the little app that I built for this blog post. Its basically a very simple banking app that uses Rell for the back end and a simple JavaScript front end that just initializes a couple account and sends/gets money transfers between the accounts. I will mainly be focusing on the Rell aspect of the application as that is specific to Chromia, I will just be going over the parts of JavaScript that is required for the communication between the front end and the back end.

Alright! That will wrap it up for my blog post! I hope you guys enjoyed and learned a little bit more about Rell and hopefully this will inspire you to take a look at Rell and Chromia for yourself. In the future I hope to continue playing around with Rell and Chromia and I hope to create bigger applications with it then the one I made for the demo. I may even continue making a few more blog posts in the future with more of my findings on the Chromia project.

References

--

--