What is Ethereum Virtual Machine?
Ethereum is one of the most popular cryptocurrencies and the first platform to offer smart contracts as we know them today. In contrast to Bitcoin, smart contracts at the Ethereum blockchain are much more commonly used during ICO. Since the ERC20 standard was proposed, smart contracts can be developed even by programmers without much experience with Solidity language. Regardless of failed cases (such as Fork The DAO) the introduction of smart contracts on the blockchain is still in use.
Many platforms are trying to follow and overcome Ethereum. The list of competitors includes NEO, EOS, Hyperledger and other well-known projects. Anyway, Ethereum offers a solution that sets it apart from other platforms — an independent technology called Ethereum Virtual Machine (EVM).
Ethereum Virtual Machine explained
To explain what EVM is, you should start with the concept of accounts. There are two types of accounts in Ethereum, and this approach has been chosen to support smart contracts.
The first type of account, called Externally owned account (EOA), is for managing members. They are considered as objects with state and have balance. The second type of account is a “contract account”. Official documentation define it as a combination of code and information that belongs to a specific address in the Ethereum blockchain.
All accounts have a number of identical fields:
- Nonce — “the number used only once”. It is used to indicate various transactions and calls from contracts to prevent double-spending situations.
- Balance — a simple state of the account at a specific address (indicated in Wei).The hash of the contract code — the result of calculating the hash of the smart contract stored in the database state. The EOA does not have this part because it is managed by the participants.
- The account storage hash — hash value that is calculated based on data placed in the long-term storage. Not available for EOA accounts.
All contracts are written in special programming languages. These languages are designed specifically for the Ethereum environment. Their list includes:
- Solidity — the main language for Ethereum. The vast majority of smart contracts on the Ethereum blockchain are created using
- Solidity. It is actively developing, and the help of Ethereum enthusiasts is greatly appreciated.
- Vyper — a high-level alternative language designed for writing smart contracts. It is less popular than Solidity, however, is supported.
- Serpent — a language similar to Python.
- Mutan — an obsolete language abandoned in favor of Solidity. Not supported.
All these languages address their commands to the same EVM process on the blockchain. All of their commands are translated into bytecode, executed in accordance with the EVM logic.
How does all this works?
Suppose you want to create a mechanism that allows you and your three neighbors to shop fairly for your home. You create a smart contract according to that need. And you have a few tasks that a smart contract should take into account.
- You and your three neighbours must create separate accounts;
- all must agree to deposit a certain amount each month from their own account into the general smart contract account;
- and all parties to the contract sign off on the fact that they will not be able to withdraw money from that account alone;
- the money can only be spent if the four of you sign your electronic signature on a particular spending account.
This is exactly how it works. But let’s assume that you want to spend a certain amount of money on household expenses every week. You create a separate smart contract that describes the following conditions:
- that only $10 a week is allocated for household goods;
- the goods must be purchased in only one particular store;
- you must make sure that the goods from a particular store have been delivered to the specified address.
Now let’s assume that you want to buy a TV in the house, but all neighbors want to pay different amounts. This will require another smart contract. Its terms and conditions are as follows.
- Man A is only willing to spend $20;
- Man B is willing to give away $40;
- Man B can only afford to contribute $10;
- Man D is entitled to pay the missing amount and buy a TV if all the above conditions are met.
Do you understand how all these contracts rely on all previous contracts? This is the way the virtual machine works. This is the environment in which all these contracts exist, interact and influence each other. It’s like a messenger, only for smart contracts.
Actually, EMV can do a lot of useful things. It is possible to create contracts that require several conditions to be met: for example, insurance contracts that require certain pieces of information to be provided before paying the policy.
You can let different people create their own mini-contracts inside larger ones. Imagine a builder who hires contractors to build a house. He can make mini-contracts between plumbers, plasters, and electricians, each of whom will only get paid if certain conditions are met.
You can create contracts that will automatically buy or sell things. Let’s say you’re in the air conditioning business. And you only want to buy air conditioners when the temperature rises above a certain level during the year. In this case you can create a smart contract, which will take into account the weather data and make a purchase only when it is necessary according to your conditions.
Finally, there’s another important contract application that will help you make money from your luck. his is a special smart contract of our Ethex.bet platform, which rewards a user who was able to guess the last characters of the next Ethereum block. Place a bet, choose the right numbers or letters and start earning ETH!