How does Serenity smart contract work?

Serenity Financial
Serenity_project
Published in
2 min readJul 25, 2018

Recently we launched the Beta version of our Escrow system, which features the first edition of our Escrow smart-contract. You can view its source code on our GitHub.

In this post, I want to give an overview of how our smart-contract works.

First of all, the contract knows that when it accepts a transfer, and has enough SRNT tokens, it should immediately burn them. This process happens absolutely automatically. In case there’s not enough tokens on the contract, 1% of the transfer goes to Serenity’s wallet, and we buy and burn tokens ourselves.

But the main part of the smart-contract is the Escrow logic: the contract holds Ethereum addresses of the trader and their brokerage company. These addresses are saved in the smart-contract at the time of its deployment, and can’t be changed later, even by us. The main thing in the logic of the contract is that the funds can be transferred only to these two addresses. That means that even theoretically, no one else, not even Serenity, can get money from the contract, because it just can’t transfer it to anyone else.

How does the smart-contract know when it needs to transfer the money? It waits for two exactly matching transfer commands. These commands can be done only by brokerage, client or from Serenity’s wallet. Again, the wallet addresses can’t be changed after the contract’s deployment. The command is really simple: it specifies which amount from what is held on the smart-contract should go to the brokerage, and which to the client. When we see that the contract received a withdrawal command from one of the parties, we notify the second party about that.

For example, if there’s 10 ETH on the smart-contract, the client can issue a transfer command, requesting to transfer 9 ETH to themselves, and 1 ETH to the brokerage. But the transfer won’t be executed, until exactly the same command arrives either from brokerage or Serenity. This procedure ensures that each transfer decision is approved by at least two of the three parties: brokerage, client, and Serenity.

This simple and straightforward structure of the contract ensures that it’s secure and can be easily audited.

Vasily Alexeev, Serenity CTO

--

--

Serenity Financial
Serenity_project

The First Blockchain Escrow for Financial and Cryptocurrency Markets