Contract Overview
Balance: 0 Ether
Ether Value: $0
Transactions: 74351 txns
 Latest 25 transactions from a total of 74351 transactions
(+1 PendingTxn)

TxHash Age From To Value [TxFee]
0x5b71c375a4457170f054cc47d5e05ce08c4dff847f6b5492da424bcd86bc3069(pending)0x544731de2bc32c96198980f14923e50518ad6a1a  IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether(Pending)
0x9ba742a9a4e0633a764c429338dfff70d0785955b23da1762fe0df003fd7444b19 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000887576
0x5c8cf8f97be64d320d197738ee445ae2928abb5ed0ebe3411b16277bfa3a3c3d21 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00088732
0x9def538275d4240135a4aef7534619b33f0b16a14d2eb5874085638bc97e63fc28 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0006878714
0x07789f1d8ccd45964f03c6114cbea48a75578f81e9440323fb9da1c694999db81 hr 8 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x008652f2efbf5a855a38656ede370313d8ad296d1081d71fc1c4f36a3f66d1781 hr 54 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00221894
0x1907f857e6e76a20aec01a7cbdb803ae04a191089fb5c420048069a66071f4992 hrs 27 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x4e9796724bf3ab414ddc4c2476b3923cc404fdd1f545816bb6c011a79d82cae52 hrs 35 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00221894
0x9142b333cd8b5e5dfa56890bdcdb5086b199719bec1d02173edcf749036299072 hrs 44 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000937449318
0x7c6160a381b9ec59c1ed870a6e950eaa83b91a08edfcabef9b9171ea2f00c7a73 hrs 18 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.001175699
0x69f46f3603b0ce2fbf98fe20e9cb1958548a3cc15251f43b9045206423d1804f4 hrs 45 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665682
0x19dedab7730034c5566f39aea42bf71181eda6c1ea4f3e40ac95c4211035fb524 hrs 54 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0xf9a205201c114179c2ccf1cfd31373bf2b333de477c80f8fbcb6a0715ddde4a08 hrs 1 min ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x182860034ebe547d0c2cb4c97b25f743e78ea02e4532e5eb6ee829d0f8aa30b98 hrs 27 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x0220c6e5711bca2f499e75a3f4febda6f81f87a63cf5db9a5328c8fb604d2eec8 hrs 47 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0xfa5f9cef779227763b783a9749deaa080253cf5e614c81c60ef13e51186f46de8 hrs 49 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110947
0x0135c1daea620187508c1aade06d766a8b77c9cceca564827521879386866a839 hrs 28 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00221894
0x6ca8c87b2c6789e91681678d48e99b9cb5b9045a66b4d6a4751deff5d9230dbe9 hrs 37 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00044366
0x3fafdbf8f89b64a3af3cd7f62c5a0365fc9081a4b689f1a0276dd2f1a384682310 hrs 14 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0xe3ef6b4bd3146d3ca26e0aba0e21753f17925f73800cc8b9c556dbbcea38874010 hrs 16 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.0022183
0xfde76d2a6608c417ec8de1ae184b7a87d907543c31ed89a58fc9b4852885d48310 hrs 18 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110915
0x84dec3afef9741b50dfba201c0d74bb53ecefe37f536df5ff2af040bf33f873910 hrs 18 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110947
0x9a450c360b63837f448fe0c596f3b4fe4e94ee2508157b026f29694100eb2d1d10 hrs 56 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665682
0xf4125e3f592eff062749f2ada6246a21bbe5d6740c3e738778ef174ca3620e8c10 hrs 57 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00066549
0x381fac84a40af11666b8c44be0b3a6af3ab1523e0377bc7c80ced9ef11facc6411 hrs 3 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a  IN   0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665682
[ 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
0x9ba742a9a4e0633a764c429338dfff70d0785955b23da1762fe0df003fd7444b708679319 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x5c8cf8f97be64d320d197738ee445ae2928abb5ed0ebe3411b16277bfa3a3c3d708678721 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x9def538275d4240135a4aef7534619b33f0b16a14d2eb5874085638bc97e63fc708675728 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x07789f1d8ccd45964f03c6114cbea48a75578f81e9440323fb9da1c694999db870865851 hr 8 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x008652f2efbf5a855a38656ede370313d8ad296d1081d71fc1c4f36a3f66d17870864131 hr 54 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x1907f857e6e76a20aec01a7cbdb803ae04a191089fb5c420048069a66071f49970862992 hrs 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4e9796724bf3ab414ddc4c2476b3923cc404fdd1f545816bb6c011a79d82cae570862602 hrs 35 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x9142b333cd8b5e5dfa56890bdcdb5086b199719bec1d02173edcf7490362990770862302 hrs 44 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x7c6160a381b9ec59c1ed870a6e950eaa83b91a08edfcabef9b9171ea2f00c7a770860903 hrs 18 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x69f46f3603b0ce2fbf98fe20e9cb1958548a3cc15251f43b9045206423d1804f70857464 hrs 45 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x19dedab7730034c5566f39aea42bf71181eda6c1ea4f3e40ac95c4211035fb5270857134 hrs 54 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xf9a205201c114179c2ccf1cfd31373bf2b333de477c80f8fbcb6a0715ddde4a070849978 hrs 1 min ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x182860034ebe547d0c2cb4c97b25f743e78ea02e4532e5eb6ee829d0f8aa30b970848828 hrs 27 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x0220c6e5711bca2f499e75a3f4febda6f81f87a63cf5db9a5328c8fb604d2eec70847938 hrs 47 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xfa5f9cef779227763b783a9749deaa080253cf5e614c81c60ef13e51186f46de70847858 hrs 49 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x0135c1daea620187508c1aade06d766a8b77c9cceca564827521879386866a8370846279 hrs 28 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x6ca8c87b2c6789e91681678d48e99b9cb5b9045a66b4d6a4751deff5d9230dbe70845969 hrs 37 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x3fafdbf8f89b64a3af3cd7f62c5a0365fc9081a4b689f1a0276dd2f1a3846823708442710 hrs 14 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xe3ef6b4bd3146d3ca26e0aba0e21753f17925f73800cc8b9c556dbbcea388740708441910 hrs 16 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xfde76d2a6608c417ec8de1ae184b7a87d907543c31ed89a58fc9b4852885d483708441510 hrs 18 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x84dec3afef9741b50dfba201c0d74bb53ecefe37f536df5ff2af040bf33f8739708441210 hrs 18 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x9a450c360b63837f448fe0c596f3b4fe4e94ee2508157b026f29694100eb2d1d708426910 hrs 56 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xf4125e3f592eff062749f2ada6246a21bbe5d6740c3e738778ef174ca3620e8c708426710 hrs 57 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x381fac84a40af11666b8c44be0b3a6af3ab1523e0377bc7c80ced9ef11facc64708424711 hrs 3 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x4928a58ef83a8bfab70aa27b6ff45e21d28d18686fc93ef5c0fc745d1c61f252708406511 hrs 50 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.