Sponsored:   Temco - Join the Largest VC Backed ICO on the Bitcoin Network! TEMCO KYC Whitelist Starts Now!!
Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 1 txn
Misc:
Address Watch: Add To Watch List
Contract Creator: 0x063ac191d1df3d3bfb2255df567fa3d235703954at txn 0xc2940a9cd07434cdfd5a42373daae0b728d1c55e158ff9eb4ef53390ae61f500
[ Download CSV Export  ] 
 Internal Transactions as a result of Contract Execution
View All
ParentTxHash Block Age From To Value
Warning: The Compiled Contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) SolidityCompiler Bugs.

Contract Source Code Verified (Exact Match)
Contract Name: p2ptokenexchange
Compiler Text: v0.4.24+commit.e67f0147
Optimization Enabled: No
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.24;

   contract TCallee {

// Connection to other ERC20 smart contracts
 function transferFrom(address _from, address _to, uint256 _value) external returns (bool success){}

}
 
interface  ptopinterface  {
       //new exchange function
       function newExchange (address smart1, uint256 amount1, address two2, address smart2, uint256 amount2) external payable returns(uint exchangeId);
       //new exchange event
       event NewExchange (uint exchangeId, address one1, address indexed smart1, uint256 amount1, address two2, address indexed smart2, uint256 amount2);
      //get the exchange details
       function getExchange (uint _Id) external view returns (address _one1,address _smart1,uint256 _amount1, address _two2, address _smart2, uint256 _amount2, bool); 
       //cancek an exchange by one of the parties
       function cancelExchange (uint exchangeId) external payable returns (bool success);
       //cancel exchange event
       event CancelExchange (uint exchangeId);
       // do exchange function
       function doExchange (uint exchangeId) external payable returns (bool success);
       //do exchange event
       event DoExchange (uint exchangeId);
    
}

contract p2ptokenexchange is ptopinterface{
    
     address constant atokenaddress=0xf0B3BA2Dd4B2ef75d727A4045d7fBcc415B77bF0;//mainnet
    
    struct exchange {
        address one1;
        address smart1;
        uint256 amount1;
        address two2;
        address smart2;
        uint256 amount2;
        bool DealDone;
    }
    
    uint counter= 0;
    //mapping by counter 
    mapping (uint => exchange) exchanges;
    
    event NewExchange (uint exchangeId, address one1, address indexed smart1, uint256 amount1, address two2, address indexed smart2, uint256 amount2);
    event CancelExchange (uint exchangeId);
    event DoExchange (uint exchangeId);
    
    function newExchange (address smart1, uint256 amount1, address two2, address smart2, uint256 amount2) external payable returns(uint exchangeId) {
        require(msg.value>=206000000);
        exchangeId = counter;
        exchanges[exchangeId]=exchange(msg.sender,smart1,amount1,two2,smart2,amount2,false);
        counter +=1;
        if (exchanges[exchangeId].smart1==address(0)) {
        require(msg.value>=exchanges[exchangeId].amount1+206000000);
        uint256 amountTosend=(msg.value-exchanges[exchangeId].amount1);
        payether(atokenaddress, amountTosend);
        } else {
           require(payether(atokenaddress, msg.value)==true);   
        }
        emit NewExchange (exchangeId,msg.sender,smart1,amount1,two2,smart2,amount2);
        return exchangeId;
    }
    
    function getExchange (uint _Id) external view returns (address _one1,address _smart1,uint256 _amount1, address _two2, address _smart2, uint256 _amount2, bool){
        return (exchanges[_Id].one1, exchanges[_Id].smart1, exchanges[_Id].amount1, exchanges[_Id].two2, exchanges[_Id].smart2, exchanges[_Id].amount2, exchanges[_Id].DealDone);
    }
    
    function cancelExchange (uint exchangeId) external payable returns (bool success) {
         //re-entry defense
        bool locked;
        require(!locked);
        locked = true;
        require(msg.value>=206000000);
        if (msg.sender==exchanges[exchangeId].one1) {
        } else {
        require(msg.sender==exchanges[exchangeId].two2);
        require(msg.sender!=0x1111111111111111111111111111111111111111);    
        }
        
        exchanges[exchangeId].DealDone=true;
        if (exchanges[exchangeId].smart1==address(0)) {
            require(payether(exchanges[exchangeId].one1, exchanges[exchangeId].amount1)==true);
        }
         require(payether(atokenaddress, msg.value)==true);
         emit CancelExchange(exchangeId);
         locked=false;
            return true;
                }
    
    function doExchange (uint exchangeId) external payable returns (bool success) {
         //re-entry defense
        bool _locked;
        require(!_locked);
        _locked = true;
        require(msg.value>=206000000);
        if (exchanges[exchangeId].two2!=0x1111111111111111111111111111111111111111){
        require(msg.sender==exchanges[exchangeId].two2);
        } else {
        exchanges[exchangeId].two2=msg.sender;    
        }
   
        require(exchanges[exchangeId].DealDone==false);
        require(exchanges[exchangeId].amount2>0);
       
        if (exchanges[exchangeId].smart2==address(0)) {
            
            require(msg.value >=206000000 + exchanges[exchangeId].amount2);
            require(payether(atokenaddress, msg.value - exchanges[exchangeId].amount2)==true);
        } else {
            require(payether(atokenaddress, msg.value)==true);
        }
       //party 2 move tokens to party 1
        if (exchanges[exchangeId].smart2==address(0)) {
            require(payether(exchanges[exchangeId].one1,exchanges[exchangeId].amount2)==true);
        } else {
            TCallee c= TCallee(exchanges[exchangeId].smart2);
            bool x=c.transferFrom(exchanges[exchangeId].two2, exchanges[exchangeId].one1, exchanges[exchangeId].amount2);
             require(x==true);
        }
      
      //party 1 moves tokens to party 2
      if (exchanges[exchangeId].smart1==address(0)) {
         require(payether(exchanges[exchangeId].two2, exchanges[exchangeId].amount1)==true);
         
    } else {
         TCallee d= TCallee(exchanges[exchangeId].smart1);
            bool y=d.transferFrom(exchanges[exchangeId].one1, exchanges[exchangeId].two2, exchanges[exchangeId].amount1);
             require(y==true);
      
      
    }
    exchanges[exchangeId].DealDone=true;
    emit DoExchange (exchangeId); 
    _locked=false;
    return true;
}

function payether(address payto, uint256 amountTo) internal returns(bool){
    payto.transfer(amountTo);
    return true;
}
}

    Contract ABI  
[{"constant":true,"inputs":[{"name":"_Id","type":"uint256"}],"name":"getExchange","outputs":[{"name":"_one1","type":"address"},{"name":"_smart1","type":"address"},{"name":"_amount1","type":"uint256"},{"name":"_two2","type":"address"},{"name":"_smart2","type":"address"},{"name":"_amount2","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"exchangeId","type":"uint256"}],"name":"cancelExchange","outputs":[{"name":"success","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"smart1","type":"address"},{"name":"amount1","type":"uint256"},{"name":"two2","type":"address"},{"name":"smart2","type":"address"},{"name":"amount2","type":"uint256"}],"name":"newExchange","outputs":[{"name":"exchangeId","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"exchangeId","type":"uint256"}],"name":"doExchange","outputs":[{"name":"success","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"exchangeId","type":"uint256"},{"indexed":false,"name":"one1","type":"address"},{"indexed":true,"name":"smart1","type":"address"},{"indexed":false,"name":"amount1","type":"uint256"},{"indexed":false,"name":"two2","type":"address"},{"indexed":true,"name":"smart2","type":"address"},{"indexed":false,"name":"amount2","type":"uint256"}],"name":"NewExchange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"exchangeId","type":"uint256"}],"name":"CancelExchange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"exchangeId","type":"uint256"}],"name":"DoExchange","type":"event"}]

  Contract Creation Code Switch To Opcodes View
60806040526000805534801561001457600080fd5b50611415806100246000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630b9d5847146100675780635d3d08a814610186578063966a360c146101be578063fcb5d44d1461025c575b600080fd5b34801561007357600080fd5b5061009260048036038101908080359060200190929190505050610294565b604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018215151515815260200197505050505050505060405180910390f35b6101a4600480360381019080803590602001909291905050506103e6565b604051808215151515815260200191505060405180910390f35b610246600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506106b3565b6040518082815260200191505060405180910390f35b61027a60048036038101908080359060200190929190505050610ac3565b604051808215151515815260200191505060405180910390f35b60008060008060008060006001600089815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008a815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008b815260200190815260200160002060020154600160008c815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008d815260200190815260200160002060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008e815260200190815260200160002060050154600160008f815260200190815260200160002060060160009054906101000a900460ff169650965096509650965096509650919395979092949650565b600080801515156103f657600080fd5b60019050630c474f80341015151561040d57600080fd5b6001600084815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561047c5761053c565b6001600084815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156104ec57600080fd5b73111111111111111111111111111111111111111173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415151561053b57600080fd5b5b600180600085815260200190815260200160002060060160006101000a81548160ff021916908315150217905550600073ffffffffffffffffffffffffffffffffffffffff166001600085815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561063e576001151561062f6001600086815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166001600087815260200190815260200160002060020154611396565b151514151561063d57600080fd5b5b6001151561066073f0b3ba2dd4b2ef75d727a4045d7fbcc415b77bf034611396565b151514151561066e57600080fd5b7ff7938541c4ede6919846ec21c27ba385bb90ece165e3df8bc6de548f747825af836040518082815260200191505060405180910390a1600090506001915050919050565b600080630c474f8034101515156106c957600080fd5b600054915060e0604051908101604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1681526020018781526020018673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff168152602001848152602001600015158152506001600084815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506040820151816002015560608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060808201518160040160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555090505060016000808282540192505081905550600073ffffffffffffffffffffffffffffffffffffffff166001600084815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614156109a857630c474f80600160008481526020019081526020016000206002015401341015151561096957600080fd5b6001600083815260200190815260200160002060020154340390506109a273f0b3ba2dd4b2ef75d727a4045d7fbcc415b77bf082611396565b506109d9565b600115156109ca73f0b3ba2dd4b2ef75d727a4045d7fbcc415b77bf034611396565b15151415156109d857600080fd5b5b8373ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f8f48278bd004b8d2fb249f9c00fb53c5506dbd28bda744062fcc33c1700bdbe084338a8a89604051808681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019550505050505060405180910390a38191505095945050505050565b60008060008060008084151515610ad957600080fd5b60019450630c474f803410151515610af057600080fd5b73111111111111111111111111111111111111111173ffffffffffffffffffffffffffffffffffffffff166001600089815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610be4576001600088815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610bdf57600080fd5b610c3a565b336001600089815260200190815260200160002060030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b600015156001600089815260200190815260200160002060060160009054906101000a900460ff161515141515610c7057600080fd5b60006001600089815260200190815260200160002060050154111515610c9557600080fd5b600073ffffffffffffffffffffffffffffffffffffffff166001600089815260200190815260200160002060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610d78576001600088815260200190815260200160002060050154630c474f80013410151515610d2b57600080fd5b60011515610d6573f0b3ba2dd4b2ef75d727a4045d7fbcc415b77bf0600160008b8152602001908152602001600020600501543403611396565b1515141515610d7357600080fd5b610da9565b60011515610d9a73f0b3ba2dd4b2ef75d727a4045d7fbcc415b77bf034611396565b1515141515610da857600080fd5b5b600073ffffffffffffffffffffffffffffffffffffffff166001600089815260200190815260200160002060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610e815760011515610e6e600160008a815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008b815260200190815260200160002060050154611396565b1515141515610e7c57600080fd5b611064565b6001600088815260200190815260200160002060040160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1693508373ffffffffffffffffffffffffffffffffffffffff166323b872dd600160008a815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008b815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008c8152602001908152602001600020600501546040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561101357600080fd5b505af1158015611027573d6000803e3d6000fd5b505050506040513d602081101561103d57600080fd5b810190808051906020019092919050505092506001151583151514151561106357600080fd5b5b600073ffffffffffffffffffffffffffffffffffffffff166001600089815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141561113c5760011515611129600160008a815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008b815260200190815260200160002060020154611396565b151514151561113757600080fd5b61131f565b6001600088815260200190815260200160002060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691508173ffffffffffffffffffffffffffffffffffffffff166323b872dd600160008a815260200190815260200160002060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008b815260200190815260200160002060030160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160008c8152602001908152602001600020600201546040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156112ce57600080fd5b505af11580156112e2573d6000803e3d6000fd5b505050506040513d60208110156112f857600080fd5b810190808051906020019092919050505090506001151581151514151561131e57600080fd5b5b600180600089815260200190815260200160002060060160006101000a81548160ff0219169083151502179055507f1384dc1dc7ef9f53981c1fd4df5fe6218bcf4a0fe21507e05c3357b662b3bab2876040518082815260200191505060405180910390a160009450600195505050505050919050565b60008273ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156113de573d6000803e3d6000fd5b5060019050929150505600a165627a7a72305820621769ccbd3e041fcf0efab92d63c152ab414219470e87e0c6d1bd7ceb3fb9260029

   Swarm Source:
bzzr://621769ccbd3e041fcf0efab92d63c152ab414219470e87e0c6d1bd7ceb3fb926

 

View All
Block Age transaction Difficulty GasUsed 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.