Before we get to web3, we need to understand what cryptocurrencies are and why they were created.
And for that, we need to talk about bank accounts.
The bank accounts are just a bunch of records kept by banks.
The records have your bank account number and the amount of money in it.
You can transfer some of your money to someone else by creating a transaction.
Banks update their records. But they can, potentially, also mess with them.
For all of this to work, everyone needs to trust the bank. Or the central bank. Or the law!
You've probably come across a system like this already! Any guesses?
Cryptocurrencies were created to solve this problem! They are just like regular currencies, except the transaction records are stored on a blockchain instead of in bank records.
Bitcoin was the first cryptocurrency. Let's checkout how it works -
The blockchain is a system that stores records of all transactions of money.
But, no one can mess with a blockchain's records.
The exact copies of the records are stored in thousands of computers across the world. You can store one in your computer as well.
If someone tries to change the data in one computer:
The other computers point out the mistake, and change it back!
To find out how much money someone has, you just go through the transactions and keep a tab the currency in their account.
Can we make other systems trustless?
Vitalik Buterin, created another blockchain, Ethereum, with some extra features over Bitcoin.
Before we get into the extra features, let's talk about accounts.
Accounts on Bitcoin are pretty simple. Each account has a balance - the amount of bitcoins it has.
To find out the balance of any account, you just go through all the recorded transactions.
Ethereum also has accounts like this.
But, it also has another type of account:
An account like this is not controlled by any human. It only transfers money as per the contract code written in it.
These accounts are called smart contracts.
What can these smart contracts do?
Let's start with a quick example.
Kickstarter is a crowd funding platform.
- People list their projects on it.
- Other people who support the project send money.
- Early supporters get some rewards later on when the project is complete. e.g. discounts or free memberships
If enough money is collected, Kickstarter transfers the money to the project.
A smart contract can replace this third party since it can hold funds too!
You write some rules in the smart contract and put it on the blockchain.
No one, including the creator of the contract can change it afterwards. (The same way no one can change the transactions recorded on a blockchain)
All the supporters transfer their fundings to this smart contract account.
Once the funding goal is achieved, the smart contract instantly transfers the money to the project owner.
The smart contract cannot be controlled by anyone. It is a simple computer program, that will always transfer the money according to the rules.
There is no need to trust a third party like Kickstarter now!
To find out what's inside a smart contract account you simply go through all the transactions on the blockchain. (Just like a regular account)
There are other applications of smart contracts as well. All of them, in some way, remove the need to trust a third party.
I plan on creating more posts like this on everything from here to the latest rabbit holes in web3!
In the next post I'll go through another popular application of smart contract accounts - NFTs - you know, those weird images like this
that were sold for millions of dollars!
Was anything confusing or hard to follow? Let me know by reaching out on @NandanApoorv and I'll try and update this accordingly.