{"id":3268,"date":"2022-12-06T12:55:49","date_gmt":"2022-12-06T12:55:49","guid":{"rendered":"https:\/\/metaschool.so\/articles\/?p=3268"},"modified":"2024-12-09T02:01:55","modified_gmt":"2024-12-09T02:01:55","slug":"what-is-ethereum-virtual-machine-evm","status":"publish","type":"post","link":"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/","title":{"rendered":"Ethereum Virtual Machine (EVM)"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_56_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Core_Components_and_Architecture\" title=\"Core Components and Architecture\">Core Components and Architecture<\/a><ul class='ez-toc-list-level-3'><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Gas_and_Execution_Model\" title=\"Gas and Execution Model\">Gas and Execution Model<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#State_and_Transactions\" title=\"State and Transactions\">State and Transactions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Memory_Management\" title=\"Memory Management\">Memory Management<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Smart_Contract_Execution\" title=\"Smart Contract Execution\">Smart Contract Execution<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#What_does_%E2%80%98EVM_compatibility_mean\" title=\"What does \u2018EVM compatibility\u2019 mean?\">What does \u2018EVM compatibility\u2019 mean?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Development_Tools_and_Interfaces\" title=\"Development Tools and Interfaces\">Development Tools and Interfaces<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Benefits_of_Ethereum_Virtual_Machine\" title=\"Benefits of Ethereum Virtual Machine\">Benefits of Ethereum Virtual Machine<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/metaschool.so\/articles\/what-is-ethereum-virtual-machine-evm\/#Major_EVM-Compatible_Blockchains\" title=\"Major EVM-Compatible Blockchains:\">Major EVM-Compatible Blockchains:<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>EVM stands for <a href=\"https:\/\/metaschool.so\/courses\/how-does-ethereum-work-a-deepdive?ref=Article&amp;utm_source=Blog_Organic\">Ethereum<\/a> Virtual Machine. It is a Turing-complete software that runs on the Ethereum network. It&#8217;s essentially a vast, decentralized computer that maintains the state of the Ethereum network and facilitates consensus between thousands of nodes worldwide. Every node on the Ethereum network runs an instance of the EVM to maintain consensus across the blockchain and verify the execution of smart contracts.<\/p>\n\n\n\n<p>The beauty of the EVM lies in its deterministic nature \u2013 given the same input and the same code, it will always produce the same output, regardless of where or when it&#8217;s executed. This predictability is crucial for maintaining consensus across the decentralized network.<\/p>\n\n\n\n<p>Created in 2015 by <a href=\"https:\/\/metaschool.so\/articles\/vitalik-buterin-ethereum-profile\/\" target=\"_blank\" rel=\"noreferrer noopener\">Vitalik Buterin<\/a> and <a href=\"https:\/\/metaschool.so\/articles\/gavin-wood-polkadot-ethereum-profile\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gavin Wood<\/a>, EVM is used to create and execute smart contracts, decentralized applications, and other automated services autonomously without the need for a third party. It also manages its state whenever a <a href=\"https:\/\/metaschool.so\/articles\/block-meaning-blockchain\/\" target=\"_blank\" rel=\"noreferrer noopener\">block<\/a> is created in the blockchain.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Core_Components_and_Architecture\"><\/span>Core Components and Architecture<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Ethereum Virtual Machine (EVM) processes instructions through what we call &#8220;opcodes&#8221; \u2013 these are low-level programming instructions that perform basic operations. When you write a smart contract in Solidity or another high-level language, it gets compiled down to these opcodes that the EVM can understand.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1920\" height=\"1736\" src=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image.png\" alt=\"Ethereum Virtual Machine Architecture\" class=\"wp-image-11038\" srcset=\"https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image.png 1920w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image-300x271.png 300w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image-1024x926.png 1024w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image-768x694.png 768w, https:\/\/metaschool.so\/articles\/wp-content\/uploads\/2022\/12\/image-1536x1389.png 1536w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/figure>\n\n\n\n<p>The Ethereum Virtual Machine operates using several key components:<\/p>\n\n\n\n<p><strong>Stack:<\/strong> The main data structure where most operations take place, handling simple push and pop operations with a maximum depth of 1024 elements.<\/p>\n\n\n\n<p><strong>Memory:<\/strong> A temporary space that gets cleared after each transaction, used for storing data during contract execution.<\/p>\n\n\n\n<p><strong>Storage: <\/strong>The permanent data store where contract state variables live. Think of this as a contract&#8217;s hard drive.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Gas_and_Execution_Model\"><\/span>Gas and Execution Model<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>One of the most important concepts in the Ethereum Virtual Machine is &#8220;gas&#8221; \u2013 the computational pricing mechanism that prevents spam and allocates resources on the network. Each operation in the EVM costs a certain amount of gas, with more complex operations costing more.<\/p>\n\n\n\n<p>For example: Adding two numbers costs 3 gas, storing a value costs 20,000 gas, or creating a new contract costs 32,000 gas. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"State_and_Transactions\"><\/span>State and Transactions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The EVM maintains the entire state of the Ethereum network, which includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Account balances<\/li>\n\n\n\n<li>Smart contract code<\/li>\n\n\n\n<li>Contract storage<\/li>\n\n\n\n<li>Nonces<\/li>\n<\/ul>\n\n\n\n<p>When a transaction triggers a smart contract, the EVM creates what we call a &#8220;context&#8221; for execution. This context includes information about who initiated the transaction, how much Ether was sent, and what data was included.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Memory_Management\"><\/span>Memory Management<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The EVM handles memory in a linear fashion, expanding it as needed during contract execution. Developers should be aware that while memory is cheaper than storage in terms of gas costs, it&#8217;s still not free. The EVM charges more gas as you use more memory, following a quadratic cost formula. Read more about Ethereum Virtual Machines in the <a href=\"https:\/\/ethereum.org\/en\/developers\/docs\/evm\/\" data-type=\"link\" data-id=\"https:\/\/ethereum.org\/en\/developers\/docs\/evm\/\" target=\"_blank\" rel=\"noopener\">official documentation of Ethereum<\/a>. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Smart_Contract_Execution\"><\/span>Smart Contract Execution<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When your smart contract runs on the EVM, it goes through several phases:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Code Loading: The EVM retrieves the contract&#8217;s bytecode<\/li>\n\n\n\n<li>Stack Setup: Preparation of the execution stack<\/li>\n\n\n\n<li>Instruction Processing: Step-by-step execution of opcodes<\/li>\n\n\n\n<li>State Updates: Any changes to the blockchain state are prepared<\/li>\n\n\n\n<li>Finalization: Changes are committed or rolled back based on success\/failure<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_does_%E2%80%98EVM_compatibility_mean\"><\/span>What does \u2018EVM compatibility\u2019 mean?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>EVM (Ethereum Virtual Machine) compatibility signifies a blockchain&#8217;s capacity to execute Ethereum smart contracts, enabling developers to write and deploy identical smart contracts across various EVM-compatible blockchains with minimal code adjustments. This feature facilitates the creation of multi-chain decentralized applications (dApps) by allowing these smart contracts to interact seamlessly with other EVM-compatible blockchains.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Development_Tools_and_Interfaces\"><\/span>Development Tools and Interfaces<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The ecosystem provides several tools to interact with the Ethereum Virtual Machine <\/p>\n\n\n\n<p>Web3.js and Ethers.js: JavaScript libraries for interacting with the EVM<br>Truffle and Hardhat: Development frameworks for testing and deployment<br>Remix IDE: Browser-based IDE for Solidity development<br>Ganache: Personal blockchain for Ethereum development<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-ethereum-virtual-machine\"><span class=\"ez-toc-section\" id=\"Benefits_of_Ethereum_Virtual_Machine\"><\/span>Benefits of Ethereum Virtual Machine<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Since the logic is implemented and executed on distributed nodes, there is no chance of ambiguity and error.<\/li>\n\n\n\n<li>Allows developers to create and deploy decentralized applications and services on the Ethereum network.<\/li>\n\n\n\n<li>Provides a secure and reliable platform for executing smart contracts and other automated services.<\/li>\n\n\n\n<li>Enables developers to write code that is resistant to malicious attacks and can be executed without a central authority.<\/li>\n\n\n\n<li>Provides a secure sandboxed environment that is resistant to malicious attacks and ensures the integrity of data and transactions.<\/li>\n\n\n\n<li>Provides high efficiency in the execution of smart contracts.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"top-blockchain-companies-using-evm\"><span class=\"ez-toc-section\" id=\"Major_EVM-Compatible_Blockchains\"><\/span><strong>Major EVM-Compatible Blockchains<\/strong>:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A lot of companies have been using EVM for enterprise use cases. These companies range from supply and retail to healthcare and insurance. Here is a list of some blockchain companies powered by EVM:<\/p>\n\n\n\n<p><strong>ThunderCore (TT):<\/strong>\u00a0A gaming-focused, EVM-compatible blockchain with native Thunder Token (TT) and ThunderCore Bridge for cross-chain mechanisms.<br><strong>Binance Smart Chain (BSC)<\/strong>: Notable for low transaction fees and high performance, attracting a multitude of dApps and users.<br><strong>Avalanche C-Chain<\/strong>: Offers high throughput and scalability while ensuring Ethereum compatibility.<br><strong>Cardano<\/strong>: Working on KEVM (K Semantics of the Ethereum Virtual Machine (EVM)) to enable Ethereum-style smart contracts, despite not being natively EVM-compatible.<br><strong>TRON (TRX)<\/strong>: A high-throughput blockchain aiming to decentralize the internet, started as an\u00a0<a href=\"https:\/\/plisio.net\/blog\/erc20-trc20-bep20-token\" target=\"_blank\" rel=\"noopener\"><u>ERC-20<\/u><\/a>\u00a0<a href=\"https:\/\/plisio.net\/blog\/altcoins-coins-tokens\" target=\"_blank\" rel=\"noopener\"><u>token<\/u><\/a>.<br><strong>Layer 2 Solutions<\/strong>: Networks like\u00a0<a href=\"https:\/\/plisio.net\/blog\/arbitrum-arb-speeding-up-ethereum-using-optimistic-rollups\" target=\"_blank\" rel=\"noopener\"><u>Arbitrum<\/u><\/a>, Optimism, and Polygon (MATIC) offer scaling solutions for Ethereum, enhancing transaction speed and cost-efficiency using technologies like Optimistic Rollup.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":24,"featured_media":5458,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[73,17],"tags":[31,68],"class_list":["post-3268","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web3-crypto-glossary","category-blockchain","tag-ethereum-blockchain","tag-web3-words"],"_links":{"self":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/3268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/comments?post=3268"}],"version-history":[{"count":14,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/3268\/revisions"}],"predecessor-version":[{"id":11061,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/3268\/revisions\/11061"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media\/5458"}],"wp:attachment":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media?parent=3268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/categories?post=3268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/tags?post=3268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}