[Ethereum] Contract exceeds block gas limit

gas-limit

I have a fairly complex contract that inherits from a bunch of other contracts, like the OpenZeppelin ERC20 libs and Oraclize libs.

When I go to deploy it onto testnet in Remix or Mist, it says that the gas required is 6.3 million, which exceeds the limit. Is there a way that I can deploy it piecemeal, or do I simply have to make the contract less complex?

If I don't use Oraclize, gas required goes down to 4 million and I can deploy the contact successfully.

Best Answer

Here's a tutorial and general approach:

https://dappsforbeginners.wordpress.com/tutorials/interactions-between-contracts/

You split the contract into several contracts, and you can create references to "parent" contracts, such as:

contract referencedContract {   
  function fn() {}
}

contract referencingContract{

  // create reference to contract
  referencedContract m = referencedContract(referencedContractAddress);

  // call referenced contract method
  m.fn();
}
Related Topic