Photo by Michael Förtsch on Unsplash
What are EVMs? -- How do they work?
Ethereum Virtual Machine simply explained ---
Unless you've been leaving under a rock, chances are that you've come across the term "Blockchain, Ethereum or Bitcoin" somewhere in the past 5 years or so. All of these words are closely related to each other and its very common for them to be misinterpreted by many people.
The Blockchain
This is the main technology that powers Bitcoin and Ethereum which functions in a PEER-to-PEER way. It works as essentially a giant digital ledger that has information recorded onto it. This ledger is duplicated and distributed among different nodes that keep track of the state of the information on the blockchain.
The whole system is made up of smaller blocks that hold transactional information that is linked together to form the giant chain. Every node has a copy of the chain, and when a transaction is made, a record is reflected on every node and then pushed to the main chain. As you can already tell, there is maximum transparency on the whole system because every node has a copy of the ledger, and every time a new transaction is made, all the nodes will verify that all the information they have matches before it is add to the ledger. This makes the system very difficult to hack and any attempt to do so means that you have change all the nodes copy of the ledgers which is fairly impossible.
Transactions
But what are these transactions? if you ask yourself -- Every record of information that is recorded on the blockchain is never stored in plain text but rather in cryptograpic form, which is a unique string that is still means the same text word when decrypted.
For anyone to make a transaction on the blockchain, you need an address, a private key and secret key
- The address which is sometimes called the wallet address, acts as your account number
- The Private Key acts as your username
- Private Key acts as your password and hence it should be stored safely and its never shared
Crypto-currency
How does it work? -- Take an example of Bitcoin, which is a crypto-currency. When a user wants to buy an item using bitcoin or maybe they want to send some coin to another user. This exchange is done through address to address connection. Just like how your bank account sends money to another bank account with your signature to verify your approve to transfer, the same works with crypto currencies. But in this case your account number is your wallet address and your signature is your private key.
The bank will verify your account credentials and account authenticity before completing the transfer. In this case the nodes will do the verification for you and in a process called proof-of-work and record the transfer to the chain when confirmed in a process called mining.
Ethereum
As you can see for bitcoin, the majority of transactions made are crypto-money exchanges between wallets, and that is a limit. For sometime, smart minds wanted to extend the potential and the type of information that can be stored on the blockchain beyond just coin exchanges. They wanted to find a way of building software that can read and write different types information on the blockchain, and in 2014 Ethereum was made -- more info on wikipedia)
Smart Contracts
The development of Ethereum let engineers write software that can communicate directly with the blockchain. These softwares are most times called DApps -- Decentralized Applications.
These Dapps are a just a piece of code with scripted instructions written in a programming language called Solidity meant to allow interactions with the Ethereum blockchain.
What are these Scripted instructions ? -- These instructions are called Smart Contracts , which is code written in Solidity that gets deployed to the Ethereum blockchain.
Once these smart contracts are deployed to the blockchain, they can never be altered by anyone and will always be on the blockchain
How software works
To understand how smart contracts work, we have to first understand how traditional software works.
First of all, all types of software we use today are written in a programming language that is easily interpreted by any human being. The programming language is made up of a set of English terms and algorithmic symbols that aid the human to carefully craft the instructions to their liking.
However much the programmer writes the instructions, they have to be translated to a computer because a computer does not understand English but rather byte-code. In this case, the translator is called a compiler , and it is found in every computer.
This is no different in Ethereum, the solidity code in smart contracts has to be compiled into byte-code for computers to understand them.
Remember, we said that every computer has a compiler has translates the code. But that's only found in your personal computer. You may ask yourself -- How are we going to compile the code that is going to the blockchain? Where is the compiler even going to be in the first place?
Well, these are good questions, Good enough the smart minds behind Ethereum came up with a smart solution
Ethereum Virtual Machine (EVM)
Every node runs EVM, and is able to convert the bytecode into opcodes for the EVM to interpret and maintain consensus across the Ethereum blockchain. The fact that all nodes run the EVM, it acts as decentralized computational engine that executes millions of projects that are mined on the nodes.
The EVM uses the optcodes to complete instructions.
EVM is Virtual because it runs independently to the blockchain and has no access to the network or any file system on the blockchain.
So the EVM works like a large Master computer channeling operational tasks on the blockchain.