What is an Ethereum Virtual Machine (EVM)?
An Ethereum Virtual Machine (EVM) is a computational platform that allows developers to create decentralised applications (DApps) on Ethereum. The EVM is where all the Ethereum accounts and smart contracts are stored.
This new software platform makes it easier for developers to operate smart contracts executed on the Ethereum blockchain. A smart contract is a collection of data and codes that exists as a type of Ethereum account.
Ethereum Virtual Machine explained
The EVM exists for the sole purpose of determining the overall state of Ethereum for each block on the blockchain. Ethereum is similar to other blockchain-based networks and has its own native currency called ether (ETH).
A distributed ledger is used to maintain a database of transactions on the blockchain, with rules to help the network work effectively. The distributed ledger is run with the help of distributed ledger technology (DLT). Distributed ledgers are also used across other types of blockchain networks such as Bitcoin.
How does the Ethereum Virtual Machine work?
The EVM utilises a set of instructions, known as opcodes, to perform specific tasks. There were at least 140 unique opcodes, as of 30 January 2019. These opcodes allow the EVM to use its resources to compute anything. Since opcodes are 1 byte each, there can be a maximum of 256, or 16 times 16, opcodes.
Smart contracts run EVM bytecode when starting a transaction, which allows them to carry out calculations and further transactions. The EVM uses a 256-bit register stack. At any given time, the most recent 16 items can be accessed or operated. In total, the register stack can hold up to 1,024 items.
A regular transaction is created when a smart contract is brought to action along with an address. Some bytecode is added, which plays the role of a constructor. During the deployment of a smart contract, the creation bytecode, which generates the runtime bytecode, will only run once, while the runtime bytecode will run on every smart contract call.
All the implementations of EVMs must abide by the specification mentioned in the Ethereum Yellow paper. It’s crucial to note that all Ethereum clients, or execution clients, must include an EVM implementation.
Finally, at the end of a bytecode, a swarm hash of a metadata file is created. It’s a distributed storage platform and service for content distribution. A swarm hash is designed for the efficient storage and retrieval in content-addressed storage, in both local and networked systems.