0

I'm testing a system to store a small amount of data on the blockchain using a contract.

So I've some js using web3.js to make a call to a contract function that mutates states.

I obtained, using specific params, a cost of

  gasUsed: 85359

It's accetable, actually 0.000085359 eth are 0.013 euros (0.014 us dollars).

But I am on rinkeby.

Will the gasUsed be the same every day, every call, (using same params value of course) and, more important, will the gasUsed be same if I deploy the contract on main network and call the function to main network?

2

Overall fee you pay for a transaction, counted in fiat currency (EUR, USD, etc), depends on the following things:

  1. Ether to fiat exchange rate (may change over time, out of your control)
  2. Gas price (set by you, but miners may reject mining your transaction if gas price is too low)
  3. Actual gas used, this depends on what smart contract actually do and how optimal smart contract's code is.
  4. Also actual gas used depends on the gas schedule, that is hardcoded into Ethereum node software and usually considered immutable, however gas schedule may be changed via hard forks.

So basically fee may change over time, and in general you cannot control this. Let me know if you need more details about any of the factors listed.

  • I know that exchange rate changes, but I am asking a different thing: if contract is not modified and call is repeated (and always is succesfully done), the gasUsed is every time the same? – realtebo Jan 22 at 16:35
  • Short answer is: not necessary. Contract behavior, and thus gas usage may depend on many different things, not only on call parameters. Also, gas schedule may be changed via hard forks. – Mikhail Vladimirov Jan 22 at 21:01

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.