If you set a very high gas price, you will end up paying lots of ether for only a few operations, just like setting a super high transaction fee in bitcoin. Providing too big of a fee is also different than providing too much ether. So it's only fair that you pay them for the work they did, even though your badly designed transaction ran out of gas. This may seem harsh, but when you realise that the real work for the miner was in performing the computation, you can see that they will never get those resources back either. The miner will stop processing the transaction, revert any changes it made, but still include it in the blockchain as a "failed transaction", collecting the fees for it. But if I provide an acceptable gas price, and then my transaction results in so much computational work that the combined gas costs go past the amount I attached as a fee, that gas counts as "spent" and I don't get it back. It will simply not be included in the blockchain by miners. If the gas price I set in my transaction is too low, no one will even bother to run my transaction in the first place. It's the combination of the two, total gas used multiplied by gas price paid, that results in the total fee paid by a transaction.Īs tricky as it is, it's important to understand this distinction, because it results in one of the most confusing things about Ethereum transactions to the initial learner: there is a difference between your transaction running out of gas and your transaction not having a high enough fee. Every transaction specifies the gas price it is willing to pay in ether for each unit of gas, allowing the market to decide the relationship between the price of ether and the cost of computing operations (as measured in gas). Operations in the EVM have gas cost, but gas itself also has a gas price measured in terms of ether. The terminology here gets a little messy. So it's helpful to separate out the price of computation from the price of the ether token, so that the cost of an operation doesn't have to be changed every time the market moves. Why don't operations just have a cost measured in ether directly? The answer is that ether, like bitcoins, have a market price that can change rapidly! But the cost of computation doesn't go up or down just because the price of ether changes. When it comes to actually paying for the gas, the transaction fee is charged as a certain number of ether, the built-in token on the Ethereum network and the token with which miners are rewarded for producing blocks. Instead, gas exists only inside of the Ethereum virtual machine as a count of how much work is being performed. Although gas is a unit that things can be measured in, there isn't any actual token for gas. So if gas is basically a transaction fee, how do you pay it? This is where it gets a little tricky. So it's important to measure the work done directly instead of just choosing a fee based on the length of a transaction or contract. Since Ethereum allows arbitrarily complex computer code to be run, a short length of code can actually result in a lot of computational work being done. This is a different strategy than the Bitcoin transaction fee, which is based only on the size in kilobytes of a transaction. By requiring that a transaction pay for each operation it performs (or causes a contract to perform), we ensure that network doesn't become bogged down with performing a lot of intensive work that isn't valuable to anyone. The reason gas is important is that it helps to ensure an appropriate fee is being paid by transactions submitted to the network. Every operation that can be performed by a transaction or contract on the Ethereum platform costs a certain number of gas, with operations that require more computational resources costing more gas than operations that require few computational resources. It measures how much "work" an action or set of actions takes to perform: for example, to calculate one Keccak256 cryptographic hash it will take 30 gas each time a hash is calculated, plus a cost of 6 more gas for every 256 bits of data being hashed. "Gas" is the name for a special unit used in Ethereum.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |