I'm using oraclize to get the price feed using this code:
import "oraclizeAPI.sol";
contract PriceFeed is usingOraclize{
uint public BTCUSD;
function PriceFeed(){
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
update(0); // first check at contract creation
}
function __callback(bytes32 myid, string result, bytes proof) {
if (msg.sender != oraclize_cbAddress()) throw;
BTCUSD = parseInt(result, 2); // save it as $ cents
// The following line is what I do which ends up with the error message
//MyContract.BTCUSD = BTCUSD;
update(360); // schedule another check in 60 seconds
}
function update(uint delay){
oraclize_query(delay, "URL",
"json(https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD).USD");
}
}
Now I have the second contract in the same file that has a variable called BTCUSD. I need to update that variable when I get callback from oraclize. I've tried multiple methods, writing a setter/getter method on both contracts, using MyContract.BTCUSD = BTCUSD style assignments but I get errors.
contract MyContract {
uint public BTCUSD;
}
I'm using linter on atom and these are the errors I get depending on how I try to assign the value:
Member "BTCUSD" not found or not visible after argument-dependent lookup in type(contract MyContract)
MyContractInterface(mycontract_address).setterMethodforBTCUSD(BTCUSD)
. My suggestion is still to use Oraclize straight away from MyContract, unless you really need to keep the two contracts separated.