Smart contracts are by far one of the most pivotal innovations introduced in the blockchain ecosystem. It opened a new world of possibilities. But, what exactly are smart contracts?
This article would focus on explaining in the most basic sense what smart contracts are.
What are Smart Contracts?
Smart contracts are programs that run on the blockchain. Or, deployed onto a blockchain.
Every smart contract has a unique address called a contract address which is generated on deployment.
Background Story
Blockchain technology was popularized by Satoshi Nakamoto with the creation of Bitcoin, the first decentralized digital currency.
On the Bitcoin Software (also known as Bitcoin Core), a programming language called Bitcoin Scripting Language(or Bitcoin Script) is used for interaction. It is used to define how coins are moved in the network.
Note that the Bitcoin Blockchain wasn't built with the Bitcoin Script rather the Bitcoin Script is built on top of it. The first implementation of the Bitcoin blockchain was built with C++ and other implementations have been built since then.
Based on the explanation above, the Bitcoin script is a smart contract because it runs on the blockchain and it defines the rules of how bitcoins are handled. But, this has a limitation. It is turing incomplete. It's rigid and can't be used for most use cases other than Bitcoin. It was built for Bitcoin and it alone it.
Developers needed a way to build on the Blockchain without having logical limitations. This is where Ethereum comes in.
In late 2013, Vitalik Buterin in a blog post titled Ethereum: The Ultimate Smart Contract and Decentralized Application Platform described an idea for a Turing-complete blockchain – a decentralized computer that, given enough time and resources, could run any application.
Ethereum launched in 2015 allowing developers to build smart contracts with turing-complete programming called Solidity. Since then other smart contract compatible blockchains and more languages for building them have come into the space.
Although Bitcoin Script can be seen as a smart contract, the terms smart contracts weren't used that much before Ethereum. Therefore, Ethereum popularized the idea of smart contracts while building an ideal version.
How do Smart Contracts Work?
They work like most computer programs would typically work. A set of instructions are defined and using those instructions you could perform certain operations if the necessary conditions are met.
One distinct factor is the smart contract depends on the blockchain for storage. And most interactions are done within the confines of the blockchain. They can't easily interact with the other side world like calling a WEB API.
Smart contracts are compiled to bytecode and then run by the Ethereum Virtual Machine (EVM).
The EVM can be seen as a processor containing Operation codes (also called OPCODES). Every section of the bytecode has its representation in the Operation code which simply tells the EVM what to do with them.
Are Smart Contracts smart?
The term word smart in the smart contract gives off the idea of something related to artificial intelligence. But, there is nothing smart about smart contracts. Until we start calling computer programs that use "if/then" statements "smart", smart contracts are not smart.
Are Smart Contracts actual Legal Contracts?
No, they are not.
Smart contracts follow the fundamental idea of a legal contract which is adhering to predefined set rules. But, smart contracts are just like most computer programs and best define how they work.
Attributes of a Smart Contract
- Immutability
Once smart contracts are deployed to the blockchain they cannot be changed. It is impossible to do that.
This is a blessing and a curse because, before smart contracts, developers weren't used to building programs that cannot be changed but at the same time, this helps us ensure security during development and after deployment.
During development, smart contract developers build with the mindset that the smart contract is unchangeable so they consider a lot (especially security). After deployment, as developers, we are sure that our contract cannot be changed.
- Publicly Available All smart contracts are public. They are publicly available if a smart contract is deployed onto a public blockchain (which is mostly the case).
Every public blockchain has an explorer where most activities performed on the blockchain are displayed. To find a smart contract, all you need to do is get the contract address and search it on explorer.
This also means that anyone can interact with a deployed smart contract. Anyone.
Transparency
Every transaction with the smart contract from the most basic to the most complex can be viewed on the explorer.
Transactions are operations that alter the state of a smart contract. Read operations are not transactions.
This helps for proper auditing.
Conclusion
Ethereum is the blockchain of context here, but the ideas discussed can be transferred to other blockchains.
Smart contracts made possible the most groundbreaking innovations in the blockchain space. One of which is Defi (Decentralized Finance). Most Defi applications like Uniswap, Compound or MakerDAO would be not in existence without smart contracts.
Top comments (0)