Do you actually know how smart contracts work? No? Me either. Ever since I started going down the rabbit hole with blockchain, I’ve been learning about blockchain basics. Without those, I’ll never be able to understand how protocols work. In my self-learning journey, I’ve neglected smart contracts. Why? Because I’m not a software engineer. But, that’s a poor excuse. Just because I’m probably never going to code a smart contract doesn’t mean I shouldn’t know how they work. So, here we go!
Smart contracts are pieces of code that can be stored in a blockchain, performing complex operations. It’s software with the ability of self-executing when one or many conditions are matched. The entire process is automated and can act as a compliment, or substitute, for legal contracts, where the terms of the contract are recorded in lines of code, as a set of instructions. Similar to a series of if-then statements that execute in a particular order.
Here’s a simple example of how it works. Suppose you wanted to charge your electric car with my charging station and we did this by blockchain buy transacting with cryptocurrency. You sent me some cryptocurrency and then you get a receipt which is held in our smart contact. I give you the digital entry key for my charger at a specified timeslot. If the key doesn’t come on time, the blockchain releases a refund. If I send the key before the timeslot, the function holds it releasing both the fee and key to you and me respectively when timeslot arrives. Everything is recorded where hundreds of people view it and delivery is irreproachable. The document is automatically canceled after the timeslot, and the code cannot be changed.
Most smart contracts are executed on the Ethereum network. Ethereum is an open source platform based on blockchain technology that enables developers to build and publish decentralized applications. Ethereum smart contracts are coded in a language called Solidity. I’m hoping to learn a little Solidity to be able to read smart contracts! Wish me luck 🙂