0

I have been created a smart contract (ERC20 implantation). The contract run great om testrpc, ropsten and rinkeby but i want to use it in a private network. When the contract deployed in the private network some of the functions get the "Gas requirement of function high: infinite in remix" warning and when i try to communicate with the contract the transaction always fails. Is there a reason that a contract will work perfectly on one network but not on the other? I set a very high "gasLimit" in my genesis block

Private network genesis file:

{
"config": {
"chainId": 51190,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},

"alloc"      : {},
"coinbase"   : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x400",
"extraData"  : "",
"gasLimit"   : "0xffffd8",
"nonce"      : "0x0000000000000042",
"mixhash"    : 
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : 
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp"  : "0x00"
}

Solidity code:

myToken.sol:

constructor (address _interfaceData) 
  public
  {
   interfaceData = DataContract(_interfaceData);
  }

function transfer(address _to, uint256 _value) public returns (bool) {
    if (interfaceData.isTransferWhitelistOnly()) {
      require(isUserAllowedToTransfer(msg.sender));
    }
    return super.transfer(_to, _value);
 }

BasicToken.sol:

function transfer(address _to, uint256 _value) public returns (bool) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);
    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    emit Transfer(msg.sender, _to, _value);
    return true;
}

DataContract.sol:

bool public isTransferWhitelistOnly;

Any help will be appreciated

  • Provide the code. We can't tell you what's wrong if you don't show us what does not work properly. – Florian Castelain Sep 27 '18 at 16:19
  • You do not have byzantinum opcodes enabled and since new versions of the solc compiler use such opcodes your contracts will fail in your private testnet. – Ismael Sep 30 '18 at 16:16
1

Without details it's not possible to know that this is "the" problem, but it's a suspect.

The Byzantium fork is a protocol change. Consequently, there is incompatibility between compiled code beyond a certain version, and blockchain nodes running an older protocol. Your private network may be composed of nodes running an older protocol than your compiled code expects.

In summary, function response format has evolved, so things need to be using the same grammar on both sides or there will be trouble.

You say the code runs on various public networks so it's safe to conclude it expects the latest node.

Hope it helps.

  • Hi Rob. I'm using geth version 1.8.16-stable, Sloc version: 0.4.25-develop.2018.6.21+commit.32f2db78.Linux.g++. I Added the code used to transfer. (the function that fail on my private network). I think these are the latest versions isn't it? Thanks – Hadar Keidar Sep 30 '18 at 7:10

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.