Everyone records this notice on the page until the page is written down. At that time, everyone will seal the content on the page by solving a math puzzle. This ensures everyone's pages have the same content and are never editable. Anyone who finishes first will be rewarded with a virtual money.
When the page is sealed, it is inserted into the paper container and the new page is removed, the process goes on and on. Over time, these pages (which are blocks) contain important information (transactions) that will be added to the stack (which is the chain) and create the database (or blockchain).
A blockchain can be used to store any type of data and the data that the storage blockchain gives it value. Bitcoin's Blockchain stores information about financial transactions, making it similar to currencies like dollars or pounds. Bitcoin has no other purpose than what dollars do.
You can read more about the blockchain here: What is Blockchain? How does blockchain work?
But Ethereum is different. It is not merely a currency but also a higher purpose.
Ethereum is not merely a virtual currency for trading
Just like any blockchain, Ethereum also needs thousands of people running software on computers to power the network. Each node (node - or a computer) in the network runs something called Ethereum Virtual Machine (EVM). Think of EVM as an operating system that can understand and run software written in Ethereum's own programming language. Software or applications running on EVM are called smart contracts.
To accomplish something on this world computer, you need to pay a price. However, you will not pay in ordinary currency but with a virtual currency of your own network called an Ether. Ether is like Bitcoin except that it can be used to implement smart contracts on Ethereum.
Both humans and smart contracts are users on Ethereum
Both humans and smart contracts are considered users on Ethereum. What people do, smart contracts can do. They behave like any other person on the network. Both send and receive Ether as any other currency.
Smart contracts behave like any human user
But unlike humans, smart contracts can execute predetermined computer programs to perform many operations. To understand smart contracts, see the example below.
Imagine you and me betting on tomorrow's weather. I bet it's sunny and you bet it's raining. We all agree that the loser will have to give the winner $ 100. What should we do to ensure the loser keeps his promise? There may be 3 ways.
Method 1: Trust each other
The simplest way is for two people to trust each other. If we are old friends and know everything about each other, this is the simplest way. But if we are strangers, it will be a little more difficult. There is no reason you have to believe me and me.
Method 2: Sign the agreement
Another way to ensure the bet is to sign an agreement or a contract. We define detailed terms, including when the loser breaches the agreement and signs it together.
The contract will make us legally bound to pay the winner but there is no practical value because we are forced to perform a contract with a legal process that is more expensive than the actual value of the contract.
Method 3: Get help from friends
We can find a mutual friend that we both trust, each giving $ 100 to that person and the next day, depending on the weather, both $ 200 will be given to the winner. Although simple, what happens when this friend disappears with $ 200?
Ethereum's smart contract can help in such situations. It is like a friend that both believe in but are written in code. Ethereum allows us to write a software that accepts $ 100 from both and the next day, it uses the weather API to check and transfer the $ 200 amount to the winner.
Smart contracts become reliable referees
Once written, the smart contract will not be modified or changed. Therefore, you can be sure that the contract will do exactly what has been said no matter what happens.
But how does smart contract work? And what does it have to do with blockchain?
Whenever a contract is made, it will record the information on the block as a transaction. At a very high level, transactions on Ethereum will look like this.
Smart contract transactions on Ethereum
The 'data' zone is what makes Ethereum unique. It is used to record the creation and execution of smart contracts as a transaction. Any block on the Ethereum blockchain contains the following three types of transactions.
Transferring ordinary Ether from users to a human user
These are transactions like normal BItcoin. If you send Ether directly to your friend, this data area will be left blank.
Transaction between two users is human
Nobody can transfer Ether from users
When transactions are made without recipients, it means that the purpose of the transaction is to create smart contracts on the network, using content in the data area. This area will contain software code and act like any other user on the network.
Contract sent to nobody
Transfer Ether from users to a smart contract
Whenever a user (or a smart contract) wants to perform a contract, he / she / he is required to make a transaction with the smart contract and give the instruction to the data area. material.
When the recipient is a smart contract
As with any blockchain, when one of the three events mentioned above happens, it will notify the entire network and people will record it. In addition, each node also executes the contract that has been instructed to bring the EV state, synchronized with the whole network.
Each node implements a piece of software that makes the whole system act as a giant (but slow) distributed computer. Each smallest execution is recorded on blockchain forever.
Users using smart contracts have to pay a sum of money to implement it. This price is paid to the node depending on memory, storage, computing power and the power needed to perform the contract.
To calculate the price of a smart contract, each statement must be pre-specified. For example, if you make a statement of button memory usage, storage space on the button drive . all have a separate price. Unit of this price is called Gas. Gas will then be converted to an Ether by the exchange rate.
Whenever you perform smart contracts, you will determine the maximum Gas level. Implementation will stop when completed or when the Gas Limit is reached. This is to prevent smart contracts from repeating forever, avoiding jammed programs and continuously executing many of the same statements without advancing to the next step.
Such situations are caused by programmers' negligence. With each repetition, some of the specified Gas are used and make the loop forever stop. It is absurd that the button gets stuck in this situation because of the programmer's error, so Gas helps solve this problem.
Ethereum is not just virtual money for trading, its true value lies in its purpose, which is to allow its owners to use the world computer, where thousands of nodes are active.
Of course, because each of the smallest statements is done by every node in the network, this decentralized distribution computer will be very slow and expensive. But slow compared to what? With centralized control servers.
To get low cost when using centralized computers, we give them control. If the central server is hacked, it will drag all customers. The decentralized computer will be defeated when all the nodes are dropped, making it an available computer. Where there is the Internet, there is Ethereum.