Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the intelligent contract transaction and transaction cost of ethernet square

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to understand the intelligent contract transaction and transaction cost in Ethernet Square". The editor shows you the operation process through the actual case, the operation method is simple and fast, and it is practical. I hope this article "how to understand the intelligent contract transaction and transaction costs in Ethernet Square" can help you solve the problem.

Trade

A transaction is a message sent from one account to another (it may be the same account or zero account, see below). Transactions can contain binary data (payload) and Ethernet coins.

If the target account contains a code, the code is executed, and payload is the input data.

If the target account is a zero account (account address is 0), the transaction will create a new contract. As mentioned above, the contract address is not a zero address, but is calculated from the address of the contract creator and the number of transactions issued by that address (known as nonce). The payload that creates the contract transaction is executed as EVM bytecode. The output of the execution is permanently stored as a contract code. This means that in order to create a contract, you don't need to send the real contract code to the contract, but send the code that returns the real code.

Oil: Gas

A certain amount of gas,gas is charged for each transaction on Ethernet Square in order to limit the amount of work required to execute the transaction and to pay for it. When EVM executes a transaction, the gas is gradually consumed according to specific rules.

Oil price: gas price

The gas price (etheric currency meter) is set by the transaction creator, and the transaction fee required to send the account in advance is gas price * gas amount. If there is any gas left at the end of the execution, the gas will be returned to the sending account.

No matter where it is executed, once the gas is exhausted (for example, reduced to a negative value), an out-of-gas exception will be triggered. All state changes made by the current calling frame will be rolled back.

Transaction fee ceiling: gas limit

Each transaction is required to include a gas limit (sometimes called startGas) and a fee that a transaction is willing to pay per unit gas. Miners can optionally package these transactions and charge these fees. In reality, all transactions today are ultimately chosen by miners, but the transaction fees that users choose to pay will affect how long it takes for the transaction to be packaged. If the amount of gas required for the transaction is less than or equal to the set gas limit due to calculation, including the original message and some other triggered messages, the transaction will be processed. If the total gas consumption exceeds gas limit, then all operations will be restored, but the transaction is established and the transaction fee will be charged by the miner. The blockchain will show that the transaction was completed, but all contract orders were restored because not enough gas was provided. So the excess gas that is not used in the transaction will be called back to the initiator in the form of Taiyuan. Because gas consumption is generally only a rough estimate, many users overpay gas to ensure that their transactions are accepted. This is no problem, because the extra gas will be returned to you.

You can think of gasLimit as the upper limit of your car's fuel tank. At the same time, gasPrice is understood as oil price.

Block transaction fee ceiling: block gas limit

Chunk gas limit is the maximum amount of gas allowed in a single chunk, which can be used to determine how many transactions can be packaged in a single chunk. For example, we have five transactions with gas limit of 10, 20, 30, 40 and 50. If the block gas limit is 100, then the first four transactions can be successfully packaged into the block. Miners have the right to decide which deals to package into blocks. So another miner can choose to package the last two transactions into the block (50-40), and then package the first deal (10). If you try to package a deal that will use more than the current block gas limit, the deal will be rejected by the network, and your Ethernet Square client will reply that the error "transaction exceeds block gas limit". The following example is a post from Ethernet Square StackExhcange.

The current gas limit of the block is 4712357 gas, and the data is from ethstats.net, which means that about 224 transfer transactions (gas limit is 21000) can be crammed into a block (the block time fluctuates between 15 and 20 seconds). This agreement allows miners in each block to adjust block gas limit by arbitrarily adding or subtracting 1max 2024 (0.0976%).

This is the end of the content about "how to understand the intelligent contract transaction and transaction costs in Ethernet Square". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report