Here is my smart contract that uses oraclize to buy bitcoin with ether.
pragma solidity ^0.4.0;
import "https://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol";
contract BuyBitcoin is usingOraclize {
address owner;
string public temp;
function BuyBitcoin() {
owner = msg.sender;
OAR = OraclizeAddrResolverI(0x51efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa);
update();
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
result;
}
function update() payable {
oraclize_query("URL", "json(https://www.shapeshift.io/shift).orderId", '{"withdrawal":"3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy", "pair":"eth_btc" , "amount" : 1000}');
}
function kill(){
if (msg.sender == owner) suicide(msg.sender);
}
}
Update :
I'm sending 0.01 ether as part of transaction
I can compile the contract but when I attempt to run the update function I receive 'VM Exception: invalid JUMP'
Have I omitted something with my contract ?
and using Javascript VM :
Have I missed a step ?
I'm using metamask and have ether in account :
update()
call? The first oraclize_query is free, but the others come at a cost (even when simulated)oraclize_query
does charge from the contract balance the correct amount, according to the Oraclize API pricing: docs.oraclize.it/#pricing . That said, you can send like 0.01 ether along and any change will stay in your contract balance