Oraclize demo that asks ShapeShift for an ETH-to-BTC deposit address and parses it onchain: the building block of a stop-loss.
Key Facts
Description
One of three StopLoss contracts Oraclize deployed in 2015 to show a contract driving an exchange. update() asks Oraclize to POST to ShapeShift's sendamount API for a 0.2 ETH to BTC conversion paying out to a fixed Bitcoin address. When Oraclize calls back with the deposit address ShapeShift issued, the contract converts the hex string into an Ethereum address and stores it. Funds sent to that address would then be converted to BTC, which is the mechanism behind an automated stop-loss. The source was reconstructed and reproduces the deployed runtime byte for byte with soljson v0.1.6, optimizer off.
Source Verified
Exact runtime match, soljson v0.1.6+commit.d41f8b7c, optimizer on, fresh compiler process. Source StopLoss_0xaa2035b8.sol in the proof folder.
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
contract OraclizeI {
function query(uint _timestamp, string _datasource, string _arg1, string _arg2) returns (bytes32 _id);
function getPrice(string _datasource) returns (uint _dsprice);
function cb_address() returns (address _cbAddress);
}
contract OraclizeAddrResolverI {
function getAddress() returns (address _addr);
}
contract StopLoss {
address public shapeshift;
OraclizeI oraclize = OraclizeI(OraclizeAddrResolverI(0x1d11e5eae3112dbd44f99266872ff1d07c77dce8).getAddress());
function update() {
oraclize.query(0, "URL", "json(https://shapeshift.io/sendamount).success.deposit", '{"pair": "eth_btc", "amount": "0.2", "withdrawal": "1AAcCo21EUc1jbocjssSQDzLna9Vem2UN5"}');
}
function kill(){
suicide(msg.sender);
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize.cb_address()) throw;
bytes memory tmp = bytes(result);
uint160 ishapeshift = 0;
uint160 b1;
uint160 b2;
for (uint i=2; i<2+2*20; i+=2){
ishapeshift *= 256;
b1 = uint160(tmp[i]);
b2 = uint160(tmp[i+1]);
if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87;
else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48;
if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87;
else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48;
ishapeshift += (b1*16+b2);
}
shapeshift = address(ishapeshift);
}
function StopLoss() {
}
}External Links
Related contracts
Target
Same deployerTarget contract.
0x9e0ae8...c9428eSeptember 17, 2015GetSet
Same deployerA minimal getter/setter proxy from the Oraclize team. set() forwards calls to a hardcoded target contract, get() returns constant 255.
0x77beac...7e96c2September 17, 2015SimpleStorage
Same deployerThe storage example rewired to send a wei and return a constant
0x7aa73b...46473bSeptember 17, 2015Controller
Same deployerController contract.
0x3c9492...e332e5September 17, 2015GetSet
Same deployerA 57-byte test contract: set() stores the transaction's ether value into storage slot 0, and get() reads it back.
0xe595e8...423530September 17, 2015GetSet
Same deployerA 57-byte test contract: set() stores the transaction's ether value into storage slot 0, and get() reads it back.
0xd17e9b...03b76aSeptember 17, 2015