Skip to content
Verified contractPartial

ShapeShift

Address0x0facdfdefb42ef8e3d86a4abd32f8aee389df03b
Balance

0 ETH

 

Transactions

2

 

Compiler

solc 0.1.6

 

Same code

Only this contract

 

Details

Compiler
solc 0.1.6+commit.d41f8b7c
Language
solidity
Optimization
Yes, 200 runs
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
506,655
Creation transaction
0x650e3661c7…d5b585cb61

ShapeShift.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
contract OraclizeI {
    address public cbAddress;
    function query(uint _timestamp, string _datasource, string _arg) returns (bytes32 _id);
    function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) returns (bytes32 _id);
    function getPrice(string _datasource) returns (uint _dsprice);
    function useCoupon(string _coupon);
    function setProofType(byte _proofType);
}

contract OraclizeAddrResolverI {
    function getAddress() returns (address _addr);
}

contract usingOraclize {
    OraclizeI oraclize;

    modifier oraclizeAPI {
        OraclizeAddrResolverI OAR = OraclizeAddrResolverI(0x1d11e5eae3112dbd44f99266872ff1d07c77dce8);
        oraclize = OraclizeI(OAR.getAddress());
        _
    }

    modifier coupon(string code) {
        OraclizeAddrResolverI OAR = OraclizeAddrResolverI(0x1d11e5eae3112dbd44f99266872ff1d07c77dce8);
        oraclize = OraclizeI(OAR.getAddress());
        oraclize.useCoupon(code);
        _
    }

    function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id) {
        return oraclize.query2.value(oraclize.getPrice(datasource))(0, datasource, arg1, arg2);
    }

    function oraclize_cbAddress() oraclizeAPI internal returns (address) {
        return oraclize.cbAddress();
    }
}

contract ShapeShift is usingOraclize {
    mapping (bytes32 => uint) public txns;
    address owner;

    event transferDone(address to, uint balance);
    event transferInProgress(string addr, string json);

    function ShapeShift() {
        owner = msg.sender;
    }

    function setOwner(address _owner) {
        if (msg.sender == owner) owner = _owner;
    }

    function parseAddr(string _a) internal returns (address) {
        bytes memory tmp = bytes(_a);
        uint160 iaddr = 0;
        uint160 b1;
        uint160 b2;
        for (uint i = 2; i < 2 + 2 * 20; i += 2) {
            iaddr *= 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;
            iaddr += (b1 * 16 + b2);
        }
        return address(iaddr);
    }

    function __callback(bytes32 myid, string result) {
        if (msg.sender != oraclize_cbAddress()) throw;
        address addr = parseAddr(result);
        uint amount = txns[myid];
        txns[myid] = 0;
        addr.send(amount);
        transferDone(addr, amount);
    }

    function transfer(string coin, string addr) coupon("HACKinDUBLIN") returns (bytes32) {
        bytes memory c = bytes(coin);
        bytes memory a = bytes(addr);
        bytes memory json;
        if (c[0] != 0x62 || c[1] != 0x74 || c[2] != 0x63) {
            msg.sender.send(msg.value);
            return;
        }
        if (a.length > 35) {
            msg.sender.send(msg.value);
            return;
        }
        string memory pre = "{\"pair\":\"eth_btc\",\"withdrawal\":\"";
        bytes memory bpre = bytes(pre);
        uint i;
        uint k;
        for (i = 0; i < bpre.length; i++) json[i] = bpre[i];
        for (k = 0; k < a.length; k++) json[i++] = a[k];
        json[i++] = 0x22;
        json[i++] = 0x7d;
        json[i++] = 0;
        string memory s = string(json);
        transferInProgress(addr, s);
        bytes32 id = oraclize_query("URL", "json(https://shapeshift.io/shift).deposit", s);
        txns[id] = msg.value;
        return id;
    }

    function kill() {
        if (msg.sender == owner) suicide(msg.sender);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.