When i am going to deploy this code its give error:The contract code couldn't be stored, please check your gas amount.

Solidity CODE:

pragma solidity ^0.4.0;

import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

contract OraclizeFetch is usingOraclize{

string public ETHXBT;

event newOraclizeQuery(string description);
event price(string price);

function OraclizeFetch() payable{
    oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);

function __callback(bytes32 myid, string result, bytes proof) {
    if (msg.sender != oraclize_cbAddress()) throw;
    ETHXBT = result;

function update() payable {
    if (oraclize.getPrice("URL") > this.balance) {
        newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
    } else {
        newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
        oraclize_query(60, "URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0");


My genesis.json file:

{ "nonce": "0xdeadbeefdeadbeef", "timestamp": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "extraData": "0x0", "gasLimit": "0x8000000", "difficulty": "0x400", "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x3333333333333333333333333333333333333333", "alloc": {



  • Hi, Thomas from Oraclize here, on what network are you trying to run this on? Is it a private testnet or what else? Commented Feb 20, 2017 at 17:29
  • Hi Thomas,We are using private network.
    – Anurag
    Commented Feb 21, 2017 at 4:54
  • if you want to use Oraclize within a private chain context, you need to set up and execute the Oraclize ethereum-bridge there. You will find instructions in that repository. If you need any further assistance, feel free to come to our dedicated gitter support channel. Commented Feb 21, 2017 at 11:23

1 Answer 1


Here's a working example of your code, testable with Oraclize in a browser:


Some issues were that you were trying to call oraclize through oraclize.getPrice before that variable was even initialized and set. To do this you need to either pre-initialize it somehow, one way to pre-initialize is calling oraclize_setProof(proofType_NONE) to get results without proofs, or use the internal getPrice function provided by Oraclize in the API which is oraclize_getPrice.

Secondly, in another iteration of the contract you asked us about, you were setting the gas to include to 50M, yet you weren't doing a price check of that allotted gas amount, and it's a very high and unrealistic gas cost amount especially for this query, which will cost several ether with such a high gas amount.

This contract should work fine on your privatenet, just ensure the OAR is set correctly for it.

  • Hi, I have the same problem, but the contract is a bit more complicated. The thing is that everything works, and Truffle migrates successfully when I'm commenting the __callback() function. Do you know anything about that?
    – Ruham
    Commented Oct 24, 2018 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.