Why Gas Used By Txn is different when invoking the same function in the same smart contract?

0 votes

I have seen some transactions in etherscan.io.But I have found that even invoking the same function in the same smart contract, the gas used by txn are different.I try to found that maybe the input data result in it.Really?

Sep 24, 2018 in Blockchain by sabby
• 4,350 points
18 views

1 answer to this question.

0 votes

The input data might be different, but also the state stored in the smart contract might be different (and change e.g. the number of times a loop iterates). Also, if storing nonzero data in a state variable that previously held zero data, or vice versa, will change the gas usage. For example, a simple function that toggles a boolean variable will not use the same amount of gas on any two consecutive calls.

answered Sep 24, 2018 by Christine
• 15,790 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

Why is it downloading the blocks when I am trying to deploy the ethereum private network?

Once you have installed the Ethereum wallet, ...READ MORE

answered May 3, 2018 in Blockchain by Shashank
• 10,330 points
32 views
0 votes
1 answer

Where are the transaction details of a smart contract is written in Ethereum?

First ques:where in the blockchain is a ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,330 points
38 views
0 votes
1 answer

Why RLP encoding is used in Ethereum?

RLP is intended to be a highly ...READ MORE

answered Aug 4, 2018 in Blockchain by Mohini
• 260 points
58 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
126 views
0 votes
1 answer
+3 votes
2 answers

How to run ethereumjs using Node.JS

You need to install testrpc globally on ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,620 points
128 views
+1 vote
1 answer