I am using a smart contract that imports and uses the Oraclize contract at https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.4.sol, if in the remix editor this can be done as follows:

import "http://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol";

However if I do this with a contract I want to compile with Truffle there is this error:

Could not find http://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol from any sources;

I have tried simply copying and pasting the entire Oraclize contract into my Truffle contract file, but this results in an "The contract code couldn't be stored, please check your gas amount" error regardless of how much gas I use (even the absolute maximum) - my guess is because the Oraclize contract is over 1000 lines of code long.

How should this be done?

2 Answers 2


I copy-pasted the Oraclize contract into my Truffle and I was able to migrate the contracts to Kovan by running a Parity node locally. Were you running an account that had Ether on it?

Looking at the Truffle docs, there is an EthPM registry that they suggest to install dependencies using: http://truffleframework.com/docs/getting_started/packages-ethpm. On EthPM, I see there is a Oraclize package. I tried truffle install oraclize, but it didn't seem to do anything. I am not sure if this feature is properly working.

Edit: truffle install oraclize indeed is working and puts the contracts into a directory called installed_contracts.


The other thing you can do to use Oraclize with Truffle is just copying the http://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol file locally and importing that file in the contract where you want to use it.

Truffle needs the contract to be named the same as the file in order to compile it, so you will need to rename the Oraclize file to UsingOraclize.sol.

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.