Alexander Schlindwein's Blog

Alexander Schlindwein's Blog

Smart Contracts 101: An introduction to smart contracts on Ethereum

Smart Contracts 101: An introduction to smart contracts on Ethereum

Before we get started

This series of articles aims to introduce newcomers with basic knowledge in IT and programming to the world of smart contracts and to cover the various aspects related to the development of such. My goal is that by the end of this series you will have a broad knowledge about the most important topics and underlying technologies and that you will be able to develop and deploy your own secure and efficient contracts to the Ethereum blockchain.

What is a smart contract?

There are a lot of misconceptions about what a smart contract actually is. The confusion might originate from the fact that the term contract is included in the name given to this invention which leads people to believe that it is in some way related to legal contracts. That’s not the case however.

Simply put, a smart contract is a decentralized program which lives on the blockchain.

The term program is self-explantory — it’s a set of instructions which can be executed. But what does decentralized mean in this context? It means that all of the benefits which apply to payments on a decentralized blockchain — the five pillars of open blockchains — apply to the program as well: Open, public, borderless, neutral and censorship resistant.

But wait, not all contracts match these criteria!

At the time of writing this article one of the most used smart contracts on the Ethereum blockchain is the USDT (Tether) token contract which manages over 10 billion USD. Its token is supposed to represent the US Dollar on Ethereum. Here is an interesting excerpt from its source code:

function addBlackList (address _evilUser) public onlyOwner {
    isBlackListed[_evilUser] = true;
    AddedBlackList(_evilUser);
}

function destroyBlackFunds (address _blackListedUser) public onlyOwner {
    require(isBlackListed[_blackListedUser]);
    uint dirtyFunds = balanceOf(_blackListedUser);
    balances[_blackListedUser] = 0;
    _totalSupply -= dirtyFunds;
    DestroyedBlackFunds(_blackListedUser, dirtyFunds);
}

Don’t worry if you do not understand the syntax just yet, we will cover that later!

This contract supports two functions: addBlackList which adds an address to the blacklist and destroyBlackFunds which destroys all funds from a blacklisted address. onlyOwner means that these functions may only be executed by the admin.

The admin in this case refers to the Tether Treasury. It is the company behind the USDT token which handles the issuance and 1:1 backing of the USDT token in fiat currency.

So what about the five pillars now?

This is the point where we reach a very important distinction: the general concept of a smart contract and a specific smart contract’s implementation are two different things.

The USDT contract is still accesible to everybody. You can interact with it no matter your country of origin, age, ethnicity or credit score. You can view its source code, address and verify every single action it performs. Its history is etched into the Ethereum blockchain and it cannot be deleted.

However by interacting with a smart contract you oblige to follow the rules it sets with its code. There is no doubt that it is possible to create a highly centralized system on top of a decentralized one. The fact that USDT is one of the most used contracts shows that this thought has not reached the majority of users yet. Summary

This initial article in the series is supposed to give you an abstract understanding of the concepts behind a smart contract. In the following articles we will start to dive into the technical content by exploring the Ethereum Virtual Machine (EVM).

I am happy to receive feedback and suggestions for content you would like to see covered by the following posts. Feel free to reach out to me!

#ethereum#smart-contracts#blockchain
 
Share this