What is the meaning of gas in blockchain
The strict definition of blockchain refers to the distributed database technology that multiple nodes in peer-to-peer network jointly maintain a continuously growing list ledger constructed by time stamp and orderly record data blocks through consensus mechanism based on cryptography technology. This technical solution allows any number of nodes in the participating system to calculate and record all the information exchange data in the system in a period of time to a data block through cryptography algorithm, and generate the fingerprint of the data block for linking the next data block and checking. All participating nodes in the system jointly determine whether the record is true
blockchain is a technical solution similar to NoSQL (non relational database). It is not a specific technology, and can be implemented through many programming languages and architectures. There are many ways to realize blockchain, including pow (proof of work), POS (proof of stake), dpos (delegate proof of stake), etc
the concept of blockchain was first proposed in the paper "bitcoin: a peer-to-peer electronic cash system" by indivials (or groups) who call themselves Satoshi Nakamoto. Therefore, bitcoin can be regarded as the first application of blockchain in the field of financial payment
< H2 > [popular explanation]no matter how big the system or how small the website is, there is a database behind it. So who will maintain this database? In general, who is responsible for the operation of the network or system, then who is responsible for the maintenance. If it is wechat database, it must be maintained by Tencent team, and Taobao database is maintained by Alibaba team. We must think that this way is natural, but blockchain technology is not P>
if we think of the database as a book, for example, Alipay is a typical account book. Any change of data is bookkeeping. We can think of database maintenance as a very simple way of accounting. In the world of blockchain, everyone in the blockchain system has the opportunity to participate in bookkeeping. The system will select the fastest and best bookkeeper in a period of time, maybe within ten seconds or ten minutes. The bookkeeper will record the changes of the database and the account book in a block. We can think of this block as a page. After the system confirms that the records are correct, the system will record the changes of the database and the account book in a block, It will link the fingerprint of the past account book to this paper, and then send this paper to everyone else in the whole system. Then, over and over again, the system will look for the next person with fast and good bookkeeping, and everyone else in the system will get a of the whole ledger. This means that everyone as like as two peas in the system is called Blockchain. It is also called distributed account technology. P>
as like as two peas (computer) have identical accounting books, and everyone has the same rights, they will not collapse e to the loss of contact or downtime of a single person. As like as two peas, the data is transparent and everyone can see what changes are in every account. Its very interesting feature is that the data can't be tampered with. Because the system will automatically compare, it will think that the same number of books with the largest number are real books, and a small number of books with different numbers are false books. In this case, it's meaningless for anyone to tamper with his own account book, because unless you can tamper with most nodes in the whole system. If there are only five or ten nodes in the whole system, it may be easy to do so. However, if there are tens of thousands or even hundreds of thousands of nodes and they are distributed in any corner of the Internet, unless someone can control most computers in the world, it is unlikely to tamper with such a large block chain
< H2 > [elements]combined with the definition of blockchain, we think that we must have the following four elements to be called public blockchain technology. If we only have the first three elements, we will consider it as private blockchain Technology (private chain)
1, peer-to-peer network (power equivalence, physical point-to-point connection)
2, verifiable data structure (verifiable PKC system, non tampering database)
3, distributed consensus mechanism (Solving Byzantine general problem, solving double payment)
4 Game design of Nash equilibrium (cooperation is the strategy of evolutionary stability)
combined with the definition of blockchain, blockchain will realize four main characteristics: decentralized, trustless, collective maintenance and reliable database. And the other two will be derived from the four characteristics Features: open source Privacy. If a system does not have these characteristics, it can not be regarded as an application based on blockchain technology
Decentralized: there is no centralized hardware or management organization in the whole network. The rights and obligations of any node are equal, and the damage or loss of any node will not affect the operation of the whole system. Therefore, it can also be considered that the blockchain system has excellent robustnesstrustworthiness: there is no need to trust each other when participating in the data exchange between each node in the whole system. The operation rules of the whole system are open and transparent, and all data contents are also open. Therefore, within the specified rule range and time range of the system, nodes cannot and cannot cheat other nodes
collective maintenance: the data blocks in the system are maintained by all the nodes with maintenance function in the whole system, and these nodes with maintenance function can be participated by anyone
reliable database: the whole system will enable each participating node to obtain a of the complete database in the form of sub databases. Unless more than 51% of the nodes in the whole system can be controlled at the same time, the modification of the database on a single node is invalid, and the data content on other nodes cannot be affected. Therefore, the more nodes and computing power in the system, the higher the data security in the system
Open Source: since the operation rules of the whole system must be open and transparent, the whole system must be open source for the program
Privacy Protection: since there is no need to trust each other between nodes, there is no need to disclose the identity between nodes, and the privacy of each participating node in the system is protected
Blockchain is a shared database. Blockchain is a new application mode of computer technology, such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and so on
main features:
1. Decentralization. Blockchain technology does not rely on additional third-party management institutions or hardware facilities, and there is no central control. In addition to the self-contained blockchain itself, each node realizes information self verification, transmission and management through distributed accounting and storage
2. Openness. The foundation of blockchain technology is open source. In addition to the private information of all parties to the transaction is encrypted, the data of blockchain is open to everyone. Anyone can query blockchain data and develop related applications through the open interface
3. Independence. Based on consensus specifications and protocols, the whole blockchain system does not rely on other third parties, and all nodes can automatically and safely verify and exchange data in the system without any human intervention
4. Safety. As long as 51% of all data nodes cannot be controlled, the network data cannot be arbitrarily manipulated and modified, which makes the blockchain itself relatively safe and avoids subjective and artificial data changes
5. Anonymity. Unless there are legal requirements, technically speaking, the identity information of each block node does not need to be disclosed or verified, and the information can be transferred anonymously
extended data
application direction:
1. Payment: for example, in terms of time, traditional cross-border remittance takes 10 minutes or several days, while blockchain cross-border remittance can achieve remittance in seconds e to decentralization. In terms of convenience, traditional cross-border remittance needs to wait until the next day after 19:00, while blockchain cross-border remittance only needs one mobile phone to realize all-weather remittance
2. Sharing medical records: the medical data blockchain sharing platform can achieve many application scenarios. Patient history data and other information can be linked, and medical history and image data can be viewed by personnel entering the system. These medical data can also be used for modeling and machine learning
source: network blockchain
Public chain, also known as "public chain", refers to the blockchain that anyone in the world can enter the system at any time to read data, send confirmatory transactions and compete for bookkeeping. The public chain is generally considered to be "completely decentralized", because no indivial or institution can control or tamper with the reading and writing of data in it. In terms of application, blockchain public chain mainly includes bitcoin, Ethereum, super ledger, most counterfeit currencies and smart contracts. The ancestor of blockchain public chain is bitcoin blockchain, which has the following characteristics:
1, open source code
upload the code to GitHub, and everyone can get complete blockchain data by downloading, Accept the test of the public
2, complete decentralization
anyone can become a node, each node is open, everyone can participate in the calculation of the blockchain, any node is not permanent, but phased, and any center is not mandatory for nodes. Anyone can read and send transactions, and transactions can be effectively confirmed on the blockchain. Anyone can participate in the consensus process. The consensus process determines whether a block can be added to the blockchain and the exact current state. Everyone can get financial reward from it, which is proportional to their contribution to the consensus process. These public chains are generally considered to be "completely decentralized"
3. Developing decentralized applications
through this public chain, developers can easily develop centralized applications. Public chain can protect the rights and interests of users from the influence of program developers
first, smart contracts are so good that they are not useless
smart contracts. As the name suggests, smart contracts refer to contracts that can be executed automatically by computer code; Ethereum virtual machine is used to execute smart contract; Smart account is the carrier that smart contract can be executed. In other words, smart account, this "account" can be controlled by Ethereum virtual machine. According to what control, according to smart contract
there is no free lunch in the world. The smart contract function is so good that it's not useless. When you trade in Ethereum, you have to pay the miner's handling charge. So what's the handling charge you have to pay on Ethereum system, and what's the relationship between
gas and handling charge
2. What's the matter with Ethereum gas
Ethereum gas is similar to automobile fuel. It needs Ethereum gas to drive smart contract. Gas is an English word, Chinese meaning: gas, gasoline, this thing in daily life, is a consumable. Why does Ethereum proce fuel
what is the meaning of gas in Ethereum? In fact, Ethereum's gas is closely related to transaction costs. Ethereum transaction needs service charge. This gas is the calculation mode of service charge of Ethereum
in the setting of Ethereum, the transaction fee is similar to an encrypted fuel, namely gas, which can drive the movement of smart contracts. When Ethereum executes transactions on the blockchain, the fuel will be graally consumed according to the rules of the characteristics
from this point of view, gas is really the same as its original intention, like automobile fuel. If you want to start a car, you must need fuel
What is the difference between the transaction fees of Ethereum gas and bitcoin When it comes to handling charges, you may be familiar with them. There is no free lunch in the world. Both Ethereum and bitcoin need service charge, but the service charge mode of the two is different. Bitcoin is used to pay bitcoin as a transfer fee directly, but Ethereum is not In essence, Ethereum is a virtual machine, which is decentralized and controlled by people all over the world, forming a "world-class computing network". When you send a token, execute a contract, transfer Ethereum, or do other things on the block, the computer needs to calculate when processing the transaction, which consumes network resources. In this way, you have to pay the "gas" to get the computer to work for you and the miners to process the transaction for yougenerally, the higher the gas price the sender is willing to pay, the greater the value the miners get from the transaction, and the more likely the miners are to choose the transaction. In this way, miners are free to choose to trade. In order to set the gas price for the sender as a reference, miners can directly put forward the lowest gas price they need to execute the transaction
How to calculate the gas consumption of Ethereumwhen Ethereum virtual machine processes transactions, Virtual Opportunities process one by one according to the operation instructions determined in the transaction, and each operation instruction has a specified gas consumption
Ethereum system stipulates two accounts: one is normal account and the other is smart account
for ordinary transfer transaction, that is to call "normal account", the required gas is fixed 21000
when calling "smart account", because the complexity of smart contract is different, the required gas is also different. The more resources (computation, memory, etc.) used to process transactions, the more gas will be needed. For example, an addition operation will consume 3gas. If more complex operations are performed, the more gas will be consumed
then you may ask a question: when a user's transaction involves a malicious smart contract, the contract is extremely complex, and the execution of the contract will consume unlimited fuel, what should we do? The solution of Ethereum system is: in order to avoid unlimited gas consumption caused by malicious
smart contract, the user needs to set the maximum allowable fuel consumption when sending the transaction, namely
gaslimit. In this way, even if there is a malicious smart contract, the worst case is only within the fuel consumption range specified by gaslimit
What is the relationship between Ethereum gas and transaction feeson Ethereum, the service charge you pay is equal to gasprice times gasused
you can understand gasprice as the unit price of fuel and gasused as how many liters of fuel the car needs
for a car, if you say 20 yuan per liter of gasoline, 10000 liters of gasoline is 200000 yuan. For Ethereum, each
gas is 20 gigabytes (gigabytes is the unit of quantity of Ethereum currency), and 10000 gas is: 20 times 10000 equals 200000 gigabytes, 20000 gigabytes equals 0.0002 Ethereum, that is to say, the transaction procere is 0.0002 Ethereum
the specific exchange value is shown in the following table:
for specific exchange rate query, you can check the following website:
for details https://jin10086.github.io/etherconVerter/
both gas price and ether price are freely regulated by the market, but they are different in that the price of ether fluctuates according to the market situation, while the price of gas is determined by miners, If the price of fuel falls below the miners' minimum requirements, the miners refuse to process the deal. The separation of gas and Ethereum can protect the system from the possible fluctuation with the rapid change of Ethereum price
generally speaking, most miners will choose to give priority to their interests. When dealing with the transaction, they will arrange according to the gas price from high to low, and give priority to those with high gas price. If you are in a hurry to trade, you need to raise the gas price so that the miners can see you earlier; If you are not in a hurry, you just need to set a gas price, which is above the bottom line of gas price set by miners
How is gas obtainedin fact, gas is the ether coin purchased from the miner. The ether coin in the user's own account can purchase gas from the miner, and the Ethereum client will automatically purchase gas with Ethereum according to the specified maximum transaction expenditure limit
Where did gas go in the endfor each transaction, the initiator of the transaction must set the gas limit and gas price. Different operations will proce different gas costs. When the gas is used up, the miner will stop executing, and the gas used will be used as a reward to the miner. This will involve several situations:
the first situation is that if there is a surplus gas, the miner will stop executing, Then the remaining gas will be returned to the transaction initiator or the creator of the smart contract. For example, if I send an Ethereum to Yiyi, the gas limit I set is 50000, and the gas normally consumed is 21000, then the remaining 29000 that has not been consumed will be returned to me
in the second case, if the gas limit I set is too low, or the Ethereum in my account is not enough to pay for my gas consumption, then the transaction will be cancelled e to insufficient gas, and the gas used for calculation will not be returned to my account
in the third case, if the transaction fails, I have to pay the handling charge for the occupied computing resources
How to set a reasonable gas pricebefore each transaction, you can query this website to confirm the gas price to be set: https://ethGasstation.info/ To sum up, in this article, we mainly introce the gas and service charge of Ethereum: gas is equivalent to fuel oil. When you process transactions on Ethereum virtual machine, you will consume computing resources, that is, gas. On Ethereum, the service charge you pay is equal to gasprice multiplied by gasused, that is, the unit price of gas multiplied by the total amount of gas consumed. The complexity of the operation is different, and the cost of gas is also different. When the gas is used up, the miner will stop executing, and the gas used will be used as a reward to the miner. The miner will give priority to the trader with higher gas price
currency circle: refers to the people who focus on currency speculation or even issue their own digital currency to raise funds. Generally speaking, blockchain project parties, exchanges and some blockchain media all belong to the currency circle
chain circle: refers to people who focus on the research and development, application or underlying protocol of blockchain. Without the technical support of the chain circle, the coin circle can not exist. In the future, the implementation of the blockchain scene will depend on the technology of the chain circle
mining circle: refers to the "miners" who focus on "mining"< Second, several investment behaviors of blockchain
currency speculation: similar to stock speculation, refers to the behavior of repeatedly buying and selling digital currency through trading platform in order to obtain high income
Soha: it's a transliteration of show hand, originally a term used in gambling games. It's the act of withdrawing all available chips at one time. When it comes to blockchain investment, it refers to investing all of your available assets in digital currency in order to speculate in money, which has the meaning of "bet your fortune"
Buddhist holding of cryptocurrency: it refers to the behavior of not caring about the price trend of cryptocurrency after holding of cryptocurrency. No matter how much the asset price of cryptocurrency falls, it will not rece the holding of cryptocurrency in hand
3. Segmentation of blockchain investors
banker: refers to the investor with strong capital volume, strong relationship network and the most informed information, who can influence or determine the price trend of a certain currency to a large extent
large investors: investors with abundant capital, but not as strong capital and relationship network as makers
retail investors: refers to the small amount of funds, small amount of trading, and unorganized investors< Four, blockchain investment common phenomenon
leek: is an image of metaphor, leek growth ability and adaptability are very strong, can be one after another in a large range of breeding. It is compared to some retail investors who do not know the market situation. Most of them are easily influenced by the investment sentiment. They buy at a high price and sell at a low price. Some people will lose money, and after they leave the market, new forces will enter. Like leeks, they will cut one crop and grow another soon
cut leek: it means that the dealer buys at a low price, speculates at a high currency price, sells at a high price after the retail investors come in and make a profit, and then smashes the plate to a low position. In this way, the retail investors will suffer losses and the dealer will make a profit. The makers and the big investors keep repeating this routine, that is, "cutting leeks", while the retail investors keep entering, the makers repeat the routine of cutting leeks
cut back: refers to the sharp drop in the price of digital currency, which is very huge, falling to half of the previous highest price. For example, when I buy a currency, the highest price of this currency is $100. After a while, I fall to less than $50. It can be said that my currency has been cut off
meat cutting: it refers to the behavior of selling stop loss in time when the price of digital currency falls in order to prevent the continuous decline from causing greater losses, so as to prevent greater losses in the future
being held up: it means that I spend a high price to buy a currency. After a while, the currency falls, and I don't want to sell it and stop loss in time. Instead, I choose to wait to see if the price can rise again. The waiting process is "being held up". In this case, I can be said to be held up
unwinding: it means that the purchased digital assets graally rise back after a round of sharp decline, and the price rising back exceeds the price when I bought them. At this time, I will not lose money when I sell these digital assets. This is unwinding
airdrop candy: refers to the free distribution of a certain amount of digital currency to users in order to promote the blockchain project at the beginning of the project. These free digital currencies are called "candy" by users.