Developing Smart Contracts – what does it mean, and how is it done?

By George Fironov ·Subscribe

There are a lot of convoluted articles online that fail to provide a short & sweet explanation to what blockchain and smart contracts are. Instead, authors often seem to think that they need to make this topic seem more complex than it is.

In this article, I want to give you an understanding of what smart contracts are, the current ways of building them, and also paint a vision of what this technology could do for us in the future.

Smart contracts have been around since 1998

The first example of smart contracts came from Nick Szabo, who created a virtual currency called Bit Gold in 1998. Ten years later, in 2008, the blockchain finally became visible to the world at large, thanks to Satoshi Nakamoto (whomever he may be), and his Bitcoin.

 

What is blockchain?

 

The blockchain is basically an equation. You can try solving the equation to “mine” bitcoins, but it requires insane computing power. Within the Bitcoin blockchain there is the whole history of every single Bitcoin transaction.

To be able to use Bitcoins, you must download the whole blockchain. When it comes to Bitcoin, at the moment of writing (November 2019) you need 200GB to store the whole blockchain on your computer. Once you have it, you can start making transactions. These transactions can be a:

  • simple fund exchange (I give you 200 Bitcoins, you receive them) 
  • smart contract (I give you 200 Bitcoins, you transfer rights to the apartment that you’re selling to me)

The biggest benefit of blockchain is that it’s a distributed ledger, and that’s where the security comes from.

 

What is a distributed ledger?

 

Surely you’ve heard the term “distributed ledger” before. A traditional ledger of transactions is a huge old book where somebody manually writes down a history of transactions. 

A standard digital ledger would be the same, but in the cyberworld. Like an Excel sheet.

In the realm of traditional ledgers, both sides of the transaction need to have their own book or excel sheet. Their ledgers are different, and the accuracy of information in them depends on the people that input that information. Information stored in traditional ledgers is easy to change and manipulate. It only takes a pen and a bit of counterfeiting skills, or access to the right Excel sheet.

Now, a distributed ledger is much harder to crack and manipulate. Remember — every user of the blockchain has to store the whole blockchain on their machine. (yes, there are light-weight blockchain wallets that don’t require downloading the whole thing, but they’re not important now, and blockchain enthusiasts generally don’t recommend them)

Because every user has the whole blockchain, the complete transaction history exists in as many copies as there are users. 

You can’t change past transaction data, and even if you try, the blockchain will verify this against other users’ copies. 

Back to the Excel sheet example, if the sheet was based on blockchain, you wouldn’t be able to just access it and change any data in it. If you tried to change a single cell, the blockchain would check it against all the other copies, and forbid you to do any changes.

You can’t lose your data, because even if some of it goes missing on your machine, it is stored on countless other machines.

(bear in mind that while the transaction data is secure, coins can still be stolen if you don’t manage them properly)

Because of all this, the blockchain, and smart contracts, could become the foundation for all important business operations and government services in the future. 

 

Development and implementation of smart contracts

 

Smart contracts aren’t documents, they are lines of code that set the conditions for the contract. 

Since they are still a novel technology, it’s easy to make faulty contracts with weak security. The technology is improving everyday, but hackers are also learning new tricks everyday. It will take a while until we reach an equilibrium state where smart contracts are both easy to develop and secure.

So far, there aren’t many platforms for developing smart contracts, and many of them are limited. The only truly open platform that enables high customization of contracts is Ethereum. 

There’s also RSK (Bitcoin-based), TRON, Stellar, EOS, and several smaller platforms.

At the moment, the risk with smart contracts is still pretty high. Ethereum specialists compare development of smart contracts to programming hardware or financial services. Meaning that once you commit or make a mistake, it’s very hard to go back and fix it.

Different platforms have different development environments, which means different programming languages and software development paradigms. We won’t be talking about those, since I’m not a programmer.

What I can provide is advice for what the mindset of a smart contract developer should be. It’s important to have a correct approach to smart contracts.

 

Preparing for failure is your #1 priority

 

Your contracts will fail and have errors in them, at this point in time it’s 100% certain. You need to tread carefully, and try to plan against any potential bugs that you know, as well as safeguard your contracts from the unknown.

The most important thing is to minimize the risk that comes with rolling out smart contracts. One good idea is a killswitch that will stop the contract from going through if there are any mistakes. 

Don’t think that you can build a quick MVP and test it in the real world in order to catch eventual bugs. This isn’t web development. Take your time building, and then deploy the contract slowly, preferably in several stages.

 

KISS

 

All start-up geeks know the KISS rule — Keep It Simple, Stupid! In the current technological environment, this is the only viable approach to developing smart contracts.

 

You need to know blockchain cold

 

It goes without saying that you need to know everything there is to know about blockchain, as well as your development platform of choice.

 

Reuse, don’t revolutionize

 

If you’ve already built a contract, and it works, then don’t be afraid to reuse it. Reuse as much of working, proven code as possible. Don’t try to reinvent the wheel, because there’s too much at stake.

 

Smart contracts might just change the world, but have patience

 

There are many foreseeable applications for smart contracts: voting, trading, protection and enforcement of content copyrights, and much, much more.

For now, smart contracts are still a novelty, and have a long way to go before they are as secure, and easy to use, as the theory promises.

Security — and not outstanding features or performance — should be the main concern of smart contract developers at the moment.

When the time comes that security of smart contracts is no longer a big issue, we might see a rapid explosion of different applications of this technology.

For now, developing and using smart contracts is still a bit like skating on thin ice. You might get to the pot of gold at the other side of the lake, but there’s a big chance that you’ll fall into the freezing-cold water, and someone will take your gold away before you can reach it.