In Ethereum, what is gas, how is it used, and what is the difference between "startgas" and "gasprice"?

fivedogit

I'm looking for an explanation of gas usage in Ethereum. What is it, how is it calculated, and what value does it have?

fivedogit

In Bitcoin, every transaction creates the same amount of “work” for the network. In Ethereum, different transactions have different costs to the network in storage, processor and memory usage, so these transactions need to be “charged” accordingly. Best official(ish) explanation I’ve found is here (“gas” vs “gasprice” is the first bullet): https://github.com/ethereum/wiki/wiki/Design-Rationale#gas-and-fees

Currently (11/20/15) the max gas one can spend with a transaction is 3141592 units. The minimum price per unit is 50000000000 wei. (0.00000005 ether). So, the amount of ether sent as gas in a sample tx might go like this: 3141592 units * 50000000000 wei/unit = 157079600000000000 wei (0.1570796 ether).

Example use (https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/58_indexOf.sol):

indexof.indexOf.sendTransaction("I am cool", "cool", {from:eth.coinbase,gas:3141592, gasprice:50000000000});

Think of it this way:

  • gas/startgas = "gas units"
  • gasprice = "wei I'm willing to pay per unit"

Whatever gas is spent executing transactions is paid to the miner of the block containing the transaction.

Note: Gas and Ether are ultimately the same thing. What makes gas “gas” is how it’s used -- as payment for a transaction.

UPDATE: 12/8/2015: Unused gas is automatically and immediately refunded.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What's the difference between ethereum and chain?

From Dev

What's the difference between ethereum and chain?

From Java

What is the difference between '/' and '//' when used for division?

From Dev

What is the difference between .// and // when they are used in the middle of the xpath?

From Dev

What is the difference between qDebug() used as a stream and as a function

From Dev

What is difference between cached memory and used memory?

From Dev

What is the difference between .// and // when they are used in the middle of the xpath?

From Dev

How to identify if a project has used CQS OR CQRS? What is the difference between CQS and CQRS?

From Dev

What is the difference between "params" and "array parameter" and when should it be used?

From Dev

What is the difference between Hashing vectorizer and Count vectorizer, when each to be used?

From Dev

What is the difference between the following two declarations and when should they be used

From Dev

what is the difference between HashSet and Set and when should each one be used?

From Dev

What is the difference between MinusEqual (-=) and PlusEqual (+=) as used in event declaration c#

From Dev

What is the difference between "params" and "array parameter" and when should it be used?

From Dev

What is the difference between "used space", "size" and "size on disk"?

From Dev

What is the difference between the single and double quotes used with the trap command?

From Dev

What is the difference between "views" path and the path used in express.static?

From Dev

What's the difference between "as?", "as!", and "as"?

From Dev

What is the difference in operation between . and ^ and ^(.*)$?

From Dev

What is the difference between .// and //* in XPath?

From Dev

What is the difference between = and => for a variable?

From Dev

What is difference between "?" and "!" in Swift?

From Java

What is the difference between `.` and `#` in the JavaDoc?

From Dev

CoffeeScript, What is the difference between => and ->

From Java

What is the difference between * and *|* in CSS?

From Dev

What is the difference between $* and $@

From Java

What's the difference between '$(this)' and 'this'?

From Dev

What the difference between != and =/= in chisel?

From Dev

What is the difference between '&&' and '&' in Ruby

Related Related

  1. 1

    What's the difference between ethereum and chain?

  2. 2

    What's the difference between ethereum and chain?

  3. 3

    What is the difference between '/' and '//' when used for division?

  4. 4

    What is the difference between .// and // when they are used in the middle of the xpath?

  5. 5

    What is the difference between qDebug() used as a stream and as a function

  6. 6

    What is difference between cached memory and used memory?

  7. 7

    What is the difference between .// and // when they are used in the middle of the xpath?

  8. 8

    How to identify if a project has used CQS OR CQRS? What is the difference between CQS and CQRS?

  9. 9

    What is the difference between "params" and "array parameter" and when should it be used?

  10. 10

    What is the difference between Hashing vectorizer and Count vectorizer, when each to be used?

  11. 11

    What is the difference between the following two declarations and when should they be used

  12. 12

    what is the difference between HashSet and Set and when should each one be used?

  13. 13

    What is the difference between MinusEqual (-=) and PlusEqual (+=) as used in event declaration c#

  14. 14

    What is the difference between "params" and "array parameter" and when should it be used?

  15. 15

    What is the difference between "used space", "size" and "size on disk"?

  16. 16

    What is the difference between the single and double quotes used with the trap command?

  17. 17

    What is the difference between "views" path and the path used in express.static?

  18. 18

    What's the difference between "as?", "as!", and "as"?

  19. 19

    What is the difference in operation between . and ^ and ^(.*)$?

  20. 20

    What is the difference between .// and //* in XPath?

  21. 21

    What is the difference between = and => for a variable?

  22. 22

    What is difference between "?" and "!" in Swift?

  23. 23

    What is the difference between `.` and `#` in the JavaDoc?

  24. 24

    CoffeeScript, What is the difference between => and ->

  25. 25

    What is the difference between * and *|* in CSS?

  26. 26

    What is the difference between $* and $@

  27. 27

    What's the difference between '$(this)' and 'this'?

  28. 28

    What the difference between != and =/= in chisel?

  29. 29

    What is the difference between '&&' and '&' in Ruby

HotTag

Archive