4

I want to create my first transaction. There are several fields I need to fill in.

From ethdocs.org:

Transactions contain:

  • ...

  • STARTGAS value, representing the maximum number of computational steps the transaction execution is allowed to take

  • GASPRICE value, representing the fee the sender is willing to pay for gas. One unit of gas corresponds to the execution of one atomic instruction, i.e., a computational step.

STARTGAS:

  1. What value should I put in, if all I want is to send some ether from one EOA(externally owned account) to another? What's the minimum value of STARTGAS field? In other words, how many computational steps does one simple transaction, that is, without triggering a contract, require?
  2. What value should I put in, If I want to trigger a contract? Is it a common practice for a contract creator to provide information on how many computational steps their contract execution requires?
  3. Wouldn't it be less confusing if this field was called MAXSTEPS?

GASPRICE

  1. Does GASPRICE represent a price for one computational step or an overall price for all steps that the transaction may incur?
5

GASPRICE represents the amount in ether to be paid for one unit of GAS consumed.The thing to consider is that some miners could only accept transactions where the GASPRICE is over a certain value or they will prioritize transactions with the highest GASPRICE.

STARTGAS - for each Ethereum Virtual Machine operation an amount of gas units was assigned in version 1.0 by the development team. I dont know exactly if this could evolve or will stay the same. The values can be found here https://docs.google.com/spreadsheets/d/1m89CVujrQe5LAFJ8-YAUCcNK950dUzMQPMJBxRtGCqs/edit#gid=0.

For a simple transaction (so no smart contracts involved) you can approximate the gas cost here: http://ether.fund/tool/calculator.

For smart contracts you dont know in advance how much it will consume, but you specify the maximum amount of gas you are willing to spend. You pay upfront for the gas you specify. After the smart contract execution ends, if there is remaining gas then the corresponding ether will be refunded. So effectively what you pay is:

paidEther = gasUsed * gasPrice

This happens only if the specified gasUsed does not surpass the maximum gas amount specified in the beginning. Otherwise all modifications done in the contract execution are reverted but you don't get any ether back.

  • 1
    I get it now. Thank you, good sir! One quick question though. So, one transfer-value transaction(no data) costs 500 gas which is 5 finney (500gas*10 szabo), am I correct?(I used this table Gas Fees)? Then why are there posts saying that the minimun gas for one transaction is 21000 gas? – manidos Jul 7 '16 at 15:28
  • I also saw mentions that a minimum transaction would require 21000 gas. The thing to notice is that the 500 are like the starting point for each transaction. Then the gas spent for computation is added. For example from the same page: 5 gas paid for every byte of data or code for a transaction. – dragosb Jul 8 '16 at 7:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.