Contract 0x85429f986a5cc38f90de7b4ffa44d570eef04066

 

TxHash Block Age From To Value [TxFee]
0xbf38b47af90084731c60b5669e2d4f9e43ba6456a972baf7d13d1c9cf383f587741786313 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665874
0xd9eaa484bbd7c63efd5b257d9e97b767564f1fe0b0c2dcf5cb5b613701430f0d741782224 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665874
0x3e600ec68f9007004429e63cffc4bdedd6515bbbae6656ae5cb8bf278d1032fa741779629 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000742172062
0xb58a6237e2d339caf0ebbade0378a3822dbca03829cb7af1ce71558f6de7240a741778732 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665682
0xff818dff2507110b70b74a440602e475ed753eb308fea3ce7d9dbe4928a6a986741778532 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665874
0xc02a0c46fa0f0bfc9c5a68b2f26e72eb3a6b57a06761330850ebb1349e68a0e5741767159 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x83acebc1cdcc9264368747041a5758e90ca44c3770759110402168e6bc4c194374176681 hr 1 min ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x9b0b1842cd055c14f900b91e35aac65a4906c7842da3a01e02afd10583be5b5074176661 hr 1 min ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0xba5032dc596f28a365fe0598409119205d6b37ef2de978cb28207062a1df3fda74176231 hr 10 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x298ca6d361afd268bd21fa10555c3d98f24c468e16f59ce0660ca23eebf292d774175681 hr 23 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000887832
0xc123254e632f1f5cdb552ea277dee6d45ffffbd669aa546219fdd767aa6d9b5374175661 hr 23 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000887832
0x2afb8c2b03ed8480dfc96a1a174569ffe933e15bc555ffbee3e84d07f649087c74174691 hr 43 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0xff11cf19a65f5c98d20c218d03837f214f89c64e8be706e826100343ecb906a774174691 hr 43 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0xfa62aeeefce56d102cf8c3bdc1a89398042d39966773e8e495583b63212da42f74174601 hr 44 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0xcd032ecb5ecceb7e28cbd4e707dd04d0111960120ebbee89844b89dfab7e0f1174173802 hrs 1 min ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0x63b0857d91791f312e1f414be379554b4537d6fdc877d625a77d82c9a4e21ae674172202 hrs 32 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.00110979
0x99c8b95c8f293ca7983e2de80670f51001b772460cf4475fa961d762b906e35d74171772 hrs 43 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x2c5b03445afca36d93aea26d035d14c635c93682465a10797ba842db7840b4b274170163 hrs 19 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665874
0x16e99f81309c1e56ac0770f14603e951aba4fc9f520ee18b6dc29d2d96a8d10774169663 hrs 32 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x46b8e480bba5a675e21ef3fd819ae09914d96dd05c9c4c87bf899447c6ac6afd74169653 hrs 33 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0x8c2be6ca09808cf285ee65d3b40c918a681a55da3382b72785dc0876fe47797e74162756 hrs 4 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443788
0x290e79cdd3f9674c8d56187efc1375858ad3242ae996ba2a918208c1929af09974157568 hrs 1 min ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665682
0x2046abe042770911e704b671347488baa9b4df46274dd21d822ba5f3ed5b50c374157128 hrs 12 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000221958
0x35932a5417bb18117ee39722cb745739dc8d7dc3017d11defc7065ad56cdda2874156578 hrs 24 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000443916
0x955d34300fd0e6cef6ceebe4a5391b8fb62aec2a0164354030362df239fb7a3574156368 hrs 28 mins ago0x544731de2bc32c96198980f14923e50518ad6a1a IN  0x85429f986a5cc38f90de7b4ffa44d570eef040660 Ether0.000665874
[ Download CSV Export 

Latest 25 internal transaction, Click here to view more Internal Transactions as a result of Contract Execution

Parent TxHash Block Age From To Value
0xbf38b47af90084731c60b5669e2d4f9e43ba6456a972baf7d13d1c9cf383f587741786313 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xd9eaa484bbd7c63efd5b257d9e97b767564f1fe0b0c2dcf5cb5b613701430f0d741782224 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x3e600ec68f9007004429e63cffc4bdedd6515bbbae6656ae5cb8bf278d1032fa741779629 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xb58a6237e2d339caf0ebbade0378a3822dbca03829cb7af1ce71558f6de7240a741778732 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xff818dff2507110b70b74a440602e475ed753eb308fea3ce7d9dbe4928a6a986741778532 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xc02a0c46fa0f0bfc9c5a68b2f26e72eb3a6b57a06761330850ebb1349e68a0e5741767159 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x83acebc1cdcc9264368747041a5758e90ca44c3770759110402168e6bc4c194374176681 hr 1 min ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x9b0b1842cd055c14f900b91e35aac65a4906c7842da3a01e02afd10583be5b5074176661 hr 1 min ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xba5032dc596f28a365fe0598409119205d6b37ef2de978cb28207062a1df3fda74176231 hr 10 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x298ca6d361afd268bd21fa10555c3d98f24c468e16f59ce0660ca23eebf292d774175681 hr 23 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xc123254e632f1f5cdb552ea277dee6d45ffffbd669aa546219fdd767aa6d9b5374175661 hr 23 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2afb8c2b03ed8480dfc96a1a174569ffe933e15bc555ffbee3e84d07f649087c74174691 hr 43 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xff11cf19a65f5c98d20c218d03837f214f89c64e8be706e826100343ecb906a774174691 hr 43 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xfa62aeeefce56d102cf8c3bdc1a89398042d39966773e8e495583b63212da42f74174601 hr 44 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0xcd032ecb5ecceb7e28cbd4e707dd04d0111960120ebbee89844b89dfab7e0f1174173802 hrs 1 min ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x63b0857d91791f312e1f414be379554b4537d6fdc877d625a77d82c9a4e21ae674172202 hrs 32 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x99c8b95c8f293ca7983e2de80670f51001b772460cf4475fa961d762b906e35d74171772 hrs 43 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2c5b03445afca36d93aea26d035d14c635c93682465a10797ba842db7840b4b274170163 hrs 19 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x16e99f81309c1e56ac0770f14603e951aba4fc9f520ee18b6dc29d2d96a8d10774169663 hrs 32 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x46b8e480bba5a675e21ef3fd819ae09914d96dd05c9c4c87bf899447c6ac6afd74169653 hrs 33 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x8c2be6ca09808cf285ee65d3b40c918a681a55da3382b72785dc0876fe47797e74162756 hrs 4 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x290e79cdd3f9674c8d56187efc1375858ad3242ae996ba2a918208c1929af09974157568 hrs 1 min ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x2046abe042770911e704b671347488baa9b4df46274dd21d822ba5f3ed5b50c374157128 hrs 12 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x35932a5417bb18117ee39722cb745739dc8d7dc3017d11defc7065ad56cdda2874156578 hrs 24 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
0x955d34300fd0e6cef6ceebe4a5391b8fb62aec2a0164354030362df239fb7a3574156368 hrs 28 mins ago0x85429f986a5cc38f90de7b4ffa44d570eef04066  Contract Creation0 Ether
[ Download CSV Export 
Warning: The compiled contract might be susceptible to ExpExponentCleanup (medium/high-severity), EventStructWrongData (very low-severity) Solidity Compiler Bugs.

Contract Source Code Verified (Exact Match)

Contract Name:
KinguinVault

Compiler Version
v0.4.23+commit.124ca40d

Optimization Enabled:
Yes

Runs (Optimizer):
200

Contract Source Code

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

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
Block Age Transaction Difficulty GasUsed Reward
Block Age Uncle Number Difficulty GasUsed Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.