Sponsored:   Color Platform: Decentralized App Store - Special Airdrop For Everyone (~17 Sep), Register NOW!
 Latest 12 txns

TxHash Age From To Value [TxFee]
0x716df69f7d81f4d8ef46499cc5c92ac341652913c93e46d65b0f13a434544fef113 days 12 hrs ago0x43962eb774aabc910a779e8214d0a155a631ef09  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.001297685
0x7a1e63335e51137df7a0148d39fd0375b48c6edb27a5ae24ef91118edffbb33e123 days 2 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.001 Ether0.0049818048
0x5729b8c26f89e63b870fdb4a6ecce695bea0d946fa0e2800efd0ff0ce444872e123 days 3 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.0072181857
0xeaa089defdebca67c2df38f3b248c8cd7c776d15545ed3ad38ac827591308565123 days 3 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.00436604
0xb43df1ea5796b17504adc00b38364b44adf7b367089f1b577a5eb3b56b0a1401123 days 5 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.0071331486
0x03401944e7297cf5d7e6887d499df7ad72d6272eee330fbc505db859efa8b44b123 days 5 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.001 Ether0.004897398
0xe6df97f0386e4f20abb3f6d377cca102272e04c42540063c9636d441efece57b123 days 5 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.00043745
0x1c550a27ca5c7765c2ba56b46d9b6be7ec4df70c03b7a468fdeb7dcff519c41a123 days 5 hrs ago0x24ca24838462e3b1c573ad68707948fa3ae2541c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.001 Ether0.0044376
0x5d54565dd095797ca8a8092b8587b75961e71d0a76f54c462d55c8ce4b219659151 days 2 hrs ago0x009bb5e9fcf28e5e601b7d0e9e821da6365d0a9c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.000219415
0xd2b7a7733faa7b13709ca82644bad2edfafe1b111a9cfa7a6eeffbe0628d94c2160 days 7 hrs ago0x009bb5e9fcf28e5e601b7d0e9e821da6365d0a9c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.000309183
0xe4a99767ab5f12d76e557787ee1c2009baba95cfcb4709fde5a1c7508886f447160 days 7 hrs ago0x009bb5e9fcf28e5e601b7d0e9e821da6365d0a9c  IN   0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0 Ether0.0002207
0x1db9fb23c75892ced35e80540d53088be5e3721c256bd2cbf74fab014687a191160 days 7 hrs ago0x009bb5e9fcf28e5e601b7d0e9e821da6365d0a9c  IN    Contract Creation0 Ether0.007660884
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
 Latest 25 Internal Txns, Click Here To View More View All
ParentTxHash Block Age From To Value
0x4a0514f01e16a654ef1fe10aaec8a4417e85b77b7d531ce456cafb53080976bf5765818105 days 18 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.66107454653497984 Ether
0x4a0514f01e16a654ef1fe10aaec8a4417e85b77b7d531ce456cafb53080976bf5765818105 days 18 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.66107454653497984 Ether
0x4094c22db62f450c7b68e5cc7c7eed91fa666ea60a0e26260242bee2aedee74e5765774105 days 18 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.186676515347020352 Ether
0x4094c22db62f450c7b68e5cc7c7eed91fa666ea60a0e26260242bee2aedee74e5765774105 days 18 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.186676515347020352 Ether
0x9b0eca1ed336d45c1492ac9f45342faa7255a3c379e9ec76c65daa391f35b2415765770105 days 18 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.182967520508033088 Ether
0x9b0eca1ed336d45c1492ac9f45342faa7255a3c379e9ec76c65daa391f35b2415765770105 days 18 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.182967520508033088 Ether
0x1fc73af9da671c01ade33ed7255f425b0f6cb2f7bf1b66c67166db9e3f579cec5765767105 days 18 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.182967520508033088 Ether
0x1fc73af9da671c01ade33ed7255f425b0f6cb2f7bf1b66c67166db9e3f579cec5765767105 days 18 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.182967520508033088 Ether
0xd830c6afa5767712b3e8f0c0de977db05c0d871f2358e3bd461355f615cd52b55765764105 days 18 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.183009045849287296 Ether
0xd830c6afa5767712b3e8f0c0de977db05c0d871f2358e3bd461355f615cd52b55765764105 days 18 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.183009045849287296 Ether
0x060d7dd34de740abc0be429e309e91d2b48902ac7f4313abf89ba790b386524f5765750105 days 19 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.449794163809403136 Ether
0x060d7dd34de740abc0be429e309e91d2b48902ac7f4313abf89ba790b386524f5765750105 days 19 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.449794163809403136 Ether
0x4b622f97b37e39e50a118ff6ffc53ed54db709775f74d2e0657f8cf18ecaf4fc5765462105 days 20 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3152.431020453800580096 Ether
0x4b622f97b37e39e50a118ff6ffc53ed54db709775f74d2e0657f8cf18ecaf4fc5765462105 days 20 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b2.431020453800580096 Ether
0x78674cb9271ddba47fb82fc667465a15310560dce4e00722cc56b84a0190b05b5765434105 days 20 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3152.419559967104530432 Ether
0x78674cb9271ddba47fb82fc667465a15310560dce4e00722cc56b84a0190b05b5765434105 days 20 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b2.419559967104530432 Ether
0x19cf064569206b8358956e7667ee7f83c4d0c67773c61d2478cd042427293ecb5765017105 days 22 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3157.586890644590614528 Ether
0x19cf064569206b8358956e7667ee7f83c4d0c67773c61d2478cd042427293ecb5765017105 days 22 hrs ago0xf42441bc7d324887a6a290ab220d71f29de69d880xcf1cc6ed5b653def7417e3fa93992c3ffe49139b7.586890644590614528 Ether
0xd421de9f42025e82392af8dbf0fa7b93cab995b041133782ada0717a1915cf7b5764659105 days 23 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3151 Ether
0xd421de9f42025e82392af8dbf0fa7b93cab995b041133782ada0717a1915cf7b5764659105 days 23 hrs ago0xc6725ae749677f21e4d8f85f41cfb6de49b9db290xcf1cc6ed5b653def7417e3fa93992c3ffe49139b1 Ether
0x4997068bdfc5a84df19a1bb3a4bb13514a4e9e235a14ae7c7800b781d17644045764656105 days 23 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.001149641844041723 Ether
0x4997068bdfc5a84df19a1bb3a4bb13514a4e9e235a14ae7c7800b781d17644045764656105 days 23 hrs ago0xc6725ae749677f21e4d8f85f41cfb6de49b9db290xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0.001149641844041723 Ether
0xa98c1b494127cc73091087cb480b4b3a2618ec4b14478d4f8e4cdd12569dc5b05764655105 days 23 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3151 Ether
0xa98c1b494127cc73091087cb480b4b3a2618ec4b14478d4f8e4cdd12569dc5b05764655105 days 23 hrs ago0xc6725ae749677f21e4d8f85f41cfb6de49b9db290xcf1cc6ed5b653def7417e3fa93992c3ffe49139b1 Ether
0x7328157c267b5172a5fab418731b5b684a5c19c17ce999dba955e5e36004dbdc5764655105 days 23 hrs ago0xcf1cc6ed5b653def7417e3fa93992c3ffe49139b0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce3150.0001 Ether
[ Download CSV Export  ] 
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity), NestedArrayFunctionCallDecoder (medium-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: BancorQuickConverter
Compiler Text: v0.4.18+commit.9cf6e910
Optimization Enabled: Yes
Runs (Optimiser):  500



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.18;

/*
    Utilities & Common Modifiers
*/
contract Utils {
    /**
        constructor
    */
    function Utils() public {
    }

    // verifies that an amount is greater than zero
    modifier greaterThanZero(uint256 _amount) {
        require(_amount > 0);
        _;
    }

    // validates an address - currently only checks that it isn't null
    modifier validAddress(address _address) {
        require(_address != address(0));
        _;
    }

    // verifies that the address is different than this contract address
    modifier notThis(address _address) {
        require(_address != address(this));
        _;
    }

    // Overflow protected math functions

    /**
        @dev returns the sum of _x and _y, asserts if the calculation overflows

        @param _x   value 1
        @param _y   value 2

        @return sum
    */
    function safeAdd(uint256 _x, uint256 _y) internal pure returns (uint256) {
        uint256 z = _x + _y;
        assert(z >= _x);
        return z;
    }

    /**
        @dev returns the difference of _x minus _y, asserts if the subtraction results in a negative number

        @param _x   minuend
        @param _y   subtrahend

        @return difference
    */
    function safeSub(uint256 _x, uint256 _y) internal pure returns (uint256) {
        assert(_x >= _y);
        return _x - _y;
    }

    /**
        @dev returns the product of multiplying _x by _y, asserts if the calculation overflows

        @param _x   factor 1
        @param _y   factor 2

        @return product
    */
    function safeMul(uint256 _x, uint256 _y) internal pure returns (uint256) {
        uint256 z = _x * _y;
        assert(_x == 0 || z / _x == _y);
        return z;
    }
}

/*
    ERC20 Standard Token interface
*/
contract IERC20Token {
    // these functions aren't abstract since the compiler emits automatically generated getter functions as external
    function name() public view returns (string) {}
    function symbol() public view returns (string) {}
    function decimals() public view returns (uint8) {}
    function totalSupply() public view returns (uint256) {}
    function balanceOf(address _owner) public view returns (uint256) { _owner; }
    function allowance(address _owner, address _spender) public view returns (uint256) { _owner; _spender; }

    function transfer(address _to, uint256 _value) public returns (bool success);
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
    function approve(address _spender, uint256 _value) public returns (bool success);
}

/*
    Owned contract interface
*/
contract IOwned {
    // this function isn't abstract since the compiler emits automatically generated getter functions as external
    function owner() public view returns (address) {}

    function transferOwnership(address _newOwner) public;
    function acceptOwnership() public;
}

/*
    Provides support and utilities for contract ownership
*/
contract Owned is IOwned {
    address public owner;
    address public newOwner;

    event OwnerUpdate(address indexed _prevOwner, address indexed _newOwner);

    /**
        @dev constructor
    */
    function Owned() public {
        owner = msg.sender;
    }

    // allows execution by the owner only
    modifier ownerOnly {
        assert(msg.sender == owner);
        _;
    }

    /**
        @dev allows transferring the contract ownership
        the new owner still needs to accept the transfer
        can only be called by the contract owner

        @param _newOwner    new contract owner
    */
    function transferOwnership(address _newOwner) public ownerOnly {
        require(_newOwner != owner);
        newOwner = _newOwner;
    }

    /**
        @dev used by a new owner to accept an ownership transfer
    */
    function acceptOwnership() public {
        require(msg.sender == newOwner);
        OwnerUpdate(owner, newOwner);
        owner = newOwner;
        newOwner = address(0);
    }
}

/*
    Token Holder interface
*/
contract ITokenHolder is IOwned {
    function withdrawTokens(IERC20Token _token, address _to, uint256 _amount) public;
}

/*
    We consider every contract to be a 'token holder' since it's currently not possible
    for a contract to deny receiving tokens.

    The TokenHolder's contract sole purpose is to provide a safety mechanism that allows
    the owner to send tokens that were sent to the contract by mistake back to their sender.
*/
contract TokenHolder is ITokenHolder, Owned, Utils {
    /**
        @dev constructor
    */
    function TokenHolder() public {
    }

    /**
        @dev withdraws tokens held by the contract and sends them to an account
        can only be called by the owner

        @param _token   ERC20 token contract address
        @param _to      account to receive the new amount
        @param _amount  amount to withdraw
    */
    function withdrawTokens(IERC20Token _token, address _to, uint256 _amount)
        public
        ownerOnly
        validAddress(_token)
        validAddress(_to)
        notThis(_to)
    {
        assert(_token.transfer(_to, _amount));
    }
}

/*
    Ether Token interface
*/
contract IEtherToken is ITokenHolder, IERC20Token {
    function deposit() public payable;
    function withdraw(uint256 _amount) public;
    function withdrawTo(address _to, uint256 _amount) public;
}

/*
    Smart Token interface
*/
contract ISmartToken is IOwned, IERC20Token {
    function disableTransfers(bool _disable) public;
    function issue(address _to, uint256 _amount) public;
    function destroy(address _from, uint256 _amount) public;
}

/*
    EIP228 Token Converter interface
*/
contract ITokenConverter {
    function convertibleTokenCount() public view returns (uint16);
    function convertibleToken(uint16 _tokenIndex) public view returns (address);
    function getReturn(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount) public view returns (uint256);
    function convert(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256);
    // deprecated, backward compatibility
    function change(IERC20Token _fromToken, IERC20Token _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256);
}

/*
    Bancor Gas Price Limit interface
*/
contract IBancorGasPriceLimit {
    function gasPrice() public view returns (uint256) {}
    function validateGasPrice(uint256) public view;
}

/*
    Bancor Quick Converter interface
*/
contract IBancorQuickConverter {
    function convert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable returns (uint256);
    function convertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public payable returns (uint256);
    function convertForPrioritized(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) public payable returns (uint256);
}

/*
    The BancorQuickConverter contract provides allows converting between any token in the 
    bancor network in a single transaction.

    A note on conversion paths -
    Conversion path is a data structure that's used when converting a token to another token in the bancor network
    when the conversion cannot necessarily be done by single converter and might require multiple 'hops'.
    The path defines which converters should be used and what kind of conversion should be done in each step.

    The path format doesn't include complex structure and instead, it is represented by a single array
    in which each 'hop' is represented by a 2-tuple - smart token & to token.
    In addition, the first element is always the source token.
    The smart token is only used as a pointer to a converter (since converter addresses are more likely to change).

    Format:
    [source token, smart token, to token, smart token, to token...]
*/
contract BancorQuickConverter is IBancorQuickConverter, TokenHolder {
    address public signerAddress = 0x0; // verified address that allows conversions with higher gas price
    IBancorGasPriceLimit public gasPriceLimit; // bancor universal gas price limit contract
    mapping (address => bool) public etherTokens;   // list of all supported ether tokens
    mapping (bytes32 => bool) public conversionHashes;

    /**
        @dev constructor
    */
    function BancorQuickConverter() public {
    }

    // validates a conversion path - verifies that the number of elements is odd and that maximum number of 'hops' is 10
    modifier validConversionPath(IERC20Token[] _path) {
        require(_path.length > 2 && _path.length <= (1 + 2 * 10) && _path.length % 2 == 1);
        _;
    }

    /*
        @dev allows the owner to update the gas price limit contract address

        @param _gasPriceLimit   address of a bancor gas price limit contract
    */
    function setGasPriceLimit(IBancorGasPriceLimit _gasPriceLimit)
        public
        ownerOnly
        validAddress(_gasPriceLimit)
        notThis(_gasPriceLimit)
    {
        gasPriceLimit = _gasPriceLimit;
    }

    /*
        @dev allows the owner to update the signer address

        @param _signerAddress    new signer address
    */
    function setSignerAddress(address _signerAddress)
        public
        ownerOnly
        validAddress(_signerAddress)
        notThis(_signerAddress)
    {
        signerAddress = _signerAddress;
    }

    /**
        @dev allows the owner to register/unregister ether tokens

        @param _token       ether token contract address
        @param _register    true to register, false to unregister
    */
    function registerEtherToken(IEtherToken _token, bool _register)
        public
        ownerOnly
        validAddress(_token)
        notThis(_token)
    {
        etherTokens[_token] = _register;
    }

    /**
        @dev verifies that the signer address is trusted by recovering 
        the address associated with the public key from elliptic 
        curve signature, returns zero on error.
        notice that the signature is valid only for one conversion
        and expires after the give block.

        @return true if the signer is verified
    */
    function verifyTrustedSender(uint256 _block, address _addr, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s) private returns(bool) {
        bytes32 hash = sha256(_block, tx.gasprice, _addr, _nonce);

        // checking that it is the first conversion with the given signature
        // and that the current block number doesn't exceeded the maximum block
        // number that's allowed with the current signature
        require(!conversionHashes[hash] && block.number <= _block);

        // recovering the signing address and comparing it to the trusted signer
        // address that was set in the contract
        bytes memory prefix = "\x19Ethereum Signed Message:\n32";
        bytes32 prefixedHash = keccak256(prefix, hash);
        bool verified = ecrecover(prefixedHash, _v, _r, _s) == signerAddress;

        // if the signer is the trusted signer - mark the hash so that it can't
        // be used multiple times
        if (verified)
            conversionHashes[hash] = true;
        return verified;
    }

/**
        @dev converts the token to any other token in the bancor network by following
        a predefined conversion path and transfers the result tokens to a target account
        note that the converter should already own the source tokens

        @param _path        conversion path, see conversion path format above
        @param _amount      amount to convert from (in the initial source token)
        @param _minReturn   if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero
        @param _for         account that will receive the conversion result

        @return tokens issued in return
    */
    function convertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public payable returns (uint256) {
        return convertForPrioritized(_path, _amount, _minReturn, _for, 0x0, 0x0, 0x0, 0x0, 0x0);
    }

    /**
        @dev converts the token to any other token in the bancor network
        by following a predefined conversion path and transfers the result
        tokens to a target account.
        this specific version of the function also allows the verified signer
        to bypass the universal gas price limit.
        note that the converter should already own the source tokens

        @param _path        conversion path, see conversion path format above
        @param _amount      amount to convert from (in the initial source token)
        @param _minReturn   if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero
        @param _for         account that will receive the conversion result

        @return tokens issued in return
    */
    function convertForPrioritized(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for, uint256 _block, uint256 _nonce, uint8 _v, bytes32 _r, bytes32 _s)
        public
        payable
        validConversionPath(_path)
        returns (uint256)
    {
        if (_v == 0x0 && _r == 0x0 && _s == 0x0)
            gasPriceLimit.validateGasPrice(tx.gasprice);
        else
            require(verifyTrustedSender(_block, _for, _nonce, _v, _r, _s));

        // if ETH is provided, ensure that the amount is identical to _amount and verify that the source token is an ether token
        IERC20Token fromToken = _path[0];
        require(msg.value == 0 || (_amount == msg.value && etherTokens[fromToken]));

        IERC20Token toToken;

        // if ETH was sent with the call, the source is an ether token - deposit the ETH in it
        // otherwise, we assume we already have the tokens
        if (msg.value > 0)
            IEtherToken(fromToken).deposit.value(msg.value)();
        
        (_amount, toToken) = convertByPath(_path, _amount, _minReturn, fromToken);

        // finished the conversion, transfer the funds to the target account
        // if the target token is an ether token, withdraw the tokens and send them as ETH
        // otherwise, transfer the tokens as is
        if (etherTokens[toToken])
            IEtherToken(toToken).withdrawTo(_for, _amount);
        else
            assert(toToken.transfer(_for, _amount));

        return _amount;
    }

    function convertByPath(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, IERC20Token _fromToken) private returns (uint256, IERC20Token) {
        ISmartToken smartToken;
        IERC20Token toToken;
        ITokenConverter converter;

        // iterate over the conversion path
        uint256 pathLength = _path.length;

        for (uint256 i = 1; i < pathLength; i += 2) {
            smartToken = ISmartToken(_path[i]);
            toToken = _path[i + 1];
            converter = ITokenConverter(smartToken.owner());

            // if the smart token isn't the source (from token), the converter doesn't have control over it and thus we need to approve the request
            if (smartToken != _fromToken)
                ensureAllowance(_fromToken, converter, _amount);

            // make the conversion - if it's the last one, also provide the minimum return value
            _amount = converter.change(_fromToken, toToken, _amount, i == pathLength - 2 ? _minReturn : 1);
            _fromToken = toToken;
        }
        return (_amount, toToken);
    }

    /**
        @dev claims the caller's tokens, converts them to any other token in the bancor network
        by following a predefined conversion path and transfers the result tokens to a target account
        note that allowance must be set beforehand

        @param _path        conversion path, see conversion path format above
        @param _amount      amount to convert from (in the initial source token)
        @param _minReturn   if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero
        @param _for         account that will receive the conversion result

        @return tokens issued in return
    */
    function claimAndConvertFor(IERC20Token[] _path, uint256 _amount, uint256 _minReturn, address _for) public returns (uint256) {
        // we need to transfer the tokens from the caller to the converter before we follow
        // the conversion path, to allow it to execute the conversion on behalf of the caller
        // note: we assume we already have allowance
        IERC20Token fromToken = _path[0];
        assert(fromToken.transferFrom(msg.sender, this, _amount));
        return convertFor(_path, _amount, _minReturn, _for);
    }

    /**
        @dev converts the token to any other token in the bancor network by following
        a predefined conversion path and transfers the result tokens back to the sender
        note that the converter should already own the source tokens

        @param _path        conversion path, see conversion path format above
        @param _amount      amount to convert from (in the initial source token)
        @param _minReturn   if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero

        @return tokens issued in return
    */
    function convert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public payable returns (uint256) {
        return convertFor(_path, _amount, _minReturn, msg.sender);
    }

    /**
        @dev claims the caller's tokens, converts them to any other token in the bancor network
        by following a predefined conversion path and transfers the result tokens back to the sender
        note that allowance must be set beforehand

        @param _path        conversion path, see conversion path format above
        @param _amount      amount to convert from (in the initial source token)
        @param _minReturn   if the conversion results in an amount smaller than the minimum return - it is cancelled, must be nonzero

        @return tokens issued in return
    */
    function claimAndConvert(IERC20Token[] _path, uint256 _amount, uint256 _minReturn) public returns (uint256) {
        return claimAndConvertFor(_path, _amount, _minReturn, msg.sender);
    }

    /**
        @dev utility, checks whether allowance for the given spender exists and approves one if it doesn't

        @param _token   token to check the allowance in
        @param _spender approved address
        @param _value   allowance amount
    */
    function ensureAllowance(IERC20Token _token, address _spender, uint256 _value) private {
        // check if allowance for the given amount already exists
        if (_token.allowance(this, _spender) >= _value)
            return;

        // if the allowance is nonzero, must reset it to 0 first
        if (_token.allowance(this, _spender) != 0)
            assert(_token.approve(_spender, 0));

        // approve the new allowance
        assert(_token.approve(_spender, _value));
    }
}

    Contract ABI  
[{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_register","type":"bool"}],"name":"registerEtherToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_signerAddress","type":"address"}],"name":"setSignerAddress","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_path","type":"address[]"},{"name":"_amount","type":"uint256"},{"name":"_minReturn","type":"uint256"},{"name":"_for","type":"address"},{"name":"_block","type":"uint256"},{"name":"_nonce","type":"uint256"},{"name":"_v","type":"uint8"},{"name":"_r","type":"bytes32"},{"name":"_s","type":"bytes32"}],"name":"convertForPrioritized","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"signerAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"withdrawTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"etherTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"conversionHashes","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gasPriceLimit","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_path","type":"address[]"},{"name":"_amount","type":"uint256"},{"name":"_minReturn","type":"uint256"},{"name":"_for","type":"address"}],"name":"claimAndConvertFor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_path","type":"address[]"},{"name":"_amount","type":"uint256"},{"name":"_minReturn","type":"uint256"}],"name":"claimAndConvert","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_path","type":"address[]"},{"name":"_amount","type":"uint256"},{"name":"_minReturn","type":"uint256"},{"name":"_for","type":"address"}],"name":"convertFor","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_gasPriceLimit","type":"address"}],"name":"setGasPriceLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_path","type":"address[]"},{"name":"_amount","type":"uint256"},{"name":"_minReturn","type":"uint256"}],"name":"convert","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_prevOwner","type":"address"},{"indexed":true,"name":"_newOwner","type":"address"}],"name":"OwnerUpdate","type":"event"}]

  Contract Creation Code Switch To Opcodes View
606060405260028054600160a060020a0319169055341561001f57600080fd5b60008054600160a060020a033316600160a060020a03199091161790556111858061004b6000396000f3006060604052600436106100d75763ffffffff60e060020a60003504166302ef521e81146100dc578063046dc166146101025780631134269a146101215780635b7633d0146101ac5780635e35359e146101db57806379ba5097146102035780638077ccf71461021657806389e63a60146102495780638da5cb5b1461025f578063961a929c14610272578063b1e9932b14610285578063c7ba24bc146102ea578063c98fefed14610340578063d4ee1d901461039a578063e33051dd146103ad578063f2fde38b146103cc578063f3898a97146103eb575b600080fd5b34156100e757600080fd5b610100600160a060020a03600435166024351515610436565b005b341561010d57600080fd5b610100600160a060020a03600435166104b3565b61019a60046024813581810190830135806020818102016040519081016040528093929190818152602001838360200280828437509496505084359460208101359450600160a060020a036040820135169350606081013592506080810135915060ff60a0820135169060c08101359060e00135610534565b60405190815260200160405180910390f35b34156101b757600080fd5b6101bf6107e8565b604051600160a060020a03909116815260200160405180910390f35b34156101e657600080fd5b610100600160a060020a03600435811690602435166044356107f7565b341561020e57600080fd5b6101006108e5565b341561022157600080fd5b610235600160a060020a0360043516610973565b604051901515815260200160405180910390f35b341561025457600080fd5b610235600435610988565b341561026a57600080fd5b6101bf61099d565b341561027d57600080fd5b6101bf6109ac565b341561029057600080fd5b61019a6004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650508435946020810135945060400135600160a060020a031692506109bb915050565b34156102f557600080fd5b61019a600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610a7a92505050565b61019a6004602481358181019083013580602081810201604051908101604052809392919081815260200183836020028082843750949650508435946020810135945060400135600160a060020a03169250610a90915050565b34156103a557600080fd5b6101bf610aac565b34156103b857600080fd5b610100600160a060020a0360043516610abb565b34156103d757600080fd5b610100600160a060020a0360043516610b3c565b61019a600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610b9e92505050565b60005433600160a060020a0390811691161461044e57fe5b81600160a060020a038116151561046457600080fd5b8230600160a060020a031681600160a060020a03161415151561048657600080fd5b5050600160a060020a03919091166000908152600460205260409020805460ff1916911515919091179055565b60005433600160a060020a039081169116146104cb57fe5b80600160a060020a03811615156104e157600080fd5b8130600160a060020a031681600160a060020a03161415151561050357600080fd5b50506002805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60008060008b6002815111801561054d57506015815111155b801561056657506002815181151561056157fe5b066001145b151561057157600080fd5b60ff8716158015610580575085155b801561058a575084155b156105f057600354600160a060020a0316636b4dff1f3a60405160e060020a63ffffffff84160281526004810191909152602401600060405180830381600087803b15156105d757600080fd5b6102c65a03f115156105e857600080fd5b505050610609565b6105fe898b8a8a8a8a610bac565b151561060957600080fd5b8c60008151811061061657fe5b9060200190602002015192503415806106515750348c1480156106515750600160a060020a03831660009081526004602052604090205460ff165b151561065c57600080fd5b60003411156106b85782600160a060020a031663d0e30db0346040518263ffffffff1660e060020a0281526004016000604051808303818588803b15156106a257600080fd5b6125ee5a03f115156106b357600080fd5b505050505b6106c48d8d8d86610db1565b600160a060020a038116600090815260046020526040902054919d50925060ff16156107575781600160a060020a031663205c28788b8e60405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401600060405180830381600087803b151561073e57600080fd5b6102c65a03f1151561074f57600080fd5b5050506107d7565b81600160a060020a031663a9059cbb8b8e60006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156107b457600080fd5b6102c65a03f115156107c557600080fd5b5050506040518051905015156107d757fe5b50999b9a5050505050505050505050565b600254600160a060020a031681565b60005433600160a060020a0390811691161461080f57fe5b82600160a060020a038116151561082557600080fd5b82600160a060020a038116151561083b57600080fd5b8330600160a060020a031681600160a060020a03161415151561085d57600080fd5b85600160a060020a031663a9059cbb868660006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b15156108ba57600080fd5b6102c65a03f115156108cb57600080fd5b5050506040518051905015156108dd57fe5b505050505050565b60015433600160a060020a0390811691161461090057600080fd5b600154600054600160a060020a0391821691167f343765429aea5a34b3ff6a3785a98a5abb2597aca87bfbb58632c173d585373a60405160405180910390a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b60046020526000908152604090205460ff1681565b60056020526000908152604090205460ff1681565b600054600160a060020a031681565b600354600160a060020a031681565b600080856000815181106109cb57fe5b90602001906020020151905080600160a060020a03166323b872dd33308860006040516020015260405160e060020a63ffffffff8616028152600160a060020a0393841660048201529190921660248201526044810191909152606401602060405180830381600087803b1515610a4157600080fd5b6102c65a03f11515610a5257600080fd5b505050604051805190501515610a6457fe5b610a7086868686610a90565b9695505050505050565b6000610a88848484336109bb565b949350505050565b6000610aa3858585858580808080610534565b95945050505050565b600154600160a060020a031681565b60005433600160a060020a03908116911614610ad357fe5b80600160a060020a0381161515610ae957600080fd5b8130600160a060020a031681600160a060020a031614151515610b0b57600080fd5b50506003805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60005433600160a060020a03908116911614610b5457fe5b600054600160a060020a0382811691161415610b6f57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b6000610a8884848433610a90565b600080610bb7611147565b60008060028b3a8c8c6000604051602001526040518085815260200184815260200183600160a060020a0316600160a060020a03166c0100000000000000000000000002815260140182815260200194505050505060206040518083038160008661646e5a03f11515610c2957600080fd5b5050604051805160008181526005602052604090205490955060ff161590508015610c5457508a4311155b1515610c5f57600080fd5b6040805190810160405280601c81526020017f19457468657265756d205369676e6564204d6573736167653a0a333200000000815250925082846040518083805190602001908083835b60208310610cc85780518252601f199092019160209182019101610ca9565b6001836020036101000a03801982511681845116179092525050509190910192835250506020019050604051908190039020600254909250600160a060020a03166001838a8a8a6040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f11515610d6e57600080fd5b505060206040510351600160a060020a03161490508015610da3576000848152600560205260409020805460ff191660011790555b9a9950505050505050505050565b60008060008060008060008a519150600190505b81811015610f2b578a8181518110610dd957fe5b9060200190602002015194508a8160010181518110610df457fe5b90602001906020020151935084600160a060020a0316638da5cb5b6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515610e4657600080fd5b6102c65a03f11515610e5757600080fd5b5050506040518051935050600160a060020a0385811690891614610e8057610e8088848c610f3c565b82600160a060020a0316635e5144eb89868d600287038614610ea3576001610ea5565b8d5b60006040516020015260405160e060020a63ffffffff8716028152600160a060020a03948516600482015292909316602483015260448201526064810191909152608401602060405180830381600087803b1515610f0257600080fd5b6102c65a03f11515610f1357600080fd5b50505060405180519a50939750879350600201610dc5565b509799919850909650505050505050565b8083600160a060020a031663dd62ed3e308560006040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b1515610f9c57600080fd5b6102c65a03f11515610fad57600080fd5b50505060405180519050101515610fc357611142565b82600160a060020a031663dd62ed3e308460006040516020015260405160e060020a63ffffffff8516028152600160a060020a03928316600482015291166024820152604401602060405180830381600087803b151561102257600080fd5b6102c65a03f1151561103357600080fd5b50505060405180511590506110c25782600160a060020a031663095ea7b3836000806040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561109f57600080fd5b6102c65a03f115156110b057600080fd5b5050506040518051905015156110c257fe5b82600160a060020a031663095ea7b3838360006040516020015260405160e060020a63ffffffff8516028152600160a060020a0390921660048301526024820152604401602060405180830381600087803b151561111f57600080fd5b6102c65a03f1151561113057600080fd5b50505060405180519050151561114257fe5b505050565b602060405190810160405260008152905600a165627a7a72305820abb4ad32d5803007b5c27aae1610ecc6c20ee7c13cbd92cc0e04614d52d632ab0029

   Swarm Source:
bzzr://abb4ad32d5803007b5c27aae1610ecc6c20ee7c13cbd92cc0e04614d52d632ab

 

View All
Block Age transaction Difficulty Reward
View All
Block Age UncleNumber Difficulty GasUsed Reward
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.