Ok so i now know the answer (i think) and will put it here for it might be of use to someone noob like myself.
Sending and receiving ether and tokens are not free as i thought. A price should be paid for miners to put your transaction in a block and add it to the chain. And that price is payed in ether and is called gas for that transaction.
RE: Ethereum "Gas" - How it Works
You are viewing a single comment's thread from:
Ethereum "Gas" - How it Works
And now my question would be 1. Am i right on the fact that gas is awarded to miners or what miners mine has nothing to do with it?
And 2. So when buying tokens there are two things to consider. First how much we want to invest and second how much we are willing to spend on that attempt to invest. Whats the purpose of this second thing? Any analogy to the common banking system would be helpful and very appreciated.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
To be clear, gas is a unit of measurement. It has no value, it simply represents the amount of work a miner must do while processing the transaction.
If a transaction consumes more gas, the miner has to do more work. Gas price is the amount of Ether you actually pay for each unit of gas that your transaction uses.
Miners receive the product of
gas consumed * gas price
for any transaction.Since there are multiple transactions in a block, you add up all of these products and that becomes part of the block reward given to the miner who produces the block.
For your second question, you're using the word "invest" and that's a bit confusing to me.
I'll assume you're talking about gas limit and gas price. The "how much we want to invest" would be your gas limit, which is the upper bound of how much gas you're willing to pay for in a transaction. The "how much we are willing to spend on that attempt to invest" would be the gas price, the actual amount of Ether you spend on each unit of gas.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
And also on rereading your comment, suddenly i have some weird problems :D
Gas limit is a set amount equal to the (technical?)(processing wise?) difficulty of mining it; thus that much will be payed as a fixed number called gas limit for that transaction. Multiplied by the price we set for every gas.
And i guess the word invest (for example as making a transaction for investing in EOS ICO) has nothing to do with anyone of those two per se. :))
But then again wouldnt that make gas price the amount we would want to invest in making this transaction happen. (And so would this make transactions with higher gas limit needs inherently to be preferred more by miners?!
Thanks!:)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Gas is a measurement of computational work. Each instruction in the Ethereum Virtual Machine has an associated gas cost. For example, the opcode ADD has a gas cost of 3, and all it does is add two numbers. MUL costs 5 gas, and multiplies two numbers. These are pretty cheap, but an instruction like STORAGEADD costs 20,000 gas because it permanently stores a 256-bit word on the blockchain. It's not so computationally hard, but the memory consumed is substantial when you consider that these 256 bits must be stored on every full node mining.
Gas price could be thought of as "the amount invested in the transaction", but I don't think it's very useful to think of it that way. The main reason is because it's not really an investment. It has a binary outcome, either the transaction goes through and you pay, or it doesn't and you don't. There's no risk involved, so I don't think it's very comparable to an investment.
The exception to this would be when a transaction not being mined has an associated cost. A good example of this would be when you're trying to get into an ICO that is selling out quickly. If you don't specify a high enough gas price, your transaction might not go through quick enough and you lose your investment opportunity. That means there's an opportunity cost to your transaction, and in this scenario the gas price you specify is more like an investment in the transaction.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Yep exactly what i had in mind.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for taking your time @tomshwom
Why should we create competition between transactions with gas price? Wouldnt it be better to have a fixed gas price so in the end all transactions would go through?
P.S: thinking about it more this would make transactions with low gas limit, face problems as miners will go for high cost ones preferentially.
So let me put it this way. There is a fee for any transaction to be put in a blockchain and so be accepted by the community which is what gives it its credibility (this transaction is done).
Now you can set that fee higher so your transaction goes through faster.
It is unfortunate that you have to pay the full price for a failed transaction.
You have any comments on that? Why the full gas invested should be payed?
Thanks again :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Gas fees exist because there are real costs to running the blockchain. Miners spend a lot of money running their mining rigs in a Proof of Work consensus blockchain, and there are electrical/hardware costs associated with that. You have to pay miners enough to incentivize them to actually maintain the blockchain for you, and you want that incentive to be large enough that you have a truly distributed network of miners so that 1) nobody can 51% attack the network with invalid transactions, and 2) even if all of the US goes offline, the blockchain is fine.
The reason why these fees are proportional to computation (which is where the gas measurement comes from) is because it simply makes more sense. If your transaction takes more computational steps, it burns more electricity and consumes more resources from the network. You should pay for that, and the amount should be proportional to the work. These fees also deter attacks on the network with things like infinite loops. I becomes economically impossible to sustain a spam attack when miners have the choice to ignore your transaction because it's not paying enough for them.
If a transaction is included in the blockchain, it hasn't failed, and this is when you pay your gas fees. Failed transactions do not cost anything because they are never computed by the network. However, transactions that did not specify a high enough gas limit to complete the computation, had incorrect data, or were wrong in some other way do cost money because they still cost the network to process these "failed" transactions. You cannot use a global distributed network, mess up, and hope for a refund. It's just not fair to the people who did the work for you.
In the future, contracts should be written to be able to anticipate failure ahead of time and exit quickly so that the gas consumed is small. This will help save people money when they mess up their transaction, but won't hurt miners.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Clear and thorough explanation. Kudos to you!
Please correct me if im wrong. When gas limit is specified as 100 thousand and your transaction needs 1 you will pay the limit you have specified if your transaction fails. Unlike when it succeeds!? Why is that so?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
The gas limit only specifies the max amount you're willing to pay. If the transaction gets mined, you only pay for the gas actually consumed. If it's mined, the transaction is technically successful (even if the results aren't what you wanted).
If it's not mined, then nobody did the computation, so nobody gets paid anything.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit