2

I have a question do these if conditions take same gas mean if condition body with && or || with simple if condition with true or false? Same gas or different? How can I check that?

if(msg.sender != MainFounderAddress && msg.sender != teamAddress && msg.sender != adviserAddress && msg.sender != FounderAddress1 && msg.sender != FounderAddress2 && msg.sender != FounderAddress3 && msg.sender != FounderAddress4){}

Other

if(true){}
2

Good rule of thumb: if there is logic or computations, it requires gas.

I tested the following contracts:

pragma solidity ^0.4.18;
contract SimpleStore {
  function testGas1(uint a, uint b) {
    if (a == 1 && b == 2) {

    }
  }

  function testGas2(uint a, uint b) {
    if (true) {

    }
  }
}

Running the testGas1 gives "cumulativeGasUsed": 21918

Running the testGas2 gives "cumulativeGasUsed": 21876

You can do the same tests here: https://ethfiddle.com/AmIZSh7AnY

| improve this answer | |

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.