The Ethereum Virtual Machine (EVM) is a virtual component that is contained in every Ethereum node and is able to execute bytecode for contracts. Smart contracts are usually written in high-level languages like Solidity and are then converted into EVM bytecode. This allows anyone to feed code into a specific ecosystem in which the result of execution can be confirmed and which is completely deterministic, i.e. smart contracts can be managed.
Ethereum follows the same approach as the JVM but with a different smart contract language - Solidity. These contracts are converted into bytecodes and uploaded onto the blockchain, where they can be executed by an EVM running on various hardware platforms.
What is the Purpose of the Ethereum Virtual Machine?
The Ethereum Virtual Machine is a vital part of the Ethereum ecosystem, responsible for processing and deploying smart contracts. Smart contracts are essentially digital agreements that automate transactions between parties in a trustless way. The EVM also processes transactions on the Ethereum blockchain ledger and maintains an ever-growing list of accounts and balances by using a database called the state tree, which stores all account balances at any given moment in time.
Developers use the EVM to create decentralized applications based on Ethereum and its EVM-compatible programming language Solidity. These DApps can then be deployed onto the mainnet once they’ve gone through a thorough security audit process to ensure there are no bugs or vulnerabilities that could damage user funds or data.
EVMs and Their Similarities to CPUs
The Ethereum Virtual Machine is a distributed worldwide computer network that runs on 100 CPUs simultaneously. It's responsible for running the bytecode of smart contracts, which are programs that can be embedded in any blockchain, such as Ethereum.
The EVM has two primary functions: to change state and to store data. A state change occurs when a transaction is processed; this can happen only with consensus from all nodes running on the EVM. Data is stored as part of each transaction, so it can be used again later or altered in some way.
The purpose of the EVM is to allow for trustless transactions between parties without a third party acting as an intermediary. The process works in such a way that no one party controls another—each party has complete control over their own money and assets at all times during the process.
Ethereum Virtual Machines: How It Works
The Ethereum Virtual Machine (EVM) is a dynamic, sandboxed virtual stack that runs on each Ethereum node and executes smart contract bytecode. It’s a decentralized nodal network that allows anyone to run a virtual machine and gives blockchain networks the flexibility they need.
With EVM, you can create a new smart contract and deploy it anywhere on the network, rather than being limited to a single computer or server. This makes it possible to automate all kinds of processes, like financial transactions or real estate sales, without having to rely on an intermediary or third party.
EVM Opcodes
In the world of Ethereum, EVM opcodes are the instructions that enable smart contracts and transactions to be executed. They're called opcodes because they operate on a single operation, like arithmetic, stopping or memory. EVM opcodes are useful for all sorts of things: calculating a new balance in a contract's state, retrieving information about the current block, or even changing how much gas you want to spend on a transaction.
EVM opcodes assist the EVM to complete specific tasks of a smart contract or transaction. Currently, there are roughly 150 opcodes that the EVM can execute. They cover a range of operations including: arithmetic, stopping, logging, duplication (copying), push (moving data), memory (allocating space), comparison (testing) and exchange (swapping). As well as for retrieving block and environment information. You can find a list of opcodes here.
For efficiency purposes EVM converts its bytecode into opcode where each opcode is assigned one byte in bytecode. Each opcode operation requires a certain amount of gas.
Smart Contracts
A smart contract is simply a list of defined operations that are executed when certain conditions are met on or off-chain. Some operations could be transferring funds from one address to another, communicating with other parties or even creating new contracts.
Rather than requiring a third party to execute these transactions, any sender can send funds directly to the address of the smart contract in order to trigger these operations. What makes smart contracts secure is the fact that once they are executed their code cannot be altered or changed. Anytime a contract is executed it alters the state of the EVM.
The EVM can be described as a "state machine" because it is responsible for computing the state changes that are a result of executing codes within these smart contracts.
All transactions are stored on a blockchain and are publicly accessible, which means that anyone can see what transactions have occurred on the network. The smart contracts themselves are also stored on this blockchain, allowing anyone to view them if they wish.
The EVM maintains accounts and their ether balances, as well as data storage for smart contracts and transactions on both account and contract levels as they are completed. All of these actions are what change the 'state' of the network.
Smart contracts are primarily written in the language of Solidity. The EVM cannot directly execute Solidity so first the code must be compiled to lower level machine instructions called opcodes.
In order to verify that the contract has been correctly compiled, we use a function call called "verify." If it successfully verifies the contract, then we can assume that it has been compiled correctly and is ready to be used.
Gas
Gas is an important part of Ethereum. It's the fuel that powers your EVM, and it's what makes it so awesome. But what is gas? Why do we have to pay for it? And how do we know when to pay more?
The purpose of gas is to act as a fee for computing the operations of a smart contract done by each Ethereum node. There needs to be a fee for computation in order to prevent an attacker from bringing the network to a halt by deploying a large amount of complex contracts that require long computation times. This type of DDoS attack is discouraged because it would be so expensive to run.
When you're driving your car, it's easy to understand how the gas you put in your tank relates to the distance you can travel.
The same thing applies when you're using Ethereum. Each opcode has a gas cost assigned to it with the more complex opcodes having higher costs. For example, simple addition costs 3 gas and every transaction starts at a cost of 21,000 gas. Most of the complaints are not about gas itself but the gas limit to complete a successful transaction.
Gas limit is the maximum amount of gas that the sender is willing to pay for the transaction to be executed and validated. To get the gas fee, you can multiply the total gas cost (the base values of the operations) by the gas price (the cost of completing those operations).
Gas Fee = Total Gas Cost x Gas Price
Much like when filling your car with actual gas, there is the cost of the gas itself and the amount of gas needed to get to your destination.
The most common issue people have with Ethereum is not knowing how much they'll have left over after sending their transaction through. This can lead people into making mistakes that could have been avoided had they only known what their limits were beforehand!
When you send Ethereum, you're paying a fee to compensate the validators who make sure your transaction is valid, free of errors or exceptions from the EVM, and meets the required funds needed to pay for the computation. Validators are paid in fees by users of the system who set gas limits when they send transactions. Setting a high gas limit means that your transaction is complex and will likely be picked up by validators as an opportunity to earn more money.
While Ethereum uses the same consensus mechanism as Bitcoin, it differs from Bitcoin in one key way: the EVM can only execute a limited amount of computation. When network activity is high, validators can simply choose from the pool of pending transactions with higher gas limits. Gas fees are thus influenced by supply and demand. The good thing is that any gas not consumed is refunded to the sender.
If the pre-paid gas limit is hit, the validator is still compensated for their work but the transaction is not completed. In this way, the EVM is quasi-Turing Complete as the computations it can complete are limited to the amount a sender is willing to pay to be completed.
EVM Crypto Use Cases
Now that we have seen each piece of the EVM separately, let’s examine how they come together to power the Ethereum network.
ERC-20 Tokens
ERC-20 tokens are a specific type of cryptocurrency that follows a defined data structure on the EVM. They can be transferred between addresses, have a fixed amount and their value is the same across the network. Smart contracts that follow a defined data structure on the EVM are used to create ERC-20 tokens. This data structure controls the naming, distribution, supply amount and monitoring of the token.
Decentralized Exchanges
Decentralized exchanges are an exciting new development in the world of cryptocurrency trading. They're different from regular exchanges in that they don't rely on a third party or any other centralized authority to function—instead, they're powered by smart contracts and decentralized blockchain technology.
Decentralized exchanges like Uniswap and SushiSwap are powered by Automated Market Makers (AMM), which allow users to contribute to liquidity pools for certain tokens without any third party controlling it. This means that you can trade your ERC-20 tokens without having to store them on an exchange or trust anyone else with your money.
ERC-721 Tokens
The other widely popular token standard is ERC-20’s non-fungible cousin ERC-721. These smart contracts are used for minting NFT’s (Non-fungible tokens) which are tokens with unique value across the blockchain. Creating unique works of art is the biggest use-case for these types of tokens.
Unlike ERC-20, which can be used to create fungible or non-fungible tokens, ERC-721 only supports non-fungible token creation. This means that every token created using this standard will have its own unique identifier, like a serial number, and will also contain information about its owner and any other attributes assigned to it by its creator.
AMMs and DEXs
Decentralized exchanges have become a popular alternative to centralized trading platforms because they enable the exchange of ERC-20 tokens through the deployment of smart contracts, which are designed to allow users to tap into the liquidity pools of tokens without third-party interference. The resulting exchange is an automated market maker (AMM), which allows for seamless transactions between buyers and sellers.
DeFi Lending
DeFi Lending is one of the most exciting areas in crypto. Decentralized lending platforms are challenging the traditional financial system, providing easier access to credit and a way to get out of debt. One of the DeFi platforms is AdaSwap. It's a Cardano-based decentralized exchange with an AMM that allows users to lend and borrow DAI.
Recently, AdaSwap announced a collaboration with Milkomeda. Using Layer 2 solutions for a sidechain, Milkomeda gives non-EVM blockchains like Cardano EVM compatibility. With this sidechain, users can transfer assets and run Cardano DApps on Ethereum, and vice versa.
DAOs
In the past, companies have been limited by the boundaries of their physical location and the limitations of centralized control. Now, thanks to the Ethereum Virtual Machine (EVM), you can build a company that's fully autonomous and transparent.
The EVM is governed by a decentralized autonomous organization (DAO), which is a communal entity without a central authority. This gives everyone in the community control over the network.
DAOs are not only autonomous—they're also transparent. Smart contracts outline the rules and execute decisions based on code-written instructions, but at any point, proposals and voting can be made through consensus. Even the code itself can be open to public audit so that every member of your community can understand how your protocol functions at each and every step of the way.
Ultimately, DAOs are entirely governed by individual members who make critical decisions regarding your project collectively as a whole. The rules of a DAO are established by core community members and implemented through smart contracts, which are visible and verifiable by anyone in your community who wants to see how things work behind closed doors!
The EVM and Beyond
As the Ethereum platform continues to evolve, it will be interesting to watch how developers continue to use and exploit its code as a building block for applications with functionalities that are not easily replicated on other blockchain platforms. The future of Ethereum, and ultimately its ability to live up to its promise and potential, will depend upon how well the developer community is able to work with the EVM and all its quirks. Only then, might we come closer to realizing the true power of what a blockchain promises, the ability to innovate without permission.
EVM Crypto Limitations
Ethereum's virtual machine allows developers to build smart contracts on the blockchain. However, there are some drawbacks to using the EVM.
First, to program in Solidity and other languages, you must have a level of technical expertise.
Second, Ethereum's high gas fees are due to its popularity and data congestion within the network.
Finally, a small portion of Ethereum nodes are actually running on Amazon Web Services (AWS). If AWS were to go offline or cease providing services, there could be noticeable effects on Ethereum-based applications and smart contracts.
What Future Does EVM Have?
Ethereum’s Virtual Machine (EVM) is a powerful tool that has a bright future ahead. As more people become involved in its development, the speed and complexity of the EVM will only increase. But there are still issues with network throughput and transaction speed that need to be addressed if Ethereum is going to succeed. These issues are focal points for the development community, and solving them will be key to Ethereum’s success.
Conclusion
The Ethereum virtual machine, or EVM, is the beating heart of the Ethereum ecosystem. It enables a shared global infrastructure for the execution of smart contracts and decentralized apps. Without it, there would be no DApps to speak of or anywhere to deploy them. The EVM brought smart contracts into existence—with it, they are able to execute in an efficient and stable manner. In this article, we have gained a deeper understanding of Ethereum's underlying machinery and explored how smart contracts carry out their day-to-day operations.
Share
Join the column
Contribute to our blog as a writer or propose a fresh idea for an article!