Product development is never an easy task. There are always hurdles and challenges. In this article, we would like to share our experience building Security Tokens Issuance Platform on Waves blockchain. We hope that our ideas will help you in developing your solutions or in understanding why exactly our platform works the way it does.
Why We Built Our Platform on Waves Blockchain
Let’s start from the reason why we have chosen Waves blockchain. In Tokenomica, we believe that legal compliance and proper regulation play a leading role in the financial services market, thus any type of asset or business model which pretends to appear and stay in this market should fit the existing rules and common business practices.
Traditionally compliance functions in the securities market were assigned to different types of intermediaries because of their control over the assets at different stages of the security administration chain. With technological advancements brought by blockchain, some of those functions no longer require intermediaries – they can be fulfilled with the same level of compliance by the asset itself.
With this in mind, we analyzed current technological solutions to find the most customizable and cost-efficient options, which at the same time provided mass adoption opportunities.
Most of the platforms are built on Ethereum and at first glance, Ethereum appeared to be the obvious choice. However, the high cost of transactions (gas) and the complexity of creating fully customizable smart contracts requiring a significant level of experience for the developers, led us to search for an alternative, which resulted to be Waves Platform.
Waves covers every aspect needed for our platform:
- Compliance embedded in a technology – Smart Account and Smart Asset technology created by Waves was specifically designed to implement compliance related restrictions into digital assets in a fully customizable way.
- Easy adoption – Waves provides a wide range of tools for developers, including Waves Smart Contract Console (IDE) and a language specifically created to design Smart Assets (RIDE).
- No Gas and low transaction fees –There is no gas in Waves blockchain, while transaction fees are maintained at the lowest level compared with other platforms which provide for similar functionality.
So Waves was a perfect solution for us, however, during the development of our product we have faced some hurdles that were caused by the untypical architecture of Waves blockchain. Our team brainstormed the best ways to overcome them.
RIDE is not Turing complete
Though being non-Turing complete is a massive advantage of RIDE, there are several challenges. The most obvious one is figuring out how to solve cases where you need non-available operations.
RIDE language is not Turing complete, because it has no loops, recursion and go-to like expressions.
In our use case (issuing and distributing tokenized securities), after the tokensale is finished, a smart contract that acts as a dApp has to distribute assets or tokens among the investors. The number of investors participated in a campaign cannot be predicted before the start of a tokensale. The perfect scenario for token distribution, in this case, is by automatically sending tokens to each investor which is, in fact, is impossible without loops.
That is where callable functions help a lot. The model our team came up with is:
tokensale is over -> investor calls a “withdraw()” function of the dApp -> smart contract checks whether this investor has deposited money -> one transfer with the whole sum is made.
Some of the downsides of the scenario are:
- Investors need to sign the transaction to get their assets;
- Unclaimed assets may be forever held in the contract.
Solution: we will probably set an expiration period, after which the assets will be transferred to a nominated account by Tokenomica’s wallet.
Time as We Know it Doesn't Exist on the Blockchain
Let’s say in the real world I would like my tokensale to last until August, 20th. Blockchain works only with the data contained in the ledger and the dates are not part of this data. That means that blockchain does not know if today is July, 3rd or that August, 20th is a further date than July, 3rd.
There are two ways to solve the problem that we were able to figure out.
The first one is by posting the date every 24 hours in the hexadecimal format. Posting can be done by any nominated account. The price for maintaining the feature will be 365 * 0,001 Waves a year (number of days * cost of one data transaction), which is not that huge.
For now, we are using another way, which is to look at the number of the current block and predict (with 99% certainty) the number of the block in the future.
It is possible on Waves blockchain because average mining time on Waves mainnet is 1 minute. We can predict the number of blocks mined in 24 hours: current + 1440 (60 min*24h, or in a month: current + 1440*30. Of course, there is a risk that timing goes off, which happens a lot on testnet. Thankfully, mainnet is more stable and we are ready to take the risk for now. And this way is cheaper, especially if you need to work with minutes.
Creating Account and Scripting it are Two Different Operations
In order to comply with regulations, we have to be able to partially control user’s accounts. We do it by setting Tomenomica’s script on the user’s address. The script can always be checked using Waves Explorer. Find out how you can do it in this article.
Tokenomica’s script limits some operations (like leasing or mass transfer). That is why we require users to create a new account in order to operate on Tokenomica. Unfortunately, we can not help users create an account with an autoinstalled script. After creating the account a user needs to get Waves to pay the future fee for the SetScript transaction. Only after that, the script can be installed on a new Account.
These operations create additional barriers for our users. In order to break at least one, after the user completes KYC, we transfer the minimum amount to cover the fee for the SetScript transaction to the user’s wallet.
Blockchain Knows Your Balance Only at the Current State
Even though there are services that allow users to check balances in the past, blockchain does not have access to this data (problems 1 and 2 again: no loops to count & blockchain can only work with data inside of it).
There are cases when the dApp needs to use the distribution information on a concrete date: for example when you grant voting rights or when you want to distribute assets.
Solution that comes to mind is making a snapshot and posting the result on a blockchain. Unfortunately, a snapshot of an unknown number of investors can not be easily done by blockchain without loops. That means that even if you are storing snapshots on a blockchain, the results you store are not really gathered “in a decentralized manner”.
We are still figuring out the best way to replace the “snapshot idea”. Even mass-transfer of assets done in a centralized manner is cheaper and has pretty much the same level of transparency.
We also know that currently Waves team is working on a solution for the voting process and we plan to implement the feature in the future.
We hope our experience will help you with the development of your product on Waves blockchain. If not — feel free to contact us, we will be happy to give a helping hand!