Sponsored:   Ubex.com - World roadshow: Seoul Sep 17-19, Singapore Sep 19-20, Dubai 18-23. Meet us!.
Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 17980 txns
 Latest 25 txns From a total of 17980 Transactions

TxHash Age From To Value [TxFee]
0x4147e4e540a460d8bb2bdc6c3b173d3f46029e9d8b3724677a8abec97e57485d3 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x5291fc7b926800412f9bca3f0cbc791b3a1c40513800388f1b97ab0710986b284 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x3b0e07d381a579d801751eb3b09194aea15403d5ca7d136af49a07dc264ece6e8 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0xe2260fa49da57642bda32e23157cba3cbacc315c4853196e55ad466de8ba588411 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0xe0adb8a065c9181778df805c852cc2bb3f23ce961c3483e9b4dc8ec273c0bc4713 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0001703298
0x709b33cccfffa74040ea5976b9c7cb6933fb8393892c32a3849752eb0833d24514 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x4fc32ae5a76e516ed0c456741f4354a1980a698fd3691160772e0c25ef7703c914 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x635305f29ea51823762cbfe99bac7635745523f688ac64dc366ab9e4070587a516 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0011310066
0x4beacd800e4197a800c6181e1e52f8d672967c2d9d0d3950abfb11664a100fa316 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x93c2020053a7b11344dd93415e2b9e64851dc26050cd9b0cf1dfd334d071e68e31 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110883
0x3ae76bc5b0838bd2d5d8f1f083cffe1c3a2f2c283dcba125427224015c91718833 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x7b60e52f78e0f79b9348f9adc54698e9fdf460b15ed332e3eb46d1abd480955234 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001330596
0x44b9250b4e884055b3c018d48be582f687e5a0f943be8201c48858529592be1e34 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x619959a77282ea722a870ce24beb5abb48a5133f9d0c100aab42f6dbf79390f436 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110883
0x86cd1208259844184db878d8e9ca0c4069fdb48ffb971e8f4e380dc7d756379c38 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x67c9212109fac4e011addf4b1f30a13ee146bfc51030953a5090b100207b8b4538 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x1227598a21f0834b464278eb09476c46e3b7d86ffc95f52c14fd28241476f1df41 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0xc40d7dd844e4df58dfeeef5cd96c96f17141bc82bae28bbc132b571f9d23c26546 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0xa33431414783f286daa2fb64a5eaf1b9a477f44b523b32f756c703176f4c5cd91 hr 8 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x6754ec021e19c3874019ba44faaf0eff342e905d3ee2ea85903b914283a30f831 hr 26 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110883
0xeb237e2a0f3207785a1654bfbccc5d9f5e2e5ad853156f600daf3a5598f83d511 hr 26 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001330596
0x1ca9475737576f71104bd4a563151eb7f8fc85c0b0333faa61dbc25e2e8b22de1 hr 26 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00133098
0x363e38fdda85ea321845e7ace9b8688cc9bf26496e1be88183ac731d577785061 hr 27 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001330596
0xb0f1d956e75dbd56a1630ec865666f55820a3107dbdb14219cc6777cd761ea861 hr 27 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001330596
0x00237438e76d683955f81a4839b51fe96bb1abf70e19a512ba882d28bee410941 hr 27 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0011531832
[ 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
0x635305f29ea51823762cbfe99bac7635745523f688ac64dc366ab9e4070587a5637808616 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4beacd800e4197a800c6181e1e52f8d672967c2d9d0d3950abfb11664a100fa3637808416 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x93c2020053a7b11344dd93415e2b9e64851dc26050cd9b0cf1dfd334d071e68e637802731 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x3ae76bc5b0838bd2d5d8f1f083cffe1c3a2f2c283dcba125427224015c917188637801833 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x7b60e52f78e0f79b9348f9adc54698e9fdf460b15ed332e3eb46d1abd4809552637801634 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x619959a77282ea722a870ce24beb5abb48a5133f9d0c100aab42f6dbf79390f4637800436 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x86cd1208259844184db878d8e9ca0c4069fdb48ffb971e8f4e380dc7d756379c637799938 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x1227598a21f0834b464278eb09476c46e3b7d86ffc95f52c14fd28241476f1df637798141 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x6754ec021e19c3874019ba44faaf0eff342e905d3ee2ea85903b914283a30f8363777981 hr 26 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xeb237e2a0f3207785a1654bfbccc5d9f5e2e5ad853156f600daf3a5598f83d5163777951 hr 26 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x1ca9475737576f71104bd4a563151eb7f8fc85c0b0333faa61dbc25e2e8b22de63777931 hr 26 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x363e38fdda85ea321845e7ace9b8688cc9bf26496e1be88183ac731d5777850663777911 hr 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xb0f1d956e75dbd56a1630ec865666f55820a3107dbdb14219cc6777cd761ea8663777881 hr 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x00237438e76d683955f81a4839b51fe96bb1abf70e19a512ba882d28bee4109463777861 hr 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xe70a4aa0f6f9246dac5e5943f07f33d2cd59991583a56bafd2f9f313fc30d82463777821 hr 28 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xf3e1271c383bcc48486ce2986fef7e5fecdda8fa3c79e8500a2489d4b70bde6163775832 hrs 16 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xee98bc200b63a9025db5e4ce63e0cfb1d1904174467ac40716658bcdffca103963775372 hrs 26 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x3a229eb4cee7c85a702f8d5d85a3d5029e9a0536b6d7cb44d22d5b5a5d497bec63775312 hrs 28 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x875cd1a7440a101b7df7720bfb08e7b0a542ab78731b47f92dabf2614c64c49463775272 hrs 29 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x6bf548fe998872b21d63cba46cdb3cd6d00c0b8bbcce1d622cc0fb30c405f3d363775232 hrs 30 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x06028e310d721a370a943dc3ae9f3ff2f3d39e51993c4c3440189f819263965a63775202 hrs 31 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xb34fb6cbfea3e28ca366983fd467e2e7ba0cd49fd2f8f11a3eac5b39ab5de40d63775172 hrs 32 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xf5362d8ba35c85b88a6711baab32a273d71b2db5ed128f21278ec13c1d16aee963775152 hrs 32 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xd7e1590d7e00be5c249241ffba0cbfdfa825239ca722c3e8963002453fedd5c563775132 hrs 33 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x51a02aa530874ba70efe146fd489e39ede78a30d5e61839d0e140aa4a67ae56563774832 hrs 41 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
[ Download CSV Export  ] 
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: KinguinVault
Compiler Text: v0.4.23+commit.124ca40d
Optimization Enabled: Yes
Runs (Optimiser):  200



  Contract Source Code   Find Similiar Contracts

pragma solidity ^0.4.23;

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;


  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);


  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() public {
    owner = msg.sender;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }

}

/*
 * ERC20 interface
 * see https://github.com/ethereum/EIPs/issues/20
 */
contract ERC20 {
  uint public totalSupply;
  function balanceOf(address who) constant returns (uint);
  function allowance(address owner, address spender) constant returns (uint);

  function transfer(address to, uint value) returns (bool ok);
  function transferFrom(address from, address to, uint value) returns (bool ok);
  function approve(address spender, uint value) returns (bool ok);
  event Transfer(address indexed from, address indexed to, uint value);
  event Approval(address indexed owner, address indexed spender, uint value);
}


contract ERC223 is ERC20 {
  function transfer(address to, uint value, bytes data) returns (bool ok);
  function transferFrom(address from, address to, uint value, bytes data) returns (bool ok);
}



/*
Base class contracts willing to accept ERC223 token transfers must conform to.

Sender: msg.sender to the token contract, the address originating the token transfer.
          - For user originated transfers sender will be equal to tx.origin
          - For contract originated transfers, tx.origin will be the user that made the tx that produced the transfer.
Origin: the origin address from whose balance the tokens are sent
          - For transfer(), origin = msg.sender
          - For transferFrom() origin = _from to token contract
Value is the amount of tokens sent
Data is arbitrary data sent with the token transfer. Simulates ether tx.data

From, origin and value shouldn't be trusted unless the token contract is trusted.
If sender == tx.origin, it is safe to trust it regardless of the token.
*/

contract ERC223Receiver {
  function tokenFallback(address _sender, address _origin, uint _value, bytes _data) returns (bool ok);
}







/**
 * Math operations with safety checks
 */
contract SafeMath {
  function safeMul(uint a, uint b) internal returns (uint) {
    uint c = a * b;
    assert(a == 0 || c / a == b);
    return c;
  }

  function safeDiv(uint a, uint b) internal returns (uint) {
    assert(b > 0);
    uint c = a / b;
    assert(a == b * c + a % b);
    return c;
  }

  function safeSub(uint a, uint b) internal returns (uint) {
    assert(b <= a);
    return a - b;
  }

  function safeAdd(uint a, uint b) internal returns (uint) {
    uint c = a + b;
    assert(c>=a && c>=b);
    return c;
  }

  function max64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a >= b ? a : b;
  }

  function min64(uint64 a, uint64 b) internal constant returns (uint64) {
    return a < b ? a : b;
  }

  function max256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a >= b ? a : b;
  }

  function min256(uint256 a, uint256 b) internal constant returns (uint256) {
    return a < b ? a : b;
  }

  /*function assert(bool assertion) internal {
    if (!assertion) {
      throw;
    }
  }*/
}


/**
 * Standard ERC20 token
 *
 * https://github.com/ethereum/EIPs/issues/20
 * Based on code by FirstBlood:
 * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
 */
contract StandardToken is ERC20, SafeMath {
  mapping(address => uint) balances;
  mapping (address => mapping (address => uint)) allowed;
  function transfer(address _to, uint _value) returns (bool success) {
    require(_to != address(0));
    require(_value <= balances[msg.sender]);
    balances[msg.sender] = safeSub(balances[msg.sender], _value);
    balances[_to] = safeAdd(balances[_to], _value);
    Transfer(msg.sender, _to, _value);
    return true;
  }
  function transferFrom(address _from, address _to, uint _value) returns (bool success) {
    var _allowance = allowed[_from][msg.sender];
    // Check is not needed because safeSub(_allowance, _value) will already throw if this condition is not met
    // if (_value > _allowance) throw;
    balances[_to] = safeAdd(balances[_to], _value);
    balances[_from] = safeSub(balances[_from], _value);
    allowed[_from][msg.sender] = safeSub(_allowance, _value);
    Transfer(_from, _to, _value);
    return true;
  }
  function balanceOf(address _owner) constant returns (uint balance) {
    return balances[_owner];
  }
  function approve(address _spender, uint _value) returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
  }
  function allowance(address _owner, address _spender) constant returns (uint remaining) {
    return allowed[_owner][_spender];
  }
}

contract KinguinKrowns is ERC223, StandardToken {
  address public owner;  // token owner adddres
  string public constant name = "PINGUINS";
  string public constant symbol = "PGS";
  uint8 public constant decimals = 18;
  // uint256 public totalSupply; // defined in ERC20 contract
		
  function KinguinKrowns() {
	owner = msg.sender;
    totalSupply = 100000000 * (10**18); // 100 mln
    balances[msg.sender] = totalSupply;
  } 
  
  /*
  //only do if call is from owner modifier
  modifier onlyOwner() {
    if (msg.sender != owner) throw;
    _;
  }*/
  
  //function that is called when a user or another contract wants to transfer funds
  function transfer(address _to, uint _value, bytes _data) returns (bool success) {
    //filtering if the target is a contract with bytecode inside it
    if (!super.transfer(_to, _value)) throw; // do a normal token transfer
    if (isContract(_to)) return contractFallback(msg.sender, _to, _value, _data);
    return true;
  }

  function transferFrom(address _from, address _to, uint _value, bytes _data) returns (bool success) {
    if (!super.transferFrom(_from, _to, _value)) throw; // do a normal token transfer
    if (isContract(_to)) return contractFallback(_from, _to, _value, _data);
    return true;
  }

  function transfer(address _to, uint _value) returns (bool success) {
    return transfer(_to, _value, new bytes(0));
  }

  function transferFrom(address _from, address _to, uint _value) returns (bool success) {
    return transferFrom(_from, _to, _value, new bytes(0));
  }

  //function that is called when transaction target is a contract
  function contractFallback(address _origin, address _to, uint _value, bytes _data) private returns (bool success) {
    ERC223Receiver receiver = ERC223Receiver(_to);
    return receiver.tokenFallback(msg.sender, _origin, _value, _data);
  }

  //assemble the given address bytecode. If bytecode exists then the _addr is a contract.
  function isContract(address _addr) private returns (bool is_contract) {
    // retrieve the size of the code on target address, this needs assembly
    uint length;
    assembly { length := extcodesize(_addr) }
    return length > 0;
  }
  
  // returns krown balance of given address 	
  function balanceOf(address _owner) constant returns (uint balance) {
    return balances[_owner];
  }
	
}

contract KinguinIco is SafeMath, ERC223Receiver {
  address constant public superOwner = 0xcEbb7454429830C92606836350569A17207dA857;
  address public owner;             // contract owner address
  address public api;               // address of api manager
  KinguinKrowns public krs;     // handler to KRS token contract
  
  // rounds data storage:
  struct IcoRoundData {
    uint rMinEthPayment;            // set minimum ETH payment
    uint rKrsUsdFixed;              // set KRS/USD fixed ratio for calculation of krown amount to be sent, 
    uint rKycTreshold;              // KYC treshold in EUR (needed for check whether incoming payment requires KYC/AML verified address)
    uint rMinKrsCap;                // minimum amount of KRS to be sent during a round
    uint rMaxKrsCap;                // maximum amount of KRS to be sent during a round
    uint rStartBlock;               // number of blockchain start block for a round
    uint rEndBlock;                 // number of blockchain end block for a round
    uint rEthPaymentsAmount;        // sum of ETH tokens received from participants during a round
    uint rEthPaymentsCount;         // counter of ETH payments during a round 
    uint rSentKrownsAmount;         // sum of ETH tokens received from participants during a round
    uint rSentKrownsCount;          // counter of KRS transactions during a round
    bool roundCompleted;            // flag whether a round has finished
  }
  mapping(uint => IcoRoundData) public icoRounds;  // table of rounds data: ico number, ico record
  
  mapping(address => bool) public allowedAdresses; // list of KYC/AML approved wallets: participant address, allowed/not allowed
  
  struct RoundPayments {            // structure for storing sum of payments
    uint round;
    uint amount;
  }
  // amount of payments from the same address during each round 
  //  (to catch multiple payments to check KYC/AML approvance): participant address, payments record
  mapping(address => RoundPayments) public paymentsFromAddress; 

  uint public ethEur;               // current EUR/ETH exchange rate (for AML check)
  uint public ethUsd;               // current ETH/USD exchange rate (sending KRS for ETH calc) 
  uint public krsUsd;               // current KRS/USD exchange rate (sending KRS for ETH calc)
  uint public rNo;                  // counter for rounds
  bool public icoInProgress;        // ico status flag
  bool public apiAccessDisabled;    // api access security flag
  
  event LogReceivedEth(address from, uint value, uint block); // publish an event about incoming ETH
  event LogSentKrs(address to, uint value, uint block); // publish an event about sent KRS

  // execution allowed only for contract superowner
  modifier onlySuperOwner() {
	require(msg.sender == superOwner);
    _;
  }

  // execution allowed only for contract owner
  modifier onlyOwner() {
	require(msg.sender == owner);
    _;
  }
  
  // execution allowed only for contract owner or api address
  modifier onlyOwnerOrApi() {
	require(msg.sender == owner || msg.sender == api);
    if (msg.sender == api && api != owner) {
      require(!apiAccessDisabled);
	}
    _;
  }
 
  function KinguinIco() {
    owner = msg.sender; // this contract owner
    api = msg.sender; // initially api address is the contract owner's address 
    krs = KinguinKrowns(0xdfb410994b66778bd6cc2c82e8ffe4f7b2870006); // KRS token 
  } 
 
  // receiving ETH and sending KRS
  function () payable {
    if(msg.sender != owner) { // if ETH comes from other than the contract owner address
      if(block.number >= icoRounds[rNo].rStartBlock && block.number <= icoRounds[rNo].rEndBlock && !icoInProgress) {
        icoInProgress = true;
      }  
      require(block.number >= icoRounds[rNo].rStartBlock && block.number <= icoRounds[rNo].rEndBlock && !icoRounds[rNo].roundCompleted); // allow payments only during the ico round
      require(msg.value >= icoRounds[rNo].rMinEthPayment); // minimum eth payment
	  require(ethEur > 0); // ETH/EUR rate for AML must be set earlier
	  require(ethUsd > 0); // ETH/USD rate for conversion to KRS
	  uint krowns4eth;
	  if(icoRounds[rNo].rKrsUsdFixed > 0) { // KRS has fixed ratio to USD
        krowns4eth = safeDiv(safeMul(safeMul(msg.value, ethUsd), uint(100)), icoRounds[rNo].rKrsUsdFixed);
	  } else { // KRS/USD is traded on exchanges
		require(krsUsd > 0); // KRS/USD rate for conversion to KRS
        krowns4eth = safeDiv(safeMul(safeMul(msg.value, ethUsd), uint(100)), krsUsd);
  	  }
      require(safeAdd(icoRounds[rNo].rSentKrownsAmount, krowns4eth) <= icoRounds[rNo].rMaxKrsCap); // krs cap per round

      if(paymentsFromAddress[msg.sender].round != rNo) { // on mappings all keys are possible, so there is no checking for its existence
        paymentsFromAddress[msg.sender].round = rNo; // on new round set to current round
        paymentsFromAddress[msg.sender].amount = 0; // zeroing amount on new round
      }   
      if(safeMul(ethEur, safeDiv(msg.value, 10**18)) >= icoRounds[rNo].rKycTreshold || // if payment from this sender requires to be from KYC/AML approved address
        // if sum of payments from this sender address requires to be from KYC/AML approved address
        safeMul(ethEur, safeDiv(safeAdd(paymentsFromAddress[msg.sender].amount, msg.value), 10**18)) >= icoRounds[rNo].rKycTreshold) { 
		require(allowedAdresses[msg.sender]); // only KYC/AML allowed address
      }

      icoRounds[rNo].rEthPaymentsAmount = safeAdd(icoRounds[rNo].rEthPaymentsAmount, msg.value);
      icoRounds[rNo].rEthPaymentsCount += 1; 
      paymentsFromAddress[msg.sender].amount = safeAdd(paymentsFromAddress[msg.sender].amount, msg.value);
      LogReceivedEth(msg.sender, msg.value, block.number);
      icoRounds[rNo].rSentKrownsAmount = safeAdd(icoRounds[rNo].rSentKrownsAmount, krowns4eth);
      icoRounds[rNo].rSentKrownsCount += 1;
      krs.transfer(msg.sender, krowns4eth);
      LogSentKrs(msg.sender, krowns4eth, block.number);
    } else { // owner can always pay-in (and trigger round start/stop)
	    if(block.number >= icoRounds[rNo].rStartBlock && block.number <= icoRounds[rNo].rEndBlock && !icoInProgress) {
          icoInProgress = true;
        }
        if(block.number > icoRounds[rNo].rEndBlock && icoInProgress) {
          endIcoRound();
        }
    }
  }

  // receiving tokens other than ETH
  
  // ERC223 receiver implementation - https://github.com/aragon/ERC23/blob/master/contracts/implementation/Standard223Receiver.sol
  Tkn tkn;

  struct Tkn {
    address addr;
    address sender;
    address origin;
    uint256 value;
    bytes data;
    bytes4 sig;
  }

  function tokenFallback(address _sender, address _origin, uint _value, bytes _data) returns (bool ok) {
    if (!supportsToken(msg.sender)) return false;
    return true;
  }

  function getSig(bytes _data) private returns (bytes4 sig) {
    uint l = _data.length < 4 ? _data.length : 4;
    for (uint i = 0; i < l; i++) {
      sig = bytes4(uint(sig) + uint(_data[i]) * (2 ** (8 * (l - 1 - i))));
    }
  }

  bool __isTokenFallback;

  modifier tokenPayable {
    if (!__isTokenFallback) throw;
    _;
  }
  
  function supportsToken(address token) returns (bool) {
    if (token == address(krs)) {
	  return true; 
    } else {
      revert();
	}
  }
  // end of ERC223 receiver implementation ------------------------------------


  // set up a new ico round  
  function newIcoRound(uint _rMinEthPayment, uint _rKrsUsdFixed, uint _rKycTreshold,
    uint _rMinKrsCap, uint _rMaxKrsCap, uint _rStartBlock, uint _rEndBlock) public onlyOwner {
    require(!icoInProgress);            // new round can be set up only after finished/cancelled the active one
    require(rNo < 25);                  // limit of 25 rounds (with pre-ico)
	rNo += 1;                           // increment round number, pre-ico has number 1
	icoRounds[rNo] = IcoRoundData(_rMinEthPayment, _rKrsUsdFixed, _rKycTreshold, _rMinKrsCap, _rMaxKrsCap, 
	  _rStartBlock, _rEndBlock, 0, 0, 0, 0, false); // rEthPaymentsAmount, rEthPaymentsCount, rSentKrownsAmount, rSentKrownsCount); 
  }
  
  // remove current round, params only - it does not refund any ETH!
  function removeCurrentIcoRound() public onlyOwner {
    require(icoRounds[rNo].rEthPaymentsAmount == 0); // only if there was no payment already
	require(!icoRounds[rNo].roundCompleted); // only current round can be removed
    icoInProgress = false;
    icoRounds[rNo].rMinEthPayment = 0;
    icoRounds[rNo].rKrsUsdFixed = 0;
    icoRounds[rNo].rKycTreshold = 0;
    icoRounds[rNo].rMinKrsCap = 0;
    icoRounds[rNo].rMaxKrsCap = 0;
    icoRounds[rNo].rStartBlock = 0;
    icoRounds[rNo].rEndBlock = 0;
    icoRounds[rNo].rEthPaymentsAmount = 0;
    icoRounds[rNo].rEthPaymentsCount = 0;
    icoRounds[rNo].rSentKrownsAmount = 0;
    icoRounds[rNo].rSentKrownsCount = 0;
    if(rNo > 0) rNo -= 1;
  }

  function changeIcoRoundEnding(uint _rEndBlock) public onlyOwner {
    require(icoRounds[rNo].rStartBlock > 0); // round must be set up earlier
    icoRounds[rNo].rEndBlock = _rEndBlock;  
  }
 
  // closes round automatically
  function endIcoRound() private {
    icoInProgress = false;
	icoRounds[rNo].rEndBlock = block.number;
	icoRounds[rNo].roundCompleted = true;
  }

  // close round manually - if needed  
  function endIcoRoundManually() public onlyOwner {
    endIcoRound();
  }
  
  // add a verified KYC/AML address
  function addAllowedAddress(address _address) public onlyOwnerOrApi {
    allowedAdresses[_address] = true;
  }
  function removeAllowedAddress(address _address) public onlyOwnerOrApi {
    delete allowedAdresses[_address];
  }

  // set exchange rate for ETH/EUR - needed for check whether incoming payment
  //  is more than xxxx EUR (thus requires KYC/AML verified address)
  function setEthEurRate(uint _ethEur) public onlyOwnerOrApi {
    ethEur = _ethEur;
  }

  // set exchange rate for ETH/USD
  function setEthUsdRate(uint _ethUsd) public onlyOwnerOrApi {
    ethUsd = _ethUsd;
  }

  // set exchange rate for KRS/USD
  function setKrsUsdRate(uint _krsUsd) public onlyOwnerOrApi {
    krsUsd = _krsUsd;
  }
  
  // set all three exchange rates: ETH/EUR, ETH/USD, KRS/USD
  function setAllRates(uint _ethEur, uint _ethUsd, uint _krsUsd) public onlyOwnerOrApi {
    ethEur = _ethEur;
    ethUsd = _ethUsd;
	  krsUsd = _krsUsd;
  }
  
  // send KRS from the contract to a given address (for BTC and FIAT payments)
  function sendKrs(address _receiver, uint _amount) public onlyOwnerOrApi {
    krs.transfer(_receiver, _amount);
  }

  // transfer KRS from other holder, up to amount allowed through krs.approve() function
  function getKrsFromApproved(address _from, uint _amount) public onlyOwnerOrApi {
    krs.transferFrom(_from, address(this), _amount);
  }
  
  // send ETH from the contract to a given address
  function sendEth(address _receiver, uint _amount) public onlyOwner {
    _receiver.transfer(_amount);
  }
 
  // disable/enable access from API - for security reasons
  function disableApiAccess(bool _disabled) public onlyOwner {
    apiAccessDisabled = _disabled;
  }
  
  // change API wallet address - for security reasons
  function changeApi(address _address) public onlyOwner {
    api = _address;
  }

  // change owner address
  function changeOwner(address _address) public onlySuperOwner {
    owner = _address;
  }
  
}

library MicroWalletLib {

    //change to production token address
    KinguinKrowns constant token = KinguinKrowns(0xdfb410994b66778bd6cc2c82e8ffe4f7b2870006);

    struct MicroWalletStorage {
        uint krsAmount ;
        address owner;
    }

    function toBytes(address a) private pure returns (bytes b){
        assembly {
            let m := mload(0x40)
            mstore(add(m, 20), xor(0x140000000000000000000000000000000000000000, a))
            mstore(0x40, add(m, 52))
            b := m
        }
    }

    function processPayment(MicroWalletStorage storage self, address _sender) public {
        require(msg.sender == address(token));

        if (self.owner == _sender) {    //closing MicroWallet
            self.krsAmount = 0;
            return;
        }

        require(self.krsAmount > 0);
        
        uint256 currentBalance = token.balanceOf(address(this));

        require(currentBalance >= self.krsAmount);

        if(currentBalance > self.krsAmount) {
            //return rest of the token
            require(token.transfer(_sender, currentBalance - self.krsAmount));
        }

        require(token.transfer(self.owner, self.krsAmount, toBytes(_sender)));

        self.krsAmount = 0;
    }
}

contract KinguinVault is Ownable, ERC223Receiver {
    
    mapping(uint=>address) public microWalletPayments;
    mapping(uint=>address) public microWalletsAddrs;
    mapping(address=>uint) public microWalletsIDs;
    mapping(uint=>uint) public microWalletPaymentBlockNr;

    KinguinKrowns public token;
    uint public uncleSafeNr = 5;
    address public withdrawAddress;

    modifier onlyWithdraw() {
        require(withdrawAddress == msg.sender);
        _;
    }

    constructor(KinguinKrowns _token) public {
        token = _token;
        withdrawAddress = owner;
    }
    
    function createMicroWallet(uint productOrderID, uint krsAmount) onlyOwner public {
        require(productOrderID != 0 && microWalletsAddrs[productOrderID] == address(0x0));
        microWalletsAddrs[productOrderID] = new MicroWallet(krsAmount);
        microWalletsIDs[microWalletsAddrs[productOrderID]] = productOrderID;
    }

    function getMicroWalletAddress(uint productOrderID) public view returns(address) {
        return microWalletsAddrs[productOrderID];
    }

    function closeMicroWallet(uint productOrderID) onlyOwner public {
        token.transfer(microWalletsAddrs[productOrderID], 0);
    }

    function checkIfOnUncle(uint currentBlockNr, uint transBlockNr) private view returns (bool) {
        if((currentBlockNr - transBlockNr) < uncleSafeNr) {
            return true;
        }
        return false;
    }

    function setUncleSafeNr(uint newUncleSafeNr) onlyOwner public {
        uncleSafeNr = newUncleSafeNr;
    }

    function getProductOrderPayer(uint productOrderID) public view returns (address) {
        if (checkIfOnUncle(block.number, microWalletPaymentBlockNr[productOrderID])) {
            return 0;    
        }
        return microWalletPayments[productOrderID];
    }

    function tokenFallback(address _sender, address _origin, uint _value, bytes _data) public returns (bool)  {
        require(msg.sender == address(token));
        if(microWalletsIDs[_sender] > 0) {
            microWalletPayments[microWalletsIDs[_sender]] = bytesToAddr(_data);
            microWalletPaymentBlockNr[microWalletsIDs[_sender]] = block.number;
        }
        return true;
    }

    function setWithdrawAccount(address _addr) onlyWithdraw public {
        withdrawAddress = _addr;
    } 

    function withdrawKrowns(address wallet, uint amount) onlyWithdraw public {
        require(wallet != address(0x0));
        token.transfer(wallet, amount);
    }

    function bytesToAddr (bytes b) private pure returns (address) {
        uint result = 0;
        for (uint i = b.length-1; i+1 > 0; i--) {
            uint c = uint(b[i]);
            uint to_inc = c * ( 16 ** ((b.length - i-1) * 2));
            result += to_inc;
        }
        return address(result);
    }
}

contract MicroWallet is ERC223Receiver {
    
    MicroWalletLib.MicroWalletStorage private mwStorage;

    constructor(uint _krsAmount) public {
        mwStorage.krsAmount = _krsAmount;
        mwStorage.owner = msg.sender;
    }

    function tokenFallback(address _sender, address _origin, uint _value, bytes _data) public returns (bool)  {
        MicroWalletLib.processPayment(mwStorage, _sender);
        
        return true;
    }
}

    Contract ABI  
[{"constant":false,"inputs":[{"name":"productOrderID","type":"uint256"}],"name":"closeMicroWallet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"withdrawAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"productOrderID","type":"uint256"},{"name":"krsAmount","type":"uint256"}],"name":"createMicroWallet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"productOrderID","type":"uint256"}],"name":"getProductOrderPayer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"productOrderID","type":"uint256"}],"name":"getMicroWalletAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_addr","type":"address"}],"name":"setWithdrawAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"microWalletPaymentBlockNr","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_sender","type":"address"},{"name":"_origin","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"tokenFallback","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newUncleSafeNr","type":"uint256"}],"name":"setUncleSafeNr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"wallet","type":"address"},{"name":"amount","type":"uint256"}],"name":"withdrawKrowns","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"microWalletPayments","outputs":[{"name":"","type":"address"}],"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":"","type":"uint256"}],"name":"microWalletsAddrs","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"microWalletsIDs","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"uncleSafeNr","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_token","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]

  Contract Creation Code Switch To Opcodes View
6080604052600560065534801561001557600080fd5b50604051602080610b75833981016040525160008054600160a060020a03338116600160a060020a0319928316179283905560058054948216948316949094179093556007805490911691909216179055610b00806100756000396000f3006080604052600436106100f05763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166304d6878f81146100f55780631581b6001461010f578063176d0780146101405780632a8ab73c1461015b5780632c0994c11461017357806335a9a5c71461018b5780634212991b146101ac5780634c123019146101d65780636cd186ce146102595780637cc3b48e14610271578063870e6972146102955780638da5cb5b146102ad5780639c6922b6146102c2578063a0093806146102da578063bac97647146102fb578063f2fde38b14610310578063fc0c546a14610331575b600080fd5b34801561010157600080fd5b5061010d600435610346565b005b34801561011b57600080fd5b50610124610409565b60408051600160a060020a039092168252519081900360200190f35b34801561014c57600080fd5b5061010d600435602435610418565b34801561016757600080fd5b506101246004356104da565b34801561017f57600080fd5b50610124600435610520565b34801561019757600080fd5b5061010d600160a060020a036004351661053b565b3480156101b857600080fd5b506101c4600435610585565b60408051918252519081900360200190f35b3480156101e257600080fd5b50604080516020601f60643560048181013592830184900484028501840190955281845261024594600160a060020a0381358116956024803590921695604435953695608494019181908401838280828437509497506105979650505050505050565b604080519115158252519081900360200190f35b34801561026557600080fd5b5061010d600435610642565b34801561027d57600080fd5b5061010d600160a060020a0360043516602435610662565b3480156102a157600080fd5b50610124600435610731565b3480156102b957600080fd5b5061012461074c565b3480156102ce57600080fd5b5061012460043561075b565b3480156102e657600080fd5b506101c4600160a060020a0360043516610776565b34801561030757600080fd5b506101c4610788565b34801561031c57600080fd5b5061010d600160a060020a036004351661078e565b34801561033d57600080fd5b50610124610826565b60005433600160a060020a0390811691161461036157600080fd5b60055460008281526002602090815260408083205481517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a03918216600482015260248101859052915194169363a9059cbb93604480840194938390030190829087803b1580156103da57600080fd5b505af11580156103ee573d6000803e3d6000fd5b505050506040513d602081101561040457600080fd5b505050565b600754600160a060020a031681565b60005433600160a060020a0390811691161461043357600080fd5b81158015906104575750600082815260026020526040902054600160a060020a0316155b151561046257600080fd5b8061046b6108c7565b90815260405190819003602001906000f08015801561048e573d6000803e3d6000fd5b506000838152600260209081526040808320805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039586161790819055909316825260039052209190915550565b6000818152600460205260408120546104f4904390610835565b156105015750600061051b565b50600081815260016020526040902054600160a060020a03165b919050565b600090815260026020526040902054600160a060020a031690565b60075433600160a060020a0390811691161461055657600080fd5b6007805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b60046020526000908152604090205481565b60055460009033600160a060020a039081169116146105b557600080fd5b600160a060020a0385166000908152600360205260408120541115610637576105dd82610855565b600160a060020a0386811660009081526003602090815260408083208054845260018352818420805473ffffffffffffffffffffffffffffffffffffffff1916969095169590951790935592548152600490925290204390555b506001949350505050565b60005433600160a060020a0390811691161461065d57600080fd5b600655565b60075433600160a060020a0390811691161461067d57600080fd5b600160a060020a038216151561069257600080fd5b600554604080517fa9059cbb000000000000000000000000000000000000000000000000000000008152600160a060020a038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561070157600080fd5b505af1158015610715573d6000803e3d6000fd5b505050506040513d602081101561072b57600080fd5b50505050565b600160205260009081526040902054600160a060020a031681565b600054600160a060020a031681565b600260205260009081526040902054600160a060020a031681565b60036020526000908152604090205481565b60065481565b60005433600160a060020a039081169116146107a957600080fd5b600160a060020a03811615156107be57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0392909216919091179055565b600554600160a060020a031681565b6000600654828403101561084b5750600161084f565b5060005b92915050565b805160009081906000190181805b60008360010111156108bd57858381518110151561087d57fe5b90602001015160f860020a900460f860020a0260f860020a900491506001838751030360020260100a820290508084019350828060019003935050610863565b5091949350505050565b6040516101fd806108d8833901905600608060405234801561001057600080fd5b506040516020806101fd833981016040525160005560018054600160a060020a033316600160a060020a03199091161790556101ac806100516000396000f3006080604052600436106100405763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416634c1230198114610045575b600080fd5b34801561005157600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526100c19473ffffffffffffffffffffffffffffffffffffffff81358116956024803590921695604435953695608494019181908401838280828437509497506100d59650505050505050565b604080519115158252519081900360200190f35b604080517fc61d02ef00000000000000000000000000000000000000000000000000000000815260006004820181905273ffffffffffffffffffffffffffffffffffffffff87166024830152915173420b2fce878e4da42820e768ec31b172bd388c909163c61d02ef9160448083019286929190829003018186803b15801561015d57600080fd5b505af4158015610171573d6000803e3d6000fd5b506001989750505050505050505600a165627a7a72305820a642af4934f4d5244339c87aa63db8bebc701d029bd3e0f54195b66bd153dc240029a165627a7a723058209be73c10040ffe88ecef8cc265f980fb48f486d6775a0c54b118c9ee7d1cbe2d0029000000000000000000000000dfb410994b66778bd6cc2c82e8ffe4f7b2870006

    Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000dfb410994b66778bd6cc2c82e8ffe4f7b2870006

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000dfb410994b66778bd6cc2c82e8ffe4f7b2870006


   Library Used
MicroWalletLib : 0x420b2fce878e4da42820e768ec31b172bd388c90

   Swarm Source:
bzzr://9be73c10040ffe88ecef8cc265f980fb48f486d6775a0c54b118c9ee7d1cbe2d

 

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.