[Ethereum] How to import a smart contract on github in a truffle contract

oraclizesoliditytruffletruffle-compiletruffle-migration

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?

Best Answer

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.

Related Topic