Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 60834 txns
Misc:
Address Watch: Add To Watch List
Contract Creator: 0x544731de2bc32c96198980f14923e50518ad6a1aat txn 0x75fbacda0e85adf57e62e25cf636dedc9c9bd475c1cb414727f4c4094ab47caf
Token Balance:
 Latest 25 transactions from a total of 60834 transactions

TxHash Age From To Value [TxFee]
0x008c5f44c41e797bb899fd3bc2951e6b98d605ca71b99c96127b0ebbe41659d212 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x6f410febecc40dace3f76b711296976cf9f58b283acf3985cf3eb5743a4c8bcf14 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0002468298
0x7d803084144e310979099e01b0eee9559f56c97e41cc6eb6af9bec1a1125e6c914 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0002468298
0x5a33ce13b85b14fd927c336247da5fbcbc935bf931dcd69203e1fe415a8fb3c215 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x35333aab53e46f9aedcc04c3938c595d38e311d484bab6d6e11c55611864b60516 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0xfb15152177ff3222b0dd3bce58fa6080842c587f7dcff2fba65a1fe8084af27016 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x4a2f4b396ae1ab31fc95be35d1cc6e6703d1d2387f5366de7bc39b6b90de3fcb24 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110883
0x4d516dea7e183c869d8195239e21a03573be260bf73c92d1360145fe391722fa45 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0009757704
0x2fb406bba10dffee2ad0598d89df9800160d13d2d55ec1757d269951704008c547 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110883
0xaacb158b2a3de1c60bce3a992834ce677cf7156255faf9f80b8590d252698bd849 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0xd6d3ab4c901def43242d68027e83d46c68f200aec5b8905662b79f786809fd0950 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x20844e9410ca21c1d357c846c912b21b633e2f35c9af0e0042a7b8abf243354951 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x84d42e3adc9d9c3bdf03d5d204d1e40111dd32e3b54f168a220ce4df5b06f1b652 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x2842476eb7990bd97b095dffb1eb35e1620892ffbcd3be7613bf803146bf7b6652 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x98b97dafdec4d297d6243de2671a63eafb01a43b89ebc0f22be993b56e4a59c553 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0xf2a56dcf3540faa1f7df00ca8503c6fcacb95317dac878b1664c6de5b24ec34a54 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x399a3e7401dee54a912256e13f8076c10a9d68b20bc8e2d1203f6c6d78a37acb55 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0x8ada80ebd7935bb8c55818af0a07ad2e64a1ce3af17a332b7e9c91a8233cd7d055 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00024199
0xbce28641470c8c744804babcb4f8f98948d739a5aba4e39cbda3767576bbb37657 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00016699
0x4b45ecf5a1fbdccb9b3ca3239a0cee9ddc62004cb3908efa1cb519e676b36cd158 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0009535938
0x2249556e942a36a348b55b0c3fa92b9fc26e77276397d56b855100022055d2681 hr 18 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001774128
0x47bbb6a9b3747f3dcba7b5bfe45681c66051c8021f51c5671d643f61ce2824552 hrs 8 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000997947
0x7372c3b81df5a91592f825c5d9c6a8e275cc2e4a645d1df11dcd77837f23886b2 hrs 9 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000998235
0xbf9acaae24d82610dacf14cb27646cc5dabef345c1a33842d4af3aee08e7d89a2 hrs 9 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000997947
0xf5cf1600815232cce024b7419003cf6b71a98338fe68baa4a6fe267ff9fad63e2 hrs 9 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000998235
[ 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
0x4a2f4b396ae1ab31fc95be35d1cc6e6703d1d2387f5366de7bc39b6b90de3fcb671911624 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4d516dea7e183c869d8195239e21a03573be260bf73c92d1360145fe391722fa671903345 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2fb406bba10dffee2ad0598d89df9800160d13d2d55ec1757d269951704008c5671902647 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4b45ecf5a1fbdccb9b3ca3239a0cee9ddc62004cb3908efa1cb519e676b36cd1671897658 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2249556e942a36a348b55b0c3fa92b9fc26e77276397d56b855100022055d26867188841 hr 18 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x47bbb6a9b3747f3dcba7b5bfe45681c66051c8021f51c5671d643f61ce28245567186672 hrs 8 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x7372c3b81df5a91592f825c5d9c6a8e275cc2e4a645d1df11dcd77837f23886b67186652 hrs 9 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xbf9acaae24d82610dacf14cb27646cc5dabef345c1a33842d4af3aee08e7d89a67186632 hrs 9 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xf5cf1600815232cce024b7419003cf6b71a98338fe68baa4a6fe267ff9fad63e67186602 hrs 9 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x1899f4d7533145f0803af4fb0bfdab603a322ee3bcb05433f9935adf780591ef67185532 hrs 36 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xc0a32cbef075db0587bcbba9491dd85440cb791d5cedc9d4f0f28c77bd84cd4567185362 hrs 39 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xe80f61d594ea898f7ae7adbaa1473381c0ac53fd72fb4f830fd9f699eb8a4c2667185342 hrs 39 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x658ed9a46198fb8d5ac771a946f63ee3a2a707dd769b803d576eff58f06580e267185152 hrs 43 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x98dea7c129dec957cc37f249ecce67afcd52db3906abaed1ed7bee0a4c0fd60767184183 hrs 6 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xa887344995a3792f00d3cbb6a197d0f022980716e267afc3516648a90447487367184123 hrs 8 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x9603bdd12863c04e19fa201c5fd1932dda2c843002dee11ffc51ac6ce568dbbe67184093 hrs 9 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x66a689a572f87f21e5cf25b89e5615e5814f3c135e1f32fbe4d4042b3e9e472767183493 hrs 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4f9135a5692c224f4963d482c87e41c0ee82eee4794c31415c37da513521d7c867183363 hrs 30 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x3c63c65fb8c25effcf0004040a24599cdfa2bd6f7f253fca32fdf5d215efeff167183213 hrs 33 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x11431c072c8606038d143f9667e2ae84a58f2508def095a0be3245c3ed7d25a467183043 hrs 37 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x45130fa9fe545eb16b6df5c303203beb325f5a16f2d529354fb4088f245ddfec67182963 hrs 39 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x40a360b6ee354f243a349cc5d65e2109b35aa601b94ec8dcc2f0631f2ce5298d67182943 hrs 39 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x1a2df27e0cff623b11de11bf8ae2f21b8c65eb254859b78c4ab5bf6c470d189767182863 hrs 41 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2a60a58208037d8218a351848c9b748b44b7237b609a089144e54166099f4a0467182523 hrs 48 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xa71e35bb75a51d59e7985fc5779cea29e9b887aae18ef814df64a2907aafb7ee67182503 hrs 49 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 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.