General understanding of EVM
Last updated
Last updated
The Ethereum Virtual Machine (EVM) is the core computational engine that powers the Ethereum blockchain, responsible for executing and deploying smart contracts. Essentially, the EVM defines the rules for determining a new valid blockchain state from block to block, ensuring that all participants reach consensus about the state of the Ethereum network.
A virtual machine (VM) is a high-level abstraction that simulates a physical computer within the host operating system. It is part of the interpreter’s internal architecture and allows the same platform to run across different hardware and operating systems. This makes virtual machines particularly suitable for distributed networks, like Ethereum, by providing a uniform execution environment regardless of the underlying hardware.
The Ethereum Virtual Machine is a type of virtual machine designed specifically for the execution of smart contracts on the Ethereum blockchain. Smart contracts are pieces of code stored on the blockchain that can be executed in a deterministic way. The EVM acts as the infrastructure that runs these smart contracts, handling everything from contract deployment to the computation of blockchain state changes.
The EVM ensures that the execution of these smart contracts is decentralised, with every participating Ethereum node able to verify the outcome. This functionality is crucial for the Ethereum network, allowing the deployment of a wide range of decentralised applications (dApps) while safeguarding against vulnerabilities such as Denial-of-Service attacks.
The process begins with developers writing smart contracts in high-level languages, such as Solidity or Vyper. These contracts are then compiled into EVM bytecode, which the EVM can execute. The bytecode is interpreted by the EVM’s runtime engine, which processes the code on a stack-based architecture, following a Last-In, First-Out (LIFO) structure.
During execution, the EVM manages temporary memory for its calculations and maintains a persistent Merkle Patricia storage trie for each smart contract, enabling efficient data retrieval and updating within the global state.
Interaction with the EVM occurs through transactions, such as deploying contracts or executing functions within contracts. These transactions can be triggered by users or by other smart contracts. The EVM processes opcodes within the bytecode, which can represent mathematical operations, account balance checks, or blockchain-specific tasks. This execution, performed across the network of nodes, is what keeps the blockchain consistent and decentralised.
It is important to distinguish between dApps that require interaction with the EVM and those that do not. Transactional dApps, like decentralised exchanges (e.g., Uniswap), require users to execute transactions involving state changes on the blockchain. These interactions are directly handled by the EVM through the deployment and execution of smart contracts, requiring users to connect their wallets to initiate and authorise transactions.
On the other hand, transactionless dApps do not require direct interaction with the EVM. These dApps often use wallet connections solely for purposes such as user identification or verifying eligibility for rewards. Unlike transactional dApps, they do not execute smart contracts or trigger state changes on the blockchain. Thus, requiring users to connect their wallets in such scenarios is often unnecessary, as there are no transactions that need to be authorised and executed via the EVM.
By understanding the nature of dApp interactions, users can differentiate between when a wallet connection is genuinely required and when it is superfluous, thereby minimising unnecessary security risks associated with granting wallet permissions.
The Ethereum Virtual Machine is the execution environment for smart contracts on the Ethereum blockchain, responsible for processing transactions and ensuring consistency across the network. Only transactional dApps, which involve the execution of smart contracts and state changes, interact directly with the EVM. For transactionless dApps, wallet connections are often used for identification purposes without any need for actual interaction with the EVM, which makes wallet authorisations in such cases redundant.