smart contract gas cost

152 Views Asked by At

I am running a smart contract on the test network(rinkeby and ropsten) 'n' number of times, with it, I am getting a varying gas usage for some functions. My understanding was the gas cost is 'constant' based on the operation of that function. I can understand the time variation, but no not sure about varying gas usage. For some function it is constant, but for some, it has a slight variation. Is it normal, shall I ignore the variation - any thoughts, please?

2

There are 2 best solutions below

0
On

I have also noticed the same. May be it also depends on computation power used i.e. the input we are passing. Suppose if we are passing much larger values as input to a function than the computation power will be much more than small values, which in turns variable gas use.

0
On

Please refer to this answer on ethereum stackexchange

Also, just a lil advice ethereum.stackexchange.com is better place than stackoverflow to ask specifically ethereum related questions you will get better reach, more experts and quicker answers there.