Written by Emaad

On April 17, 2020

What is a smart contract?

What is a smart contract?

Smart contracts are computer programs that run on the blockchain. They are digital agreements encoded or written, with specific sets of rules that govern how and when the contracts will be signed, much like traditional contracts that are signed between two or more consenting parties.

The conditions of the fully customizable contracts are defined by how the code is written at the time the contract is created with a blockchain transaction; they cannot be changed after the fact. Smart contracts were first popularized with the creation of Ethereum Virtual Machine, or EVM.

How does a smart contract work?

Smart contracts are deterministic data structures. Deterministic algorithms and data structures will always return a particular output(s) for a particular input or given set of inputs, whereas non-deterministic structures have the potential to offer different outputs for the same set of inputs.

Due to the deterministic design, we know that smart contracts will execute with certainty when they are presented with given inputs. Contracts are written to execute processes as input requirements are met, regardless of who is executing them.

These processes are decentralized via the distributed computing system on which they run; this system is responsible for maintaining the global state of the ledger. In the case of the EVM, full nodes and PoW miners work together to update the state of the ledger as smart contracts continuously execute tasks based on the inputs they are receiving. 

What are the advantages of a smart contract?

Smart contracts deployed on EVM or other blockchains are distributed across the network of full nodes instead of executing on central servers. This decentralized architecture alleviates the risks associated with centralized services which include, but are not limited to, DDoS attacks, censorship, and server hacks in which data is lost or compromised. 

Decentralized computing platforms are also immutable by nature. Tampering with network consensus in order to alter outcomes by malicious actors is highly unlikely because the attacker must spend a lot of resources to attack the network- investing in enough mining hardware to mount a 51% attack in a PoW network, or buying up enough of the native asset in a PoS system to disrupt the voting-based consensus mechanism.

Well-written smart contracts inherit the same security properties as the secure, decentralized networks on which they are deployed. 

Another emergent property of secure decentralization is trustlessness. Two users interacting across the blockchain who do not know each other may still transact with confidence because the blockchain provides them with cryptographic assurance relating to identity or the validity of data. 

Use cases of smart contracts

Smart contracts are fully programmable and can be customized for a variety of use cases. Any contract can be automated to execute when it receives a particular off-chain input from a decentralized oracle, for example.

As detailed by the business logic in the contract, funds owed could deposit to specific addresses on the blockchain that belong to the rightful participants in the transaction. Another common application of programmable money is Decentralized Finance, or DeFi.

Through complex financial algorithms coded into smart contracts, users are able to participate in lending platforms which allow them to earn interest on their crypto holdings, and even create collateralized stablecoins which are pegged 1:1 to the US Dollar, for example. 

Smart contracts greatly increase the utility of blockchain technology because they allow for complex business logic to be created around simple monetary transactions. They can impact a variety of industries beyond finance such as healthcare, education, governance, and logistics, to name a few.

Other Blockchain Lessons:

The history of money

The history of money

What is money? Money is a technology that has been as essential to the development of civilization as the wheel itself. Money is any good that is widely accepted as a medium of exchange during the transaction of goods and services. It facilitates commerce by serving...

What is a blockchain?

What is a blockchain?

What is a blockchain? Distributed ledger technologies are based on a concept known as blockchain. The term “blockchain” refers to the basic structure that is a chain of blocks. The “block” in a blockchain is where transaction records or various pieces of information...

What are nodes?

What are nodes?

What is a node? A node is essentially a computer on the blockchain that runs network software to recognize and broadcast valid transactions. Nodes communicate which each other and reach consensus, or a common agreement, as to which transactions are legitimate. When we...

What is a consensus mechanism?

What is a consensus mechanism?

What is a consensus mechanism? Consensus refers to the act of coming to an agreement among individuals or groups. A consensus mechanism is the method by which decentralized networks agree on which transactions are valid before being confirmed as legitimate across the...

What is Proof of Work (PoW)?

What is Proof of Work (PoW)?

Proof-of-Work is the original consensus mechanism that is utilized by the Bitcoin blockchain. Bitcoin’s decentralization refers to the global network of nodes and miners that is responsible for broadcasting and confirming valid transactions; they are not controlled by...

What is Proof of Stake (PoS)?

What is Proof of Stake (PoS)?

Proof-of-Stake (PoS) was developed as an alternative consensus mechanism to Proof-of-Work. Proponents of PoS typically say that PoW is too energy and resource intensive. As a response, they developed Proof-of-Stake which aims to solve these issues inherent to PoW. In...