I'm trying to deploy a smart contract that uses Oraclize on the Ropsten TestNet using truffle. It seems that deploy the Oraclize api contract (imported by my contract) it's too costly and causes the deploy to fail with the error "the contract code couldn't be stored please check your gas amount". If i increase the gas limit i get the error "Error: Exceeds block gas limit".

What can i do? There is a way to deploy only my contract without the oraclize contract?

Thank you in advance

  • At least for me, this error is usually due to errors in code and nothing to do with gas. Maybe you can post your code and state exactly where the problem is? Jul 17 '18 at 8:31

First solution : try to set gas limit at 4700000 witha gas price of 40 or more.

second solution (depends on your contract model) :

Deploy the oracle contract separately then create a new instance in your contract to interact with it as follow let's assume you want to use : https://github.com/oraclize/ethereum-examples/blob/master/solidity/DieselPrice.sol

in your contract

contract Mycontract{
Fuelprice o;
constructor(address Oracleaddress_){

function getfuelPriceUSD() public view returns (uint){
      return o.fuelPriceUSD();


of course you need to define in your codefile an abstract representation of the called contract. using this example you can fed the oracle address to your contract when you deploy it (if you're using truffle you can do it using deployment file)

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.