What is the Ethereum Virtual Machine (EVM)?
- The Ethereum Virtual Machine (EVM) is the computing engine that runs smart contracts and decentralized applications on the Ethereum blockchain.
- It operates as an isolated, sandboxed environment, protecting the main blockchain network from potential flaws in smart contract code.
- The EVM is considered quasi-Turing complete because it requires gas fees to execute operations, effectively preventing infinite computational loops.
The Ethereum Virtual Machine (EVM) is a globally executed, consensus-based virtual machine that serves as the runtime environment for smart contracts on the Ethereum blockchain. The Ethereum network could be described as a blockchain with a built-in programming language.
The part of the protocol in charge of all the computing is known as the EVM. It is key to Ethereum being able to run smart contracts. These smart contracts enable Ethereum to harness the power of decentralized applications (dapps).
Additionally, smart contracts enable developers to launch their own digital tokens on the Ethereum network.
Why is the EVM considered a sandboxed environment?
The EVM is sandboxed and isolated from the real world. This means that the code running in the EVM has no access to a network, file-system, or any other processes. This makes the EVM a secure environment for developing and testing smart contracts without interfering with the operations of the underlying blockchain.
Flawed code can be detrimental to any smart contract, so ensuring there are no vulnerabilities before deployment is critical. A sandboxed environment provides a secure space to iterate and complete robust smart contracts that are ready for deployment to the live blockchain.
Additionally, the EVM cannot access real-world data on its own, such as the current date, time, or weather. To acquire such data, which is often required for the proper execution of smart contracts, the EVM relies on real-world data providers known as oracles. An oracle can gather data from outside sources and feed it to the smart contract.
What does it mean that the EVM is quasi-Turing complete?
The EVM is often described in relation to Turing completeness. Turing completeness refers to a system's capacity to perform any calculation it is presented with, given enough time and resources. This means that, in Ethereum, it is theoretically possible to write programs or decentralized apps that are capable of solving any reasonable computation.
However, there is a limitation built into the EVM as a safety precaution. Because smart contracts can call other contracts, there is a potential for infinite loops. To prevent this, the EVM demands a gas fee to be paid for each computational step of an on-network transaction.
This means that infinite computational loops are prevented because they will eventually exhaust the initiating user's ether balance. Because of this safety measure limiting computations to available gas, the EVM cannot be entirely Turing-complete and is instead referred to as quasi-Turing complete.
What checks does the EVM perform on transactions?
Whenever a transaction is initiated on the Ethereum blockchain, whether it is a simple transfer of value or a smart contract deployment, the EVM performs three specific checks:
| Step | EVM check | Description |
| 1 | Validation | Confirms whether a transaction has the correct number of values, a valid signature, and a matching transaction nonce. Mismatches prompt an error. |
| 2 | Gas calculation | Calculates the fee required for the transaction and initializes the gas payment. |
| 3 | Execution | Executes the transfer of ether or tokens to the assigned address. |
If the EVM detects that the sender did not allocate enough gas to complete the initiated transaction, the transaction will fail.
In this case, the transaction fee is not refunded to the initiator but is instead paid to the network validator for the computational work done up to that point. However, if a transaction is unsuccessful due to an error at the recipient's address, the EVM will return the sent amount and the associated fee back to the sender.
Disclosures:
Content provided for educational purposes only. Not investment advice or a recommendation. Trading and owning digital assets involves significant risk, including the risk of substantial loss. Cryptocurrency services are offered through an account with Robinhood Crypto, LLC (NMLS ID 1702840). Robinhood Crypto is licensed to engage in virtual currency business activity by the New York State Department of Financial Services. Cryptocurrency held through Robinhood Crypto is not FDIC insured or SIPC protected.
New customers need to sign up, get approved, and link their bank account. The cash value of the stock rewards may not be withdrawn for 60 days after the reward is claimed. Stock rewards not claimed within 60 days may expire. See full terms and conditions at rbnhd.co/freestock. Securities trading is offered through Robinhood Financial LLC. Futures trading offered through Robinhood Derivatives, LLC.