15.08.2021 Crypto Basics By George Gus

Smart contracts explained: Ethereum, Cardano, and EOS

smart contract definition explained

Smart contracts are binding and immutable digital agreements executed automatically when predefined terms are met. They are one of the most impressive tools and powerful features of the Ethereum project. 

Just like Bitcoin was the first cryptocurrency, Ethereum was the first crypto project to deploy the idea of smart contracts on its network. Other crypto projects followed suit, such as Cardano, EOSIO, and Tron. However, Ethereum smart contracts have been the gold standard in this arena so far. 

Features of smart contracts

We have previously learned that the Bitcoin blockchain is a public ledger or database that records and stores transactions and tracks balances. Once the transactions enter the block, no one can change them. Once the block reaches its size limit, another block is composed to store a new group of transactions. 

The Bitcoin network is powered by thousands of nodes or devices connected to each other. Every full node or device that runs the Bitcoin protocol receives a copy of the blockchain. The Bitcoin blockchain is a series of blocks of transactions chained together with an encryption mechanism, which provides a high level of security.

Hence, the Bitcoin blockchain is secure, immutable, and distributed, meaning it is not subject to hacking, tampering, or any central authority. For more information read: what is blockchain?

On the other hand, the Ethereum blockchain stores smart contracts, besides tracking, recording, and storing transactions. Since smart contracts live inside the blockchain, they are also secure, immutable, and distributed.

Therefore, no one can change the coded agreement once the smart contract is deployed on the Ethereum public network and stored inside the Ethereum blockchain. This also means that no central authority controls the contracts. Other features of smart contracts include anonymity, self-verification, and self-execution.

However, smart contracts are not safe from hackers if not coded with caution. Attackers can take advantage of vulnerabilities in the code, and hence steal funds. 

What are smart contracts?

Smart contracts are a set of digitally coded promises. They self verify and execute automatically with predefined terms and without needing an intermediary.

Understanding regular contracts help to understand smart contracts. Both serve the same end goal: to enforce an agreement between two or more parties. Regular contracts are usually mediated and written by a lawyer. They are legally binding and enforced by the law.

Smart contracts, on the other hand, are written or coded by developers. Developers use a programming language, such as Solidity, to write such contracts.

When the smart contract gets deployed, a special software converts the contract language to bytecode. The contract is then stored in the blockchain until it selves-executes as intended and expected. 

Therefore, in a smart contract, the code is the law that governs and enforces the rules automatically once the terms and conditions are met. 

You don’t have to be a developer to deploy a smart contract. Ethereum provides many tools for developers to create smart contracts in the form of decentralized applications (DApps).

The Ethereum project has become a popular platform for developers and a marketplace for users. The developer creates the DApps, and the user uses them to deploy their smart contracts with relative ease and a friendly interface. 

While smart contracts are associated with the Ethereum blockchain, rival blockchains, such as Cardno and EOSIO, also use smart contract functionality. 

Besides creating decentralized applications (DApps), smart contracts can create tokens and decentralized autonomous organizations (DAOs). Let’s first explore DApps. 

Decentralized applications powered by smart contracts 

Let’s take a real-world example of a smart contract and the corresponding decentralized app that makes it easy for the average user to deploy it. 

Let’s say you want to engage in a 100-dollar bet with a stranger called Alex on the next soccer game between Real Madrid and Barcelona. You bet on Barcelona winning the game. You both agree to the terms and condition of the bet, as follow:

  • If Barcelona wins over real Madrid, then Alex must pay me 100$. 
  • If Barcelona loses against real Madrid, then I must pay 100$ to Alex.
  • If the result is tied, then neither pay. 

You can write these terms in a handwritten contract, but you run into the risk of Alex not paying you if you win the bet. Then you may decide to take him to court, and who would do that for 100$? 

You could both agree to deposit the amount of the bet at a third party. The third party dispenses the amount as specified in the contract. But you must trust the third party not to run away with the money. Plus, you have to expose your identity and personal information to a third party. 

After weighing the risks and the rewards of using a traditional contract, you decide to use a smart contract and deploy it on the Ethereum or EOSIO blockchain. This way, you are sure that no one can escape from the terms and conditions you and Alex agreed to. 

You can program these terms and conditions in a smart contract or use a decentralized application, such as Sportbet.one that operates on the EOSIO blockchain, a rival to the Ethereum blockchain.

This way, you can place your bet with a stranger without needing to know his identity and without him knowing yours. The app matches your bet with someone willing to play. The smart contract is the trusted middleman that will ensure that each party plays by the rules. The rules are predetermined and automatically executed once there is a winner.

Instead of using fiat currency such as the dollar, you place your bet in the token or cryptocurrency that the app accepts. So you choose an amount in tokens equivalent to 100$ or any other amount of your choice. This transaction creates a smart contract behind the scenes and locks in the funds of both parties within the smart contract. The smart contract then gets stored in the EOSIO Blockchain.

The contract self executes as soon as the game is over. If Barcelona loses, the funds go directly to your friend’s crypto wallet or account, and if Real Madrid wins, the funds go to yours. 

There is no human intervention in this process. But how does the smart contract know the future? How does it know that Barcelona has won the game? Smart contracts use oracles. Think of oracles as live news feeds. They communicate with the blockchain to give up-to-date real-world information. 

Uniswap is another decentralized app that operates using smart contracts. It is a decentralized crypto exchange application that instantly matches buyers and sellers of cryptocurrencies automatically. Your crypto wallet connects you with the app and the blockchain. You choose the cryptocurrencies you want to swap or trade and then specify the amount and hit deploy. 

How could Uniswap instantly match every trade? Uniswap achieves this through liquidity pools and automotive market makers, concepts we will explain in another article. 

Smart contracts have paved the way for creating many other decentralized financial applications (DeFi) in areas such as Lending, borrowing, commodities, and more.

Other decentralized applications focus on areas, such as gaming, collectibles and crowdfunding, and even supply chain management. With smart contracts, the sky is the limit. 

Decentralized Autonomous Organization 

Decentralized autonomous organizations (DAOs) are made possible by using advanced smart contracts. A virtual entity can be created and run without a central authority. 

A DAO is a virtual democratic institution or organization run by predefined and agreed-upon rules. The contract specifies the protocol or rules that govern the organization and its members. 

The DAO could represent a charity, company, or investment fund. The main purpose of DAO is to democratize organizations and companies by voting on major decisions by its members or stakeholders. 

Some DAOs are private, and others are public. A public DAO could invite anyone to become a member. Each member deposits money, and in exchange, they obtain tokens that represent ownership of the DAO.

The members’ voting power could depend on the percentage of ownership. This is all predefined in the smart contract, which governs and enforces the rules automatically. 

Token creation 

With smart contracts, anyone can issue their tokens using an existing blockchain like Ethereum. If you want to run a crypto project or company, you can use the Ethereum blockchain to create and store your tokens.

The smart contract holds your tokens and governs their distribution according to predefined rules. The general public or the user can buy those tokens and own a stake in your project or company.

The main difference between tokens and cryptocurrencies is that tokens are run on an existing blockchain while a cryptocurrency runs on its own blockchain like Bitcoin. Yet, some cryptocurrencies produce tokens that are run on their rival’s blockchain.

It is worth noting that Ethereum is not a cryptocurrency. It is a platform for decentralized application, and it uses its native currency Ether to transfer value: send and receive digital money (Ether) and settle payments, just like Bitcoin. 

Ethereum is the most popular platform for creating tokens via the smart contract ERC 20. As long as you adhere to the token rules of the platform, you can launch any token you like on Ethereum.

Join our free newsletter for daily crypto updates!