1

https://github.com/christianlundkvist/simple-multisig/blob/master/contracts/SimpleMultiSig.sol

I'm deploying the above contract recursively and I find that the gasUsed varies by specifically 12 gas. The array of owners stays the same length between deploys, however the addresses change. Could the change in addresses change effect the computation cost?

gasUsed: 1391022 gasUsed: 1391010

  constructor(uint threshold_, address[] owners_, uint chainId) public {
    require(owners_.length <= 10 && threshold_ <= owners_.length && threshold_ > 0);

    address lastAdd = address(0);
    for (uint i = 0; i < owners_.length; i++) {
      require(owners_[i] > lastAdd);
      isOwner[owners_[i]] = true;
      lastAdd = owners_[i];
    }
    ownersArr = owners_;
    threshold = threshold_;

    DOMAIN_SEPARATOR = keccak256(abi.encode(EIP712DOMAINTYPE_HASH,
                                            NAME_HASH,
                                            VERSION_HASH,
                                            chainId,
                                            this,
                                            SALT));
  }

1

You have to pay some gas for every byte in data field of a transaction.

After Istanbul fork new cost are given in EIP 2028

  • 16 gas a non-zero byte (it was 68 gas)
  • 4 gas a zero byte (it didn't change)

So if your addresses have a zero byte the transaction will be 12 gas cheaper.

  • Ok thats interesting. So generating an address with more 0 bytes is slightly more efficient? – arete Nov 15 '19 at 9:55
  • @arete Yes, some tokens like TrueUSD 0x0000000000085d4780B73119b644AE5ecd22b376 use that as an advantage. – Ismael Nov 15 '19 at 14:25

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.