1

I have a simple contract:

pragma solidity ^0.4.4;

contract Counter {
  uint public count;

  function Counter() {
    count = 0;
  }

  function inc() {
    count++;
  }
}

And some javascript that loads web3 in the usual way:

window.onload = function () {
  if (typeof window.web3 !== 'undefined') {
    window.web3 = new Web3(window.web3.currentProvider)
  } else {
    window.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
  }
}

I then call the inc method in the contract (I load it using truffle-contract).

If I have MetaMask enabled and connected to the testrpc, this costs 41614 of gas, but if I disable MetaMask and use the HttpProvider, then it costs 26614.

Is this behavior expected? If it is, why does it happen?

  • 1
    I think you should add a truffle tag, just to make sure Tim Coulter finds it. I work on MetaMask, and this behavior makes no sense to me, I suspect a testrpc bug. – DanF Nov 1 '17 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.