Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x06a6a7aF298129E3a2AB396c9C06F91D3C54aBA8
Balance 0 ETH
Nonce 1
Code Size 17173 bytes
Indexed Transactions Index loading...
External Etherscan · Sourcify

Contract Bytecode

17173 bytes
0x60806040526004361061028f5763ffffffff60e060020a60003504166305e4554681146102af57806306fdde03146102d6578063081812fc14610360578063095ea7b31461039457806318160ddd146103b8578063189052f1146103cd57806323b872dd146103f757806324953eaa1461042157806326c1e7501461048a578063286dd3f5146104a25780632f745c59146104c357806330f18fb7146104e757806334efcb8e146104fc57806335bde22c146105975780633d7d3f5a146105b85780633e573168146105d95780633f4ba83a14610629578063414b50641461063e57806342842e0e146106565780634bbe9547146106805780634f558e79146106a15780634f6ccce7146106b95780635a71e6d3146106d15780635c975abb146106f25780635fd8c71014610707578063611e68d41461071c5780636352211e1461073d57806364384a9914610755578063672815c2146107765780636fbde40d1461079157806370a08231146107b25780637b9417c8146107d35780637c0f0ac9146107f45780638456cb59146108095780638b17b33b1461081e5780638da5cb5b1461085b57806391876e57146108705780639272eb8b1461088557806395d89b41146108a65780639b19251a146108bb578063a22cb465146108dc578063aac0b77614610902578063b568ee2b14610926578063b88d4fde146109a9578063bdf22c6614610a18578063c4d66de814610a2d578063c58b1bdd14610a4e578063c87b56dd14610a7b578063cd216f0e14610a93578063e2ec6ec314610ab8578063e6cbe35114610b0d578063e985e9c514610b22578063eb822fe514610b49578063f2fde38b14610b64578063f6d016dc14610b85578063f97fd58a14610b9a578063fda49eb414610bbe575b336000908152600c602052604090205460ff1615156102ad57600080fd5b005b3480156102bb57600080fd5b506102c4610bd3565b60408051918252519081900360200190f35b3480156102e257600080fd5b506102eb610bd9565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561032557818101518382015260200161030d565b50505050905090810190601f1680156103525780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561036c57600080fd5b50610378600435610c70565b60408051600160a060020a039092168252519081900360200190f35b3480156103a057600080fd5b506102ad600160a060020a0360043516602435610c8e565b3480156103c457600080fd5b506102c4610d73565b3480156103d957600080fd5b506102ad600160a060020a0360043516602435604435606435610d79565b34801561040357600080fd5b506102ad600160a060020a0360043581169060243516604435610f57565b34801561042d57600080fd5b5060408051602060048035808201358381028086018501909652808552610476953695939460249493850192918291850190849080828437509497506110069650505050505050565b604080519115158252519081900360200190f35b34801561049657600080fd5b506102c4600435611067565b3480156104ae57600080fd5b50610476600160a060020a0360043516611086565b3480156104cf57600080fd5b506102c4600160a060020a036004351660243561111e565b3480156104f357600080fd5b5061037861116c565b34801561050857600080fd5b5061051460043561117b565b6040518087815260200186815260200185815260200184815260200183600560200280838360005b8381101561055457818101518382015260200161053c565b5050505090500182600560200280838360005b8381101561057f578181015183820152602001610567565b50505050905001965050505050505060405180910390f35b3480156105a357600080fd5b506102c4600160a060020a03600435166111d3565b3480156105c457600080fd5b506102ad6004356024356044356064356111e5565b3480156105e557600080fd5b506105f1600435611422565b604051808260a080838360005b838110156106165781810151838201526020016105fe565b5050505090500191505060405180910390f35b34801561063557600080fd5b506102ad61164b565b34801561064a57600080fd5b506102c4600435611793565b34801561066257600080fd5b506102ad600160a060020a03600435811690602435166044356117a5565b34801561068c57600080fd5b506102ad600160a060020a03600435166117dd565b3480156106ad57600080fd5b506104766004356118dd565b3480156106c557600080fd5b506102c46004356118fa565b3480156106dd57600080fd5b506102c4600160a060020a036004351661192f565b3480156106fe57600080fd5b50610476611afd565b34801561071357600080fd5b506102ad611b0d565b34801561072857600080fd5b506102ad600160a060020a0360043516611bb2565b34801561074957600080fd5b50610378600435611bf7565b34801561076157600080fd5b506102c4600160a060020a0360043516611c1b565b34801561078257600080fd5b506102c4600435602435611c2d565b34801561079d57600080fd5b506102ad600160a060020a0360043516611c6e565b3480156107be57600080fd5b506102c4600160a060020a0360043516611d6e565b3480156107df57600080fd5b50610476600160a060020a0360043516611da1565b34801561080057600080fd5b50610378611e3d565b34801561081557600080fd5b506102ad611e4c565b34801561082a57600080fd5b50610842600160a060020a0360043516602435611ef3565b60408051600092830b90920b8252519081900360200190f35b34801561086757600080fd5b506103786120db565b34801561087c57600080fd5b506102ad6120ea565b34801561089157600080fd5b506102ad600160a060020a03600435166121f0565b3480156108b257600080fd5b506102eb6122f0565b3480156108c757600080fd5b50610476600160a060020a0360043516612351565b3480156108e857600080fd5b506102ad600160a060020a03600435166024351515612366565b34801561090e57600080fd5b506102ad600160a060020a03600435166024356123ea565b34801561093257600080fd5b5061093e600435612431565b604051838152602081018360a080838360005b83811015610969578181015183820152602001610951565b5050505090500182600560200280838360005b8381101561099457818101518382015260200161097c565b50505050905001935050505060405180910390f35b3480156109b557600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526102ad94600160a060020a0381358116956024803590921695604435953695608494019181908401838280828437509497506124719650505050505050565b348015610a2457600080fd5b506102c46124a9565b348015610a3957600080fd5b506102ad600160a060020a03600435166124af565b348015610a5a57600080fd5b506102c4600160a060020a03600435166024356044356064356084356128b2565b348015610a8757600080fd5b506102eb6004356128fd565b348015610a9f57600080fd5b506102ad600160a060020a0360043516602460c46129b2565b348015610ac457600080fd5b506040805160206004803580820135838102808601850190965280855261047695369593946024949385019291829185019084908082843750949750612bd29650505050505050565b348015610b1957600080fd5b50610378612c2d565b348015610b2e57600080fd5b50610476600160a060020a0360043581169060243516612c3c565b348015610b5557600080fd5b506102c4600435602435612c6a565b348015610b7057600080fd5b506102ad600160a060020a0360043516612c87565b348015610b9157600080fd5b506102ad612d0f565b348015610ba657600080fd5b506102ad600160a060020a0360043516602435612d90565b348015610bca57600080fd5b5061037861302d565b60195481565b60048054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c655780601f10610c3a57610100808354040283529160200191610c65565b820191906000526020600020905b815481529060010190602001808311610c4857829003601f168201915b505050505090505b90565b600081815260016020526040902054600160a060020a03165b919050565b6000610c9982611bf7565b9050600160a060020a038381169082161415610cb457600080fd5b33600160a060020a0382161480610cd05750610cd08133612c3c565b1515610cdb57600080fd5b6000610ce683610c70565b600160a060020a0316141580610d045750600160a060020a03831615155b15610d6e576000828152600160209081526040918290208054600160a060020a031916600160a060020a03878116918217909255835186815293519093918516927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35b505050565b60085490565b610d816141fc565b336000908152600c602052604090205460ff161515610d9f57600080fd5b600160a060020a0385161515610dff576040805160e560020a62461bcd02815260206004820152601d60248201527f4f776e657220706172616d2073686f756c6420626520646566696e6564000000604482015290519081900360640190fd5b60008211610e7d576040805160e560020a62461bcd02815260206004820152602e60248201527f5265736f7572636556616c756520706172616d2073686f756c6420626520626960448201527f676765722074686174207a65726f000000000000000000000000000000000000606482015290519081900360840190fd5b610e868461303c565b9050610e928582613157565b9050818160e0015184600581101515610ea757fe5b60200201511015610f28576040805160e560020a62461bcd02815260206004820152603460248201527f5265736f757263652063757272656e742073686f756c6420626520626967676560448201527f722074686174205265736f7572636556616c7565000000000000000000000000606482015290519081900360840190fd5b60e081015182908460058110610f3a57fe5b602002018051919091039052610f50848261343e565b5050505050565b80610f62338261346d565b1515610f6d57600080fd5b600160a060020a0384161515610f8257600080fd5b600160a060020a0383161515610f9757600080fd5b610fa184836134cc565b610fab848361356c565b610fb583836136a5565b82600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050565b600b546000908190600160a060020a0316331461102257600080fd5b5060005b82518110156110615761104f838281518110151561104057fe5b90602001906020020151611086565b1561105957600191505b600101611026565b50919050565b600f80548290811061107557fe5b600091825260209091200154905081565b600b54600090600160a060020a031633146110a057600080fd5b600160a060020a0382166000908152600c602052604090205460ff1615610c8957600160a060020a0382166000818152600c6020908152604091829020805460ff19169055815192835290517ff1abf01a1043b7c244d128e8595cf0c1d10743b022b03a02dffd8ca3bf729f5a9281900390910190a1506001919050565b600061112983611d6e565b821061113457600080fd5b600160a060020a038316600090815260066020526040902080548390811061115857fe5b906000526020600020015490505b92915050565b601554600160a060020a031681565b600080600080611189614253565b611191614253565b6111996141fc565b6111a28861303c565b805160208201516060830151608084015160a085015160c090950151939d929c50909a509850919650945092505050565b60176020526000908152604090205481565b600d5460a060020a900460ff16156111fc57600080fd5b601460009054906101000a9004600160a060020a0316600160a060020a03166355909f876040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561124f57600080fd5b505af1158015611263573d6000803e3d6000fd5b505050506040513d602081101561127957600080fd5b50511561130557601654604080517f0b7edea3000000000000000000000000000000000000000000000000000000008152336004820152602481018790529051600160a060020a0390921691630b7edea39160448082019260009290919082900301818387803b1580156112ec57600080fd5b505af1158015611300573d6000803e3d6000fd5b505050505b3361130f85611bf7565b600160a060020a03161461136d576040805160e560020a62461bcd02815260206004820152600960248201527f4e6f74206f776e65720000000000000000000000000000000000000000000000604482015290519081900360640190fd5b60165461138390600160a060020a031685610c8e565b601654604080517f27ebe40a000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606481018490523360848201529051600160a060020a03909216916327ebe40a9160a48082019260009290919082900301818387803b15801561140457600080fd5b505af1158015611418573d6000803e3d6000fd5b5050505050505050565b61142a614253565b60006114346141fc565b600061143e614253565b6014546040805160e060020a6364c6639502815260226004820152905160009283928392600160a060020a03909216916364c663959160248082019260209290919082900301818787803b15801561149557600080fd5b505af11580156114a9573d6000803e3d6000fd5b505050506040513d60208110156114bf57600080fd5b505196506114cc8961303c565b95508686604001516114dc6136ee565b030294508560c001519350601460009054906101000a9004600160a060020a0316600160a060020a03166364c6639560126040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b15801561154657600080fd5b505af115801561155a573d6000803e3d6000fd5b505050506040513d602081101561157057600080fd5b50519250600091505b60058210156116395783826005811061158e57fe5b6020020151151561159e5761162e565b6115c3858760c00151846005811015156115b457fe5b602002015102620151806136f2565b60e087015183600581106115d357fe5b602002018051909101905260c0860151839083600581106115f057fe5b6020020151029050808660e001518360058110151561160b57fe5b6020020151111561162e5760e08601518190836005811061162857fe5b60200201525b600190910190611579565b50505060e09092015195945050505050565b600b54600160a060020a0316331461166257600080fd5b600d5460a060020a900460ff16151561167a57600080fd5b601654600160a060020a03161515611701576040805160e560020a62461bcd028152602060048201526024808201527f53616c65436c6f636b20636f6e74726163742073686f756c642062652064656660448201527f696e656400000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b601454600160a060020a03161515611789576040805160e560020a62461bcd02815260206004820152602260248201527f42616c616e636520636f6e74726163742073686f756c6420626520646566696e60448201527f6564000000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b611791613720565b565b60009081526013602052604090205490565b806117b0338261346d565b15156117bb57600080fd5b6117d78484846020604051908101604052806000815250612471565b50505050565b600b54600090600160a060020a031633146117f757600080fd5b81905080600160a060020a031663051f403f6040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561183857600080fd5b505af115801561184c573d6000803e3d6000fd5b505050506040513d602081101561186257600080fd5b505115156118ba576040805160e560020a62461bcd02815260206004820152601760248201527f496e636f7272656374206164647265737320706172616d000000000000000000604482015290519081900360640190fd5b60148054600160a060020a031916600160a060020a039290921691909117905550565b600090815260208190526040902054600160a060020a0316151590565b6000611904610d73565b821061190f57600080fd5b600880548390811061191d57fe5b90600052602060002001549050919050565b600080600080600061193f6141fc565b6014546040805160e060020a6364c66395028152602260048201529051600092600160a060020a0316916364c6639591602480830192602092919082900301818787803b15801561198f57600080fd5b505af11580156119a3573d6000803e3d6000fd5b505050506040513d60208110156119b957600080fd5b5051600160a060020a038916600090815260176020526040902054909650620151800294506119e788613798565b9350600092505b83831015611ae457611a08611a0389856137b3565b61303c565b915085611a1589846137d7565b611a1d6136ee565b0302905080601460009054906101000a9004600160a060020a0316600160a060020a03166364c6639560116040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b158015611a8157600080fd5b505af1158015611a95573d6000803e3d6000fd5b505050506040513d6020811015611aab57600080fd5b505160c0840151611aca90849060005b6020020151026202a3006136f2565b60e0850151510102029490940193600192909201916119ee565b611af185620151806136f2565b98975050505050505050565b600d5460a060020a900460ff1681565b600d54600090600160a060020a03163314611b72576040805160e560020a62461bcd02815260206004820152600e60248201527f4f6e6c7920747265617375726572000000000000000000000000000000000000604482015290519081900360640190fd5b50600d54604051303191600160a060020a03169082156108fc029083906000818181858888f19350505050158015611bae573d6000803e3d6000fd5b5050565b600b54600160a060020a03163314611bc957600080fd5b600160a060020a03811615611bf457600d8054600160a060020a031916600160a060020a0383161790555b50565b600081815260208190526040812054600160a060020a031680151561116657600080fd5b60186020526000908152604090205481565b60008281526011602090815260408083208484529091528120546103e88110611c595760009150611c67565b6103e8606482020460640391505b5092915050565b600b54600090600160a060020a03163314611c8857600080fd5b81905080600160a060020a03166385b861886040518163ffffffff1660e060020a028152600401602060405180830381600087803b158015611cc957600080fd5b505af1158015611cdd573d6000803e3d6000fd5b505050506040513d6020811015611cf357600080fd5b50511515611d4b576040805160e560020a62461bcd02815260206004820152601760248201527f496e636f7272656374206164647265737320706172616d000000000000000000604482015290519081900360640190fd5b60168054600160a060020a031916600160a060020a039290921691909117905550565b6000600160a060020a0382161515611d8557600080fd5b50600160a060020a031660009081526002602052604090205490565b600b54600090600160a060020a03163314611dbb57600080fd5b600160a060020a0382166000908152600c602052604090205460ff161515610c8957600160a060020a0382166000818152600c6020908152604091829020805460ff19166001179055815192835290517fd1bba68c128cc3f427e5831b3c6f99f480b6efa6b9e80c757768f6124158cc3f9281900390910190a1506001919050565b601454600160a060020a031681565b600b54600160a060020a0316331480611e6f5750600d54600160a060020a031633145b1515611eeb576040805160e560020a62461bcd02815260206004820152602360248201527f4f6e6c79206f776e657220616e6420747265617375726520686176652061636360448201527f6573730000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b611791613825565b6000806060611f00614272565b600080600080611f0e6141fc565b600080611f1a8d613798565b995060058a02604051908082528060200260200182016040528015611f49578160200160208202803883390190505b509850601460009054906101000a9004600160a060020a0316600160a060020a031663ccf9bbb68d6040518263ffffffff1660e060020a028152600401808281526020019150506040805180830381600087803b158015611fa957600080fd5b505af1158015611fbd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052506040811015611fe257600080fd5b508051602082015191995097508701600019019550600094508493505b8984101561209257612014611a038e866137b3565b9250600191505b60058210156120875760a0830151826005811061203457fe5b6020020151905080151561204757612087565b8681101580156120575750858111155b1561207c5780898681518110151561206b57fe5b602090810290910101526001909401935b60019091019061201b565b600190930192611fff565b60008511156120c557886120aa6000600188036138a2565b815181106120b457fe5b906020019060200201519a506120cb565b6000199a505b5050505050505050505092915050565b600b54600160a060020a031681565b600b54600160a060020a031633148061210d5750600d54600160a060020a031633145b1515612189576040805160e560020a62461bcd02815260206004820152602360248201527f4f6e6c79206f776e657220616e6420747265617375726520686176652061636360448201527f6573730000000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b601660009054906101000a9004600160a060020a0316600160a060020a0316635fd8c7106040518163ffffffff1660e060020a028152600401600060405180830381600087803b1580156121dc57600080fd5b505af11580156117d7573d6000803e3d6000fd5b600b54600090600160a060020a0316331461220a57600080fd5b81905080600160a060020a0316639bd593e36040518163ffffffff1660e060020a028152600401602060405180830381600087803b15801561224b57600080fd5b505af115801561225f573d6000803e3d6000fd5b505050506040513d602081101561227557600080fd5b505115156122cd576040805160e560020a62461bcd02815260206004820152601760248201527f496e636f7272656374206164647265737320706172616d000000000000000000604482015290519081900360640190fd5b60158054600160a060020a031916600160a060020a039290921691909117905550565b60058054604080516020601f6002600019610100600188161502019095169490940493840181900481028201810190925282815260609390929091830182828015610c655780601f10610c3a57610100808354040283529160200191610c65565b600c6020526000908152604090205460ff1681565b600160a060020a03821633141561237c57600080fd5b336000818152600360209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6123f26141fc565b336000908152600c602052604090205460ff16151561241057600080fd5b6124198261303c565b90506124258382613157565b9050610d6e828261343e565b600061243b614253565b612443614253565b61244b6141fc565b6124548561303c565b604081015160a082015160e0909201519097919650945092505050565b8161247c338261346d565b151561248757600080fd5b612492858585610f57565b61249e858585856138d6565b1515610f5057600080fd5b61271081565b6124b7614272565b6124bf61428d565b6124c761428d565b6124cf61428d565b6124d76141fc565b600b54600160a060020a031633146124ee57600080fd5b600f5415612546576040805160e560020a62461bcd02815260206004820152601160248201527f4561727468207761732063726561746564000000000000000000000000000000604482015290519081900360640190fd5b60148054604080517fbe8fb1c100000000000000000000000000000000000000000000000000000000815260048101939093528051600160a060020a039092169263be8fb1c192602480830193928290030181600087803b1580156125aa57600080fd5b505af11580156125be573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525060408110156125e357600080fd5b50601454604080517fe4c5efe9000000000000000000000000000000000000000000000000000000008152601560048201529051929750600160a060020a039091169163e4c5efe9916024808201926060929091908290030181600087803b15801561264e57600080fd5b505af1158015612662573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250606081101561268757600080fd5b50601454604080517fe4c5efe9000000000000000000000000000000000000000000000000000000008152601660048201529051929650600160a060020a039091169163e4c5efe9916024808201926060929091908290030181600087803b1580156126f257600080fd5b505af1158015612706573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250606081101561272b57600080fd5b50601454604080517fe4c5efe9000000000000000000000000000000000000000000000000000000008152601860048201529051929550600160a060020a039091169163e4c5efe9916024808201926060929091908290030181600087803b15801561279657600080fd5b505af11580156127aa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525060608110156127cf57600080fd5b5060408051610100810182526003815242602080830182905282840191909152885160608084019190915289820151608080850191909152845160a080820187528b5182528b850151828601528b87015182880152600082850181905282840181905281870192909252865180820188528b5181528b860151818701528b8801518189015280850183905280840183905260c087015286519081018752875181528785015194810194909452868601519584019590955290820184905281019290925260e081019190915290925090506128a98682613a46565b50505050505050565b60006128bc6141fc565b336000908152600c602052604090205460ff1615156128da57600080fd5b6128e686868686613d2f565b90506128f28782613a46565b979650505050505050565b6060612908826118dd565b151561291357600080fd5b6000828152600a602090815260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156129a65780601f1061297b576101008083540402835291602001916129a6565b820191906000526020600020905b81548152906001019060200180831161298957829003601f168201915b50505050509050919050565b6000806000806000806129c36141fc565b336000908152600c6020526040812054819060ff1615156129e357600080fd5b6129ec8c613798565b9850600097505b6005881015612bc4578a8860058110612a0857fe5b60200201359650898860058110612a1b57fe5b60200201359550851515612a2e57612bb9565b600094505b88851015612b6057851515612a4757612b60565b612a518c866137b3565b9350612a5c8461303c565b925061270f9150600090505b6005811015612a9d5760a08301518160058110612a8157fe5b6020020151871415612a9557809150612a9d565b600101612a68565b8161270f1415612aac57612b55565b612ab68c84613157565b925060008360e0015183600581101515612acc57fe5b60200201511115612b4b5760e083015186908360058110612ae957fe5b602002015110612b1a5760e083015186908360058110612b0557fe5b60200201805191909103905260009550612b4b565b60e08301518260058110612b2a57fe5b602002015160e08401519603956000908360058110612b4557fe5b60200201525b612b55848461343e565b600190940193612a33565b6000861115612bb9576040805160e560020a62461bcd02815260206004820152601260248201527f4e6f74456e6f7567685265736f75726365730000000000000000000000000000604482015290519081900360640190fd5b6001909701966129f3565b505050505050505050505050565b600b546000908190600160a060020a03163314612bee57600080fd5b5060005b825181101561106157612c1b8382815181101515612c0c57fe5b90602001906020020151611da1565b15612c2557600191505b600101612bf2565b601654600160a060020a031681565b600160a060020a03918216600090815260036020908152604080832093909416825291909152205460ff1690565b600091825260126020908152604080842092845291905290205490565b600b54600160a060020a03163314612c9e57600080fd5b600160a060020a0381161515612cb357600080fd5b600b54604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600b8054600160a060020a031916600160a060020a0392909216919091179055565b336000908152600c602052604090205460ff161515612d2d57600080fd5b601980546001019081905561271011611791576040805160e560020a62461bcd02815260206004820152601d60248201527f50726f6d6f20706c616e6574206c696d69742069732072656163686564000000604482015290519081900360640190fd5b600080600080600080612da16141fc565b336000908152600c602052604081205460ff161515612dbf57600080fd5b600160a060020a038a16600090815260176020526040902054891115612fe4576014546040805160e060020a6364c66395028152602260048201529051600160a060020a03909216916364c66395916024808201926020929091908290030181600087803b158015612e3057600080fd5b505af1158015612e44573d6000803e3d6000fd5b505050506040513d6020811015612e5a57600080fd5b5051600160a060020a038b16600090815260176020526040902054909850620151808a81029850029550612e8d8a613798565b945060009350600092505b84831015612f8d57612ead611a038b856137b3565b915087612eba8b846137d7565b612ec26136ee565b0302905080601460009054906101000a9004600160a060020a0316600160a060020a03166364c6639560116040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b158015612f2657600080fd5b505af1158015612f3a573d6000803e3d6000fd5b505050506040513d6020811015612f5057600080fd5b505160c0840151612f649084906000611abb565b60e0850151510102029590950194868610612f825760019350612f8d565b600190920191612e98565b831515612fe4576040805160e560020a62461bcd02815260206004820152601260248201527f4e6f74456e6f7567684b6e6f776c656467650000000000000000000000000000604482015290519081900360640190fd5b600160a060020a038a166000908152601760205260408120556130056136ee565b600160a060020a03909a16600090815260186020526040902099909955505050505050505050565b600d54600160a060020a031681565b6130446141fc565b600080600f8481548110151561305657fe5b60009182526020808320909101548683526010825260409092205465ffffffffffff831691860191909152909250905061309f64ffffffffff6601000000000000840416613e38565b60a08401526130c264ffffffffff6b010000000000000000000000840416613e38565b60c084015260ff700100000000000000000000000000000000830481166060850152710100000000000000000000000000000000008304811660808501527201000000000000000000000000000000000000830416835265ffffffffffff8116604084015261314a69ffffffffffffffffffff6b010000000000000000000000830416613e71565b60e0840152509092915050565b61315f6141fc565b6014546040805160e060020a6364c66395028152602260048201529051600092839283928392839283928392600160a060020a0316916364c6639591602480830192602092919082900301818787803b1580156131bb57600080fd5b505af11580156131cf573d6000803e3d6000fd5b505050506040513d60208110156131e557600080fd5b50519650866131f48b8b6137d7565b6131fc6136ee565b0302955085601460009054906101000a9004600160a060020a0316600160a060020a03166364c6639560116040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b15801561326057600080fd5b505af1158015613274573d6000803e3d6000fd5b505050506040513d602081101561328a57600080fd5b505160c08b015161329e9089906000611abb565b60e08c01515101020294506132b685620151806136f2565b600160a060020a038b1660009081526017602052604090819020805490920190915589015187906132e56136ee565b03029350601460009054906101000a9004600160a060020a0316600160a060020a03166364c6639560126040518263ffffffff1660e060020a02815260040180828152602001915050602060405180830381600087803b15801561334857600080fd5b505af115801561335c573d6000803e3d6000fd5b505050506040513d602081101561337257600080fd5b50519250600091505b60058210156134305760c0890151826005811061339457fe5b602002015115156133a457613425565b6133ba848a60c00151846005811015156115b457fe5b60e08a015183600581106133ca57fe5b602002018051909101905260c0890151839083600581106133e757fe5b6020020151029050808960e001518360058110151561340257fe5b602002015111156134255760e08901518190836005811061341f57fe5b60200201525b60019091019061337b565b509698975050505050505050565b60006134486136ee565b604083015261345682613eab565b600093845260106020526040909320929092555050565b60008061347983611bf7565b905080600160a060020a031684600160a060020a031614806134b4575083600160a060020a03166134a984610c70565b600160a060020a0316145b806134c457506134c48185612c3c565b949350505050565b81600160a060020a03166134df82611bf7565b600160a060020a0316146134f257600080fd5b600081815260016020526040902054600160a060020a031615611bae5760008181526001602090815260408083208054600160a060020a031916905580518481529051600160a060020a038616927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925928290030190a35050565b600080600061357b8585613ee6565b600084815260076020908152604080832054600160a060020a03891684526006909252909120549093506135b690600163ffffffff613f6e16565b600160a060020a0386166000908152600660205260409020805491935090839081106135de57fe5b90600052602060002001549050806006600087600160a060020a0316600160a060020a031681526020019081526020016000208481548110151561361e57fe5b6000918252602080832090910192909255600160a060020a038716815260069091526040812080548490811061365057fe5b6000918252602080832090910192909255600160a060020a03871681526006909152604090208054906136879060001983016142ac565b50600093845260076020526040808520859055908452909220555050565b60006136b18383613f80565b50600160a060020a039091166000908152600660209081526040808320805460018101825590845282842081018590559383526007909152902055565b4290565b600081838115156136ff57fe5b04905060028204828481151561371157fe5b06106111665760010192915050565b600b54600160a060020a0316331461373757600080fd5b600d5460a060020a900460ff16151561374f57600080fd5b600d805474ff0000000000000000000000000000000000000000191690556040517f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3390600090a1565b600160a060020a031660009081526006602052604090205490565b600160a060020a038216600090815260066020526040812080548390811061115857fe5b600160a060020a03821660009081526018602052604080822054908301511161381857600160a060020a03831660009081526018602052604090205461381e565b81604001515b9392505050565b600b54600160a060020a0316331461383c57600080fd5b600d5460a060020a900460ff161561385357600080fd5b600d805474ff0000000000000000000000000000000000000000191660a060020a1790556040517f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62590600090a1565b6000828383036001016138b3614002565b60408051918252519081900360200190208115156138cd57fe5b06019392505050565b6000806138eb85600160a060020a031661403b565b15156138fa5760019150613a3d565b84600160a060020a031663f0b9e5ba8786866040518463ffffffff1660e060020a0281526004018084600160a060020a0316600160a060020a0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015613979578181015183820152602001613961565b50505050905090810190601f1680156139a65780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b1580156139c757600080fd5b505af11580156139db573d6000803e3d6000fd5b505050506040513d60208110156139f157600080fd5b50517fffffffff0000000000000000000000000000000000000000000000000000000081167ff0b9e5ba0000000000000000000000000000000000000000000000000000000014925090505b50949350505050565b6000806000806000613a5786614043565b9350613a6286613eab565b600f8054600181019091557f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802810186905560008181526010602052604090208290559093509150620f42408210613b03576040805160e560020a62461bcd02815260206004820152600f60248201527f4e6f206d6f726520706c616e6574730000000000000000000000000000000000604482015290519081900360640190fd5b8187600160a060020a03167ff54657dd54b8d60149296317ff8dd81a5f9d0ed22aa82d92db76bc5ce97973c4886060015189608001518a600001518b60a001518c60c001518d60e001516000600581101515613b5b57fe5b60200201516040518087815260200186815260200185815260200184600560200280838360005b83811015613b9a578181015183820152602001613b82565b5050505090500183600560200280838360005b83811015613bc5578181015183820152602001613bad565b50505050905001828152602001965050505050505060405180910390a36060860151600090815260116020908152604080832060808a01518452909152902080546001019055855160031415613cde5760145460608701516080880151604080517f7944013a0000000000000000000000000000000000000000000000000000000081526004810193909352602483019190915251600160a060020a0390921691637944013a916044808201926020929091908290030181600087803b158015613c8e57600080fd5b505af1158015613ca2573d6000803e3d6000fd5b505050506040513d6020811015613cb857600080fd5b505160008181526012602090815260408083206003845290915290208054600101905590505b855160041415613d1b57600460005260136020527f01413ff7a3b1d5b6c016c061d48e2c7014700c777a29fcd068fff04265813d5d805460010190555b613d2587836140d0565b5095945050505050565b613d376141fc565b613d3f614253565b613d47614253565b613d4f614253565b601554604080517f570bb139000000000000000000000000000000000000000000000000000000008152600481018b90529051600160a060020a039092169163570bb13991602480820192610140929091908290030181600087803b158015613db757600080fd5b505af1158015613dcb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250610140811015613df157600080fd5b5094815260408051610100810182529889524260208a01819052908901526060880196909652505050608084019190915260a08381018290520160c083015260e082015290565b613e40614253565b60005b60058110156110615760ff6008820260020a840416828260058110613e6457fe5b6020020152600101613e43565b613e79614253565b60005b60058110156110615761ffff6010820260020a840416828260058110613e9e57fe5b6020020152600101613e7c565b604081015160a0820151603090613ec19061411f565b9060020a02811790506058613ed98360e00151614155565b60029190910a0217919050565b81600160a060020a0316613ef982611bf7565b600160a060020a031614613f0c57600080fd5b600160a060020a038216600090815260026020526040902054613f3690600163ffffffff613f6e16565b600160a060020a0390921660009081526002602090815260408083209490945591815290819052208054600160a060020a0319169055565b600082821115613f7a57fe5b50900390565b600081815260208190526040902054600160a060020a031615613fa257600080fd5b6000818152602081815260408083208054600160a060020a031916600160a060020a03871690811790915583526002909152902054613fe290600161418b565b600160a060020a0390921660009081526002602052604090209190915550565b600e8054606433067f028f5c28f5c28f5c28f5c28f5c28f5c28f5c28f5c28f5c28f5c28f5c28f5c28f4360001901400401019081905590565b6000903b1190565b602081015160a08201516030906140599061411f565b9060020a028117905060586140718360c0015161411f565b6060840151608085015194517201000000000000000000000000000000000000027101000000000000000000000000000000000090950270010000000000000000000000000000000090910260029390930a9091029290921717171790565b6140da8282614198565b600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3015550565b6000805b6005811015611061576008810283826005811061413c57fe5b602002015160029190910a029190911790600101614123565b6000805b6005811015611061576010810283826005811061417257fe5b602002015160029190910a029190911790600101614159565b8181018281101561116657fe5b600160a060020a03821615156141ad57600080fd5b6141b782826136a5565b604080518281529051600160a060020a038416916000917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b610280604051908101604052806000815260200160008152602001600081526020016000815260200160008152602001614234614253565b8152602001614241614253565b815260200161424e614253565b905290565b60a0604051908101604052806005906020820280388339509192915050565b60408051808201825290600290829080388339509192915050565b6060604051908101604052806003906020820280388339509192915050565b815481835581811115610d6e57600083815260209020610d6e918101908301610c6d91905b808211156142e557600081556001016142d1565b50905600a165627a7a72305820cc930dfb63da67c2f11234443ecfc4eb23d21eebbbcec6ea66063eba28a673cb0029

Verified Source Code Partial Match

Compiler: v0.4.24+commit.e67f0147 EVM: byzantium Optimization: Yes (200 runs)
UniverseGalaxy.sol 1688 lines
pragma solidity 0.4.24;

// File: contracts/Auction/ISaleClockAuction.sol

contract ISaleClockAuction {

    function isSaleClockAuction() public returns(bool);


    /// @dev Creates and begins a new auction.
    /// @param _tokenId - ID of token to auction, sender must be owner.
    /// @param _startingPrice - Price of item (in wei) at beginning of auction.
    /// @param _endingPrice - Price of item (in wei) at end of auction.
    /// @param _duration - Length of auction (in seconds).
    /// @param _seller - Seller, if not the message sender
    function createAuction(
        uint256 _tokenId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration,
        address _seller
    )
    external;

    /// @dev Updates lastSalePrice if seller is the nft contract
    /// Otherwise, works the same as default bid method.
    function bid(uint256 _tokenId)
    external
    payable;

    function cancelAuction(uint256 _tokenId)
    external;

    // cancel all old auctions
    function clearAll(address _seller, uint planetLimitation)
    external;

    // cancel an old auction for the token id
    function clearOne(address _seller, uint256 _tokenId)
    external;

    function averageExpansionSalePrice(uint256 _rarity) external view returns (uint256);

    function withdrawBalance() external;
}

// File: contracts/Common/ArrayArchiveTools.sol

contract ArrayArchiveTools {

    function _splitUint40ToArray(uint256 _hash) internal pure returns (uint256[5] _array) {
        for (uint i = 0; i < 5; i++) {
            _array[i] = uint256(uint8(_hash >> (8 * i)));
        }
    }

    function _mergeArrayToUint40(uint256[5] _array) internal pure returns (uint256 _hash) {
        for (uint i = 0; i < 5; i++) {
            _hash |= (_array[i] << (8 * i));
        }
    }

    function _splitUint80ToArray(uint256 _hash) internal pure returns (uint256[5] _array) {
        for (uint i = 0; i < 5; i++) {
            _array[i] = uint256(uint16(_hash >> (16 * i)));
        }
    }

    function _mergeArrayToUint80(uint256[5] _array) internal pure returns (uint256 _hash) {
        for (uint i = 0; i < 5; i++) {
            _hash |= (_array[i] << (16 * i));
        }
    }
}

// File: contracts/Common/MathTools.sol

contract MathTools {
    function _divisionWithRound(uint _numerator, uint _denominator) internal pure returns (uint _r) {
        _r = _numerator / _denominator;
        if (_numerator % _denominator >= _denominator / 2) {
            _r++;
        }
    }
}

// File: contracts/Discovery/UniverseDiscoveryConstant.sol

//TODO: run as separate contract
contract UniverseDiscoveryConstant {
    //ships
    uint256 internal constant MAX_RANKS_COUNT = 20;

    //resources
    uint256 internal constant MAX_ID_LIST_LENGTH = 5;
}

// File: contracts/PlanetExploration/IUniversePlanetExploration.sol

contract IUniversePlanetExploration is UniverseDiscoveryConstant {

    function isUniversePlanetExploration() external returns(bool);

    function explorePlanet(uint256 _rarity)
    external
    returns (
        uint[MAX_ID_LIST_LENGTH] resourcesId,
        uint[MAX_ID_LIST_LENGTH] resourcesVelocity
    );
}

// File: openzeppelin-solidity/contracts/ownership/Ownable.sol

/**
 * @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));
    emit OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }

}

// File: contracts/Access/Treasurer.sol

contract Treasurer is Ownable {
    address public treasurer;

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

    function transferTreasurer(address _treasurer) public onlyOwner {
        if (_treasurer != address(0)) {
            treasurer = _treasurer;
        }
    }
}

// File: openzeppelin-solidity/contracts/lifecycle/Pausable.sol

/**
 * @title Pausable
 * @dev Base contract which allows children to implement an emergency stop mechanism.
 */
contract Pausable is Ownable {
  event Pause();
  event Unpause();

  bool public paused = false;


  /**
   * @dev Modifier to make a function callable only when the contract is not paused.
   */
  modifier whenNotPaused() {
    require(!paused);
    _;
  }

  /**
   * @dev Modifier to make a function callable only when the contract is paused.
   */
  modifier whenPaused() {
    require(paused);
    _;
  }

  /**
   * @dev called by the owner to pause, triggers stopped state
   */
  function pause() onlyOwner whenNotPaused public {
    paused = true;
    emit Pause();
  }

  /**
   * @dev called by the owner to unpause, returns to normal state
   */
  function unpause() onlyOwner whenPaused public {
    paused = false;
    emit Unpause();
  }
}

// File: contracts/Access/AccessControl.sol

contract AccessControl is Ownable, Treasurer, Pausable {

    modifier onlyTeam() {
        require(
            msg.sender == owner ||
            msg.sender == treasurer
        , "Only owner and treasure have access"
        );
        _;
    }

    function pause() public onlyTeam {
        return super.pause();
    }
}

// File: contracts/Common/Random.sol

//TODO: Should be moved to separate library
contract Random {
    uint internal saltForRandom;

    function _rand() internal returns (uint256) {
        uint256 lastBlockNumber = block.number - 1;

        uint256 hashVal = uint256(blockhash(lastBlockNumber));

        // This turns the input data into a 100-sided die
        // by dividing by ceil(2 ^ 256 / 100).
        uint256 factor = 1157920892373161954235709850086879078532699846656405640394575840079131296399;

        saltForRandom += uint256(msg.sender) % 100 + uint256(uint256(hashVal) / factor);

        return saltForRandom;
    }

    function _randRange(uint256 min, uint256 max) internal returns (uint256) {
        return uint256(keccak256(_rand())) % (max - min + 1) + min;
    }

    function _randChance(uint percent) internal returns (bool) {
        return _randRange(0, 100) < percent;
    }

    function _now() internal view returns (uint256) {
        return now;
    }
}

// File: contracts/Settings/IUniverseBalance.sol

contract IUniverseBalance {
    function isUniverseBalance() external returns(bool);

    function autoClearAuction() external returns(bool);

    function getUIntValue(uint record) external view returns (uint);
    function getUIntArray2Value(uint record) external view returns (uint[2]);
    function getUIntArray3Value(uint record) external view returns (uint[3]);
    function getUIntArray4Value(uint record) external view returns (uint[4]);

    function getRankParamsValue(uint rankId) external view returns (uint[3]);
    function getRankResourcesCountByRarity(uint rankId) external view returns (uint[4]);

    function getGroupId(uint _x, uint _y) external view returns (uint);

    function getResourcesQuantityByRarity(uint256 rarity) external pure returns (uint256[2]);
}

// File: contracts/Galaxy/UniverseGalaxyConstant.sol

//TODO: run as separate contract
contract UniverseGalaxyConstant {
    //map
    uint256 internal constant SECTOR_X_MAX = 25;
    uint256 internal constant SECTOR_Y_MAX = 40;

    uint256 internal constant PLANETS_COUNT = 1000000;

    uint256 internal constant SECTORS_COUNT = SECTOR_X_MAX * SECTOR_Y_MAX; // 1000

    uint256 internal constant PLANETS_COUNT_PER_SECTOR = PLANETS_COUNT / SECTORS_COUNT; // 1000000 / 1000 = 1000

    //resources
    uint256 internal constant MAX_ID_LIST_LENGTH = 5;
}

// File: openzeppelin-solidity/contracts/token/ERC721/ERC721Basic.sol

/**
 * @title ERC721 Non-Fungible Token Standard basic interface
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Basic {
  event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
  event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);
  event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

  function balanceOf(address _owner) public view returns (uint256 _balance);
  function ownerOf(uint256 _tokenId) public view returns (address _owner);
  function exists(uint256 _tokenId) public view returns (bool _exists);

  function approve(address _to, uint256 _tokenId) public;
  function getApproved(uint256 _tokenId) public view returns (address _operator);

  function setApprovalForAll(address _operator, bool _approved) public;
  function isApprovedForAll(address _owner, address _operator) public view returns (bool);

  function transferFrom(address _from, address _to, uint256 _tokenId) public;
  function safeTransferFrom(address _from, address _to, uint256 _tokenId) public;
  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    public;
}

// File: contracts/Galaxy/IUniverseGalaxy.sol

contract IUniverseGalaxy is ERC721Basic, UniverseGalaxyConstant{

    function getPlanet(uint256 _id) external view
    returns (
        uint256 rarity,
        uint256 discovered,
        uint256 sectorX,
        uint256 sectorY,
        uint256[MAX_ID_LIST_LENGTH] resourcesId,
        uint256[MAX_ID_LIST_LENGTH] resourcesVelocity
    );

    function createSaleAuction(uint256 _planetId, uint256 _startingPrice, uint256 _endingPrice, uint256 _duration) external;

    function findAvailableResource(address _owner, uint _rarity) external returns (int8);
    function getDiscoveredPlanetsDensity(uint sectorX, uint sectorY) external view returns (uint);

    function createPlanet(
        address _owner,
        uint256 _rarity,
        uint256 _sectorX,
        uint256 _sectorY,
        uint256 _startPopulation
    ) external returns(uint256);

    function spendResources(address _owner, uint[MAX_ID_LIST_LENGTH] _resourcesId, uint[MAX_ID_LIST_LENGTH] _resourcesNeeded) external;

    function spendResourceOnPlanet(address _owner, uint _planetId, uint _resourceId, uint _resourceValue) external;

    function spendKnowledge(address _owner, uint _spentKnowledge) external;

    function recountPlanetResourcesAndUserKnowledge(address _owner, uint256 _planetId) external;

    function countPlanetsByRarityInGroup(uint _groupIndex, uint _rarity) external view returns (uint);

    function countPlanetsByRarity(uint _rarity) external view returns (uint);

    function checkWhetherEnoughPromoPlanet() external;
}

// File: openzeppelin-solidity/contracts/ownership/Whitelist.sol

/**
 * @title Whitelist
 * @dev The Whitelist contract has a whitelist of addresses, and provides basic authorization control functions.
 * @dev This simplifies the implementation of "user permissions".
 */
contract Whitelist is Ownable {
  mapping(address => bool) public whitelist;

  event WhitelistedAddressAdded(address addr);
  event WhitelistedAddressRemoved(address addr);

  /**
   * @dev Throws if called by any account that's not whitelisted.
   */
  modifier onlyWhitelisted() {
    require(whitelist[msg.sender]);
    _;
  }

  /**
   * @dev add an address to the whitelist
   * @param addr address
   * @return true if the address was added to the whitelist, false if the address was already in the whitelist
   */
  function addAddressToWhitelist(address addr) onlyOwner public returns(bool success) {
    if (!whitelist[addr]) {
      whitelist[addr] = true;
      emit WhitelistedAddressAdded(addr);
      success = true;
    }
  }

  /**
   * @dev add addresses to the whitelist
   * @param addrs addresses
   * @return true if at least one address was added to the whitelist,
   * false if all addresses were already in the whitelist
   */
  function addAddressesToWhitelist(address[] addrs) onlyOwner public returns(bool success) {
    for (uint256 i = 0; i < addrs.length; i++) {
      if (addAddressToWhitelist(addrs[i])) {
        success = true;
      }
    }
  }

  /**
   * @dev remove an address from the whitelist
   * @param addr address
   * @return true if the address was removed from the whitelist,
   * false if the address wasn't in the whitelist in the first place
   */
  function removeAddressFromWhitelist(address addr) onlyOwner public returns(bool success) {
    if (whitelist[addr]) {
      whitelist[addr] = false;
      emit WhitelistedAddressRemoved(addr);
      success = true;
    }
  }

  /**
   * @dev remove addresses from the whitelist
   * @param addrs addresses
   * @return true if at least one address was removed from the whitelist,
   * false if all addresses weren't in the whitelist in the first place
   */
  function removeAddressesFromWhitelist(address[] addrs) onlyOwner public returns(bool success) {
    for (uint256 i = 0; i < addrs.length; i++) {
      if (removeAddressFromWhitelist(addrs[i])) {
        success = true;
      }
    }
  }

}

// File: openzeppelin-solidity/contracts/token/ERC721/ERC721.sol

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Enumerable is ERC721Basic {
  function totalSupply() public view returns (uint256);
  function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256 _tokenId);
  function tokenByIndex(uint256 _index) public view returns (uint256);
}


/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Metadata is ERC721Basic {
  function name() public view returns (string _name);
  function symbol() public view returns (string _symbol);
  function tokenURI(uint256 _tokenId) public view returns (string);
}


/**
 * @title ERC-721 Non-Fungible Token Standard, full implementation interface
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721 is ERC721Basic, ERC721Enumerable, ERC721Metadata {
}

// File: openzeppelin-solidity/contracts/AddressUtils.sol

/**
 * Utility library of inline functions on addresses
 */
library AddressUtils {

  /**
   * Returns whether the target address is a contract
   * @dev This function will return false if invoked during the constructor of a contract,
   *  as the code is not actually created until after the constructor finishes.
   * @param addr address to check
   * @return whether the target address is a contract
   */
  function isContract(address addr) internal view returns (bool) {
    uint256 size;
    // XXX Currently there is no better way to check if there is a contract in an address
    // than to check the size of the code at that address.
    // See https://ethereum.stackexchange.com/a/14016/36603
    // for more details about how this works.
    // TODO Check this again before the Serenity release, because all addresses will be
    // contracts then.
    assembly { size := extcodesize(addr) }  // solium-disable-line security/no-inline-assembly
    return size > 0;
  }

}

// File: openzeppelin-solidity/contracts/math/SafeMath.sol

/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {

  /**
  * @dev Multiplies two numbers, throws on overflow.
  */
  function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
    if (a == 0) {
      return 0;
    }
    c = a * b;
    assert(c / a == b);
    return c;
  }

  /**
  * @dev Integer division of two numbers, truncating the quotient.
  */
  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    // uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return a / b;
  }

  /**
  * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
  function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
    c = a + b;
    assert(c >= a);
    return c;
  }
}

// File: openzeppelin-solidity/contracts/token/ERC721/ERC721Receiver.sol

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 *  from ERC721 asset contracts.
 */
contract ERC721Receiver {
  /**
   * @dev Magic value to be returned upon successful reception of an NFT
   *  Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`,
   *  which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
   */
  bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;

  /**
   * @notice Handle the receipt of an NFT
   * @dev The ERC721 smart contract calls this function on the recipient
   *  after a `safetransfer`. This function MAY throw to revert and reject the
   *  transfer. This function MUST use 50,000 gas or less. Return of other
   *  than the magic value MUST result in the transaction being reverted.
   *  Note: the contract address is always the message sender.
   * @param _from The sending address
   * @param _tokenId The NFT identifier which is being transfered
   * @param _data Additional data with no specified format
   * @return `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
   */
  function onERC721Received(address _from, uint256 _tokenId, bytes _data) public returns(bytes4);
}

// File: openzeppelin-solidity/contracts/token/ERC721/ERC721BasicToken.sol

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721BasicToken is ERC721Basic {
  using SafeMath for uint256;
  using AddressUtils for address;

  // Equals to `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
  // which can be also obtained as `ERC721Receiver(0).onERC721Received.selector`
  bytes4 constant ERC721_RECEIVED = 0xf0b9e5ba;

  // Mapping from token ID to owner
  mapping (uint256 => address) internal tokenOwner;

  // Mapping from token ID to approved address
  mapping (uint256 => address) internal tokenApprovals;

  // Mapping from owner to number of owned token
  mapping (address => uint256) internal ownedTokensCount;

  // Mapping from owner to operator approvals
  mapping (address => mapping (address => bool)) internal operatorApprovals;

  /**
   * @dev Guarantees msg.sender is owner of the given token
   * @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
   */
  modifier onlyOwnerOf(uint256 _tokenId) {
    require(ownerOf(_tokenId) == msg.sender);
    _;
  }

  /**
   * @dev Checks msg.sender can transfer a token, by being owner, approved, or operator
   * @param _tokenId uint256 ID of the token to validate
   */
  modifier canTransfer(uint256 _tokenId) {
    require(isApprovedOrOwner(msg.sender, _tokenId));
    _;
  }

  /**
   * @dev Gets the balance of the specified address
   * @param _owner address to query the balance of
   * @return uint256 representing the amount owned by the passed address
   */
  function balanceOf(address _owner) public view returns (uint256) {
    require(_owner != address(0));
    return ownedTokensCount[_owner];
  }

  /**
   * @dev Gets the owner of the specified token ID
   * @param _tokenId uint256 ID of the token to query the owner of
   * @return owner address currently marked as the owner of the given token ID
   */
  function ownerOf(uint256 _tokenId) public view returns (address) {
    address owner = tokenOwner[_tokenId];
    require(owner != address(0));
    return owner;
  }

  /**
   * @dev Returns whether the specified token exists
   * @param _tokenId uint256 ID of the token to query the existance of
   * @return whether the token exists
   */
  function exists(uint256 _tokenId) public view returns (bool) {
    address owner = tokenOwner[_tokenId];
    return owner != address(0);
  }

  /**
   * @dev Approves another address to transfer the given token ID
   * @dev The zero address indicates there is no approved address.
   * @dev There can only be one approved address per token at a given time.
   * @dev Can only be called by the token owner or an approved operator.
   * @param _to address to be approved for the given token ID
   * @param _tokenId uint256 ID of the token to be approved
   */
  function approve(address _to, uint256 _tokenId) public {
    address owner = ownerOf(_tokenId);
    require(_to != owner);
    require(msg.sender == owner || isApprovedForAll(owner, msg.sender));

    if (getApproved(_tokenId) != address(0) || _to != address(0)) {
      tokenApprovals[_tokenId] = _to;
      emit Approval(owner, _to, _tokenId);
    }
  }

  /**
   * @dev Gets the approved address for a token ID, or zero if no address set
   * @param _tokenId uint256 ID of the token to query the approval of
   * @return address currently approved for a the given token ID
   */
  function getApproved(uint256 _tokenId) public view returns (address) {
    return tokenApprovals[_tokenId];
  }

  /**
   * @dev Sets or unsets the approval of a given operator
   * @dev An operator is allowed to transfer all tokens of the sender on their behalf
   * @param _to operator address to set the approval
   * @param _approved representing the status of the approval to be set
   */
  function setApprovalForAll(address _to, bool _approved) public {
    require(_to != msg.sender);
    operatorApprovals[msg.sender][_to] = _approved;
    emit ApprovalForAll(msg.sender, _to, _approved);
  }

  /**
   * @dev Tells whether an operator is approved by a given owner
   * @param _owner owner address which you want to query the approval of
   * @param _operator operator address which you want to query the approval of
   * @return bool whether the given operator is approved by the given owner
   */
  function isApprovedForAll(address _owner, address _operator) public view returns (bool) {
    return operatorApprovals[_owner][_operator];
  }

  /**
   * @dev Transfers the ownership of a given token ID to another address
   * @dev Usage of this method is discouraged, use `safeTransferFrom` whenever possible
   * @dev Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
  */
  function transferFrom(address _from, address _to, uint256 _tokenId) public canTransfer(_tokenId) {
    require(_from != address(0));
    require(_to != address(0));

    clearApproval(_from, _tokenId);
    removeTokenFrom(_from, _tokenId);
    addTokenTo(_to, _tokenId);

    emit Transfer(_from, _to, _tokenId);
  }

  /**
   * @dev Safely transfers the ownership of a given token ID to another address
   * @dev If the target address is a contract, it must implement `onERC721Received`,
   *  which is called upon a safe transfer, and return the magic value
   *  `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`; otherwise,
   *  the transfer is reverted.
   * @dev Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
  */
  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId
  )
    public
    canTransfer(_tokenId)
  {
    // solium-disable-next-line arg-overflow
    safeTransferFrom(_from, _to, _tokenId, "");
  }

  /**
   * @dev Safely transfers the ownership of a given token ID to another address
   * @dev If the target address is a contract, it must implement `onERC721Received`,
   *  which is called upon a safe transfer, and return the magic value
   *  `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`; otherwise,
   *  the transfer is reverted.
   * @dev Requires the msg sender to be the owner, approved, or operator
   * @param _from current owner of the token
   * @param _to address to receive the ownership of the given token ID
   * @param _tokenId uint256 ID of the token to be transferred
   * @param _data bytes data to send along with a safe transfer check
   */
  function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    public
    canTransfer(_tokenId)
  {
    transferFrom(_from, _to, _tokenId);
    // solium-disable-next-line arg-overflow
    require(checkAndCallSafeTransfer(_from, _to, _tokenId, _data));
  }

  /**
   * @dev Returns whether the given spender can transfer a given token ID
   * @param _spender address of the spender to query
   * @param _tokenId uint256 ID of the token to be transferred
   * @return bool whether the msg.sender is approved for the given token ID,
   *  is an operator of the owner, or is the owner of the token
   */
  function isApprovedOrOwner(address _spender, uint256 _tokenId) internal view returns (bool) {
    address owner = ownerOf(_tokenId);
    return _spender == owner || getApproved(_tokenId) == _spender || isApprovedForAll(owner, _spender);
  }

  /**
   * @dev Internal function to mint a new token
   * @dev Reverts if the given token ID already exists
   * @param _to The address that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   */
  function _mint(address _to, uint256 _tokenId) internal {
    require(_to != address(0));
    addTokenTo(_to, _tokenId);
    emit Transfer(address(0), _to, _tokenId);
  }

  /**
   * @dev Internal function to burn a specific token
   * @dev Reverts if the token does not exist
   * @param _tokenId uint256 ID of the token being burned by the msg.sender
   */
  function _burn(address _owner, uint256 _tokenId) internal {
    clearApproval(_owner, _tokenId);
    removeTokenFrom(_owner, _tokenId);
    emit Transfer(_owner, address(0), _tokenId);
  }

  /**
   * @dev Internal function to clear current approval of a given token ID
   * @dev Reverts if the given address is not indeed the owner of the token
   * @param _owner owner of the token
   * @param _tokenId uint256 ID of the token to be transferred
   */
  function clearApproval(address _owner, uint256 _tokenId) internal {
    require(ownerOf(_tokenId) == _owner);
    if (tokenApprovals[_tokenId] != address(0)) {
      tokenApprovals[_tokenId] = address(0);
      emit Approval(_owner, address(0), _tokenId);
    }
  }

  /**
   * @dev Internal function to add a token ID to the list of a given address
   * @param _to address representing the new owner of the given token ID
   * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
   */
  function addTokenTo(address _to, uint256 _tokenId) internal {
    require(tokenOwner[_tokenId] == address(0));
    tokenOwner[_tokenId] = _to;
    ownedTokensCount[_to] = ownedTokensCount[_to].add(1);
  }

  /**
   * @dev Internal function to remove a token ID from the list of a given address
   * @param _from address representing the previous owner of the given token ID
   * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
   */
  function removeTokenFrom(address _from, uint256 _tokenId) internal {
    require(ownerOf(_tokenId) == _from);
    ownedTokensCount[_from] = ownedTokensCount[_from].sub(1);
    tokenOwner[_tokenId] = address(0);
  }

  /**
   * @dev Internal function to invoke `onERC721Received` on a target address
   * @dev The call is not executed if the target address is not a contract
   * @param _from address representing the previous owner of the given token ID
   * @param _to target address that will receive the tokens
   * @param _tokenId uint256 ID of the token to be transferred
   * @param _data bytes optional data to send along with the call
   * @return whether the call correctly returned the expected magic value
   */
  function checkAndCallSafeTransfer(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes _data
  )
    internal
    returns (bool)
  {
    if (!_to.isContract()) {
      return true;
    }
    bytes4 retval = ERC721Receiver(_to).onERC721Received(_from, _tokenId, _data);
    return (retval == ERC721_RECEIVED);
  }
}

// File: openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol

/**
 * @title Full ERC721 Token
 * This implementation includes all the required and some optional functionality of the ERC721 standard
 * Moreover, it includes approve all functionality using operator terminology
 * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
 */
contract ERC721Token is ERC721, ERC721BasicToken {
  // Token name
  string internal name_;

  // Token symbol
  string internal symbol_;

  // Mapping from owner to list of owned token IDs
  mapping (address => uint256[]) internal ownedTokens;

  // Mapping from token ID to index of the owner tokens list
  mapping(uint256 => uint256) internal ownedTokensIndex;

  // Array with all token ids, used for enumeration
  uint256[] internal allTokens;

  // Mapping from token id to position in the allTokens array
  mapping(uint256 => uint256) internal allTokensIndex;

  // Optional mapping for token URIs
  mapping(uint256 => string) internal tokenURIs;

  /**
   * @dev Constructor function
   */
  function ERC721Token(string _name, string _symbol) public {
    name_ = _name;
    symbol_ = _symbol;
  }

  /**
   * @dev Gets the token name
   * @return string representing the token name
   */
  function name() public view returns (string) {
    return name_;
  }

  /**
   * @dev Gets the token symbol
   * @return string representing the token symbol
   */
  function symbol() public view returns (string) {
    return symbol_;
  }

  /**
   * @dev Returns an URI for a given token ID
   * @dev Throws if the token ID does not exist. May return an empty string.
   * @param _tokenId uint256 ID of the token to query
   */
  function tokenURI(uint256 _tokenId) public view returns (string) {
    require(exists(_tokenId));
    return tokenURIs[_tokenId];
  }

  /**
   * @dev Gets the token ID at a given index of the tokens list of the requested owner
   * @param _owner address owning the tokens list to be accessed
   * @param _index uint256 representing the index to be accessed of the requested tokens list
   * @return uint256 token ID at the given index of the tokens list owned by the requested address
   */
  function tokenOfOwnerByIndex(address _owner, uint256 _index) public view returns (uint256) {
    require(_index < balanceOf(_owner));
    return ownedTokens[_owner][_index];
  }

  /**
   * @dev Gets the total amount of tokens stored by the contract
   * @return uint256 representing the total amount of tokens
   */
  function totalSupply() public view returns (uint256) {
    return allTokens.length;
  }

  /**
   * @dev Gets the token ID at a given index of all the tokens in this contract
   * @dev Reverts if the index is greater or equal to the total number of tokens
   * @param _index uint256 representing the index to be accessed of the tokens list
   * @return uint256 token ID at the given index of the tokens list
   */
  function tokenByIndex(uint256 _index) public view returns (uint256) {
    require(_index < totalSupply());
    return allTokens[_index];
  }

  /**
   * @dev Internal function to set the token URI for a given token
   * @dev Reverts if the token ID does not exist
   * @param _tokenId uint256 ID of the token to set its URI
   * @param _uri string URI to assign
   */
  function _setTokenURI(uint256 _tokenId, string _uri) internal {
    require(exists(_tokenId));
    tokenURIs[_tokenId] = _uri;
  }

  /**
   * @dev Internal function to add a token ID to the list of a given address
   * @param _to address representing the new owner of the given token ID
   * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
   */
  function addTokenTo(address _to, uint256 _tokenId) internal {
    super.addTokenTo(_to, _tokenId);
    uint256 length = ownedTokens[_to].length;
    ownedTokens[_to].push(_tokenId);
    ownedTokensIndex[_tokenId] = length;
  }

  /**
   * @dev Internal function to remove a token ID from the list of a given address
   * @param _from address representing the previous owner of the given token ID
   * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
   */
  function removeTokenFrom(address _from, uint256 _tokenId) internal {
    super.removeTokenFrom(_from, _tokenId);

    uint256 tokenIndex = ownedTokensIndex[_tokenId];
    uint256 lastTokenIndex = ownedTokens[_from].length.sub(1);
    uint256 lastToken = ownedTokens[_from][lastTokenIndex];

    ownedTokens[_from][tokenIndex] = lastToken;
    ownedTokens[_from][lastTokenIndex] = 0;
    // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
    // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
    // the lastToken to the first position, and then dropping the element placed in the last position of the list

    ownedTokens[_from].length--;
    ownedTokensIndex[_tokenId] = 0;
    ownedTokensIndex[lastToken] = tokenIndex;
  }

  /**
   * @dev Internal function to mint a new token
   * @dev Reverts if the given token ID already exists
   * @param _to address the beneficiary that will own the minted token
   * @param _tokenId uint256 ID of the token to be minted by the msg.sender
   */
  function _mint(address _to, uint256 _tokenId) internal {
    super._mint(_to, _tokenId);

    allTokensIndex[_tokenId] = allTokens.length;
    allTokens.push(_tokenId);
  }

  /**
   * @dev Internal function to burn a specific token
   * @dev Reverts if the token does not exist
   * @param _owner owner of the token to burn
   * @param _tokenId uint256 ID of the token being burned by the msg.sender
   */
  function _burn(address _owner, uint256 _tokenId) internal {
    super._burn(_owner, _tokenId);

    // Clear metadata (if any)
    if (bytes(tokenURIs[_tokenId]).length != 0) {
      delete tokenURIs[_tokenId];
    }

    // Reorg all tokens array
    uint256 tokenIndex = allTokensIndex[_tokenId];
    uint256 lastTokenIndex = allTokens.length.sub(1);
    uint256 lastToken = allTokens[lastTokenIndex];

    allTokens[tokenIndex] = lastToken;
    allTokens[lastTokenIndex] = 0;

    allTokens.length--;
    allTokensIndex[_tokenId] = 0;
    allTokensIndex[lastToken] = tokenIndex;
  }

}

// File: contracts/Galaxy/UniverseGalaxyStore.sol

contract UniverseGalaxyStore is IUniverseGalaxy, ERC721Token, Whitelist, AccessControl, Random, MathTools, ArrayArchiveTools {
    /*** EVENTS ***/
    event PlanetCreated(
        address indexed owner,
        uint256 indexed planetId,
        uint256 sectorX,
        uint256 sectorY,
        uint256 rarity,
        uint256[MAX_ID_LIST_LENGTH] resourcesId,
        uint256[MAX_ID_LIST_LENGTH] resourcesVelocity,
        uint256 startPopulation
    );

    /*** DATA TYPES ***/

    struct Planet {
        uint256 rarity;
        uint256 discovered;
        uint256 updated;
        uint256 sectorX;
        uint256 sectorY;
        uint[MAX_ID_LIST_LENGTH] resourcesId;
        uint[MAX_ID_LIST_LENGTH] resourcesVelocity;
        uint[MAX_ID_LIST_LENGTH] resourcesUpdated;
    }

    /*** STORAGE ***/

    //    struct Planet {
    //        uint48 discovered;
    //        uint40 resourcesId;
    //        uint40 resourcesVelocity;
    //        uint8 sectorX;
    //        uint8 sectorY;
    //        uint8 rarity;
    //    }
    uint256[] public planets;

    //    struct PlanetState {
    //        uint48 updated;
    //        uint40 resourcesId;
    //        uint80 resourcesUpdated;
    //    }
    mapping (uint256 => uint256) planetStates;

    // x => (y => discovered_planet_count)
    mapping (uint => mapping ( uint => uint )) discoveredPlanetsCountMap;

    // group index => rarity => discovered planet count
    mapping (uint => mapping (uint => uint)) planetCountByRarityInGroups;

    // rarity => discovered planet count in galaxy
    mapping (uint => uint) planetCountByRarity;

    IUniverseBalance public universeBalance;
    IUniversePlanetExploration public universePlanetExploration;

    function UniverseGalaxyStore() ERC721Token("0xUniverse", "PLANET")
    public { }

    function _getPlanet(uint256 _id)
    internal view
    returns(Planet memory _planet)
    {
        uint256 planet = planets[_id];
        uint256 planetState = planetStates[_id];

        _planet.discovered = uint256(uint48(planet));
        _planet.resourcesId = _splitUint40ToArray(uint40(planet >> 48));
        _planet.resourcesVelocity = _splitUint40ToArray(uint40(planet >> 88));
        _planet.sectorX = uint256(uint8(planet >> 128));
        _planet.sectorY = uint256(uint8(planet >> 136));
        _planet.rarity = uint256(uint8(planet >> 144));

        _planet.updated = uint256(uint48(planetState));
        _planet.resourcesUpdated = _splitUint80ToArray(uint80(planetState >> 88));
    }

    function _convertPlanetToPlanetHash(Planet memory _planet)
    internal
    pure
    returns(uint256 _planetHash)
    {
        _planetHash = _planet.discovered;
        _planetHash |= _mergeArrayToUint40(_planet.resourcesId) << 48;
        _planetHash |= _mergeArrayToUint40(_planet.resourcesVelocity) << 88;
        _planetHash |= _planet.sectorX << 128;
        _planetHash |= _planet.sectorY << 136;
        _planetHash |= uint256(_planet.rarity) << 144;
    }

    function _convertPlanetToPlanetStateHash(Planet memory _planet)
    internal
    pure
    returns(uint256 _planetStateHash)
    {
        _planetStateHash = _planet.updated;
        _planetStateHash |= _mergeArrayToUint40(_planet.resourcesId) << 48;
        _planetStateHash |= _mergeArrayToUint80(_planet.resourcesUpdated) << 88;
    }

    function getDiscoveredPlanetsDensity(uint sectorX, uint sectorY) external view returns (uint) {
        uint discoveredPlanetsCount = discoveredPlanetsCountMap[sectorX][sectorY];
        // жёсткая проверка на количество планет в секторе и защита от переполнения переменной
        if (discoveredPlanetsCount >= PLANETS_COUNT_PER_SECTOR) {
            return 0;
        }
        return 100 - (discoveredPlanetsCount * 100) / PLANETS_COUNT_PER_SECTOR;
    }

    function countPlanetsByRarityInGroup(uint _groupIndex, uint _rarity) external view returns (uint){
        return planetCountByRarityInGroups[_groupIndex][_rarity];
    }

    function countPlanetsByRarity(uint _rarity) external view returns (uint){
        return planetCountByRarity[_rarity];
    }

    function setUniverseBalanceAddress(address _address) external onlyOwner {
        IUniverseBalance candidateContract = IUniverseBalance(_address);

        // NOTE: verify that a contract is what we expect
        // https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isUniverseBalance(), "Incorrect address param");

        // Set the new contract address
        universeBalance = candidateContract;
    }

    function setUniversePlanetExplorationAddress(address _address) external onlyOwner {
        IUniversePlanetExploration candidateContract = IUniversePlanetExploration(_address);

        // NOTE: verify that a contract is what we expect
        // https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isUniversePlanetExploration(), "Incorrect address param");

        // Set the new contract address
        universePlanetExploration = candidateContract;
    }

    function getPlanet(uint256 _id)
    external
    view
    returns (
        uint256 rarity,
        uint256 discovered,
        uint256 sectorX,
        uint256 sectorY,
        uint256[MAX_ID_LIST_LENGTH] resourcesId,
        uint256[MAX_ID_LIST_LENGTH] resourcesVelocity
    ) {
        Planet memory pl = _getPlanet(_id);

        rarity = pl.rarity;
        discovered = pl.discovered;
        sectorX = pl.sectorX;
        sectorY = pl.sectorY;
        resourcesId = pl.resourcesId;
        resourcesVelocity = pl.resourcesVelocity;
    }

    function _getOwnedTokensCount(address _owner) internal view returns (uint256){
        return ownedTokens[_owner].length;
    }

    function _getOwnedTokensByIndex(address _owner, uint256 _ownerTokenIndex) internal view returns (uint256){
        return ownedTokens[_owner][_ownerTokenIndex];
    }

    function findAvailableResource(address _owner, uint _rarity) external returns (int8) {
        uint ownedPlanetsCount = _getOwnedTokensCount(_owner);

        uint[] memory resourceList = new uint[](ownedPlanetsCount * MAX_ID_LIST_LENGTH);

        uint[2] memory resourcesOrderByRarity = universeBalance.getResourcesQuantityByRarity(_rarity);
        uint firstResourceId = resourcesOrderByRarity[0];
        uint lastResourceId = resourcesOrderByRarity[0] + resourcesOrderByRarity[1] - 1;

        uint maxResourceListElement = 0;
        for (uint i = 0; i < ownedPlanetsCount; i++) {
            Planet memory planet = _getPlanet( _getOwnedTokensByIndex(_owner, i) );

            for (uint k = 1; k < planet.resourcesId.length; k++) {
                uint resourceId = planet.resourcesId[k];
                if(resourceId == 0) break;

                if(resourceId >= firstResourceId && resourceId <= lastResourceId) {
                    resourceList[maxResourceListElement] = resourceId; // замена resourceList.push(j);
                    maxResourceListElement++;
                }
            }
        }

        if (maxResourceListElement > 0) { // выбираем из них один случайный
            return int8(resourceList[_randRange(0, maxResourceListElement - 1)]);
        } else {
            return -1;
        }
    }

    function createPlanet(
        address _owner,
        uint256 _rarity,
        uint256 _sectorX,
        uint256 _sectorY,
        uint256 _startPopulation
    )
    external
    onlyWhitelisted
    returns (uint256)
    {
        Planet memory planet = _createPlanetWithRandomResources(_rarity, _sectorX, _sectorY, _startPopulation);
        return _savePlanet(_owner, planet);
    }

    function _savePlanet(
        address _owner,
        Planet _planet
    )
    internal
    returns (uint)
    {
        uint256 planet = _convertPlanetToPlanetHash(_planet);
        uint256 planetState = _convertPlanetToPlanetStateHash(_planet);

        uint256 newPlanetId = planets.push(planet) - 1;
        planetStates[newPlanetId] = planetState;

        require(newPlanetId < PLANETS_COUNT, "No more planets");

        emit PlanetCreated(
            _owner,
            newPlanetId,
            _planet.sectorX,
            _planet.sectorY,
            _planet.rarity,
            _planet.resourcesId,
            _planet.resourcesVelocity,
            _planet.resourcesUpdated[0]
        );

        discoveredPlanetsCountMap[_planet.sectorX][_planet.sectorY] += 1;

        if (_planet.rarity == 3) {
            uint groupIndex = universeBalance.getGroupId(_planet.sectorX, _planet.sectorY);
            planetCountByRarityInGroups[groupIndex][3] += 1;
        }

        if (_planet.rarity == 4) {
            planetCountByRarity[4] += 1;
        }

        _mint(_owner, newPlanetId);

        return newPlanetId;
    }

    function _createPlanetWithRandomResources(uint _rarity, uint _sectorX, uint _sectorY, uint _startPopulation)
    internal
    returns (Planet memory _planet)
    {
        uint[MAX_ID_LIST_LENGTH] memory resourcesId;
        uint[MAX_ID_LIST_LENGTH] memory resourcesVelocity;
        (resourcesId, resourcesVelocity) = universePlanetExploration.explorePlanet(_rarity);

        uint[MAX_ID_LIST_LENGTH] memory resourcesUpdated;
        resourcesUpdated[0] = _startPopulation;

        _planet = Planet({
            rarity: _rarity,
            discovered: uint256(now),
            updated: uint256(now),
            sectorX: _sectorX,
            sectorY: _sectorY,
            resourcesId: resourcesId,
            resourcesVelocity: resourcesVelocity,
            resourcesUpdated: resourcesUpdated
            });
    }
}

// File: contracts/Galaxy/UniverseAuction.sol

contract UniverseAuction is UniverseGalaxyStore {

    ISaleClockAuction public saleAuction;

    function setSaleAuctionAddress(address _address) external onlyOwner {
        ISaleClockAuction candidateContract = ISaleClockAuction(_address);

        // NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
        require(candidateContract.isSaleClockAuction(), "Incorrect address param");

        // Set the new contract address
        saleAuction = candidateContract;
    }

    function createSaleAuction(
        uint256 _planetId,
        uint256 _startingPrice,
        uint256 _endingPrice,
        uint256 _duration
    )
    external
    whenNotPaused
    {
        if (universeBalance.autoClearAuction()) saleAuction.clearOne(msg.sender, _planetId);
        // Auction contract checks input sizes
        // If planet is already on any auction, this will throw
        // because it will be owned by the auction contract.
        require(ownerOf(_planetId) == msg.sender, "Not owner");

        approve(saleAuction, _planetId);
        // Sale auction throws if inputs are invalid and clears
        // transfer approval after escrowing the planet.
        saleAuction.createAuction(
            _planetId,
            _startingPrice,
            _endingPrice,
            _duration,
            msg.sender
        );
    }

    function withdrawAuctionBalances() external onlyTeam {
        saleAuction.withdrawBalance();
    }
}

// File: contracts/Galaxy/UniverseGalaxyState.sol

contract UniverseGalaxyState is UniverseAuction {

    uint internal constant SECONDS_IN_DAY = 60 * 60 * 24;

    mapping (address => uint) public ownerToKnowledge;
    mapping (address => uint) public lastKnowledgeSpentDateByOwner;

    function getPlanetUpdatedResources(uint256 _id)
    external
    view
    returns (
        uint256 updated,
        uint256[MAX_ID_LIST_LENGTH] resourcesId,
        uint256[MAX_ID_LIST_LENGTH] resourcesUpdated
    ) {
        Planet memory pl = _getPlanet(_id);

        updated = pl.updated;
        resourcesId = pl.resourcesId;
        resourcesUpdated = pl.resourcesUpdated;
    }

    function spendResourceOnPlanet(
        address _owner,
        uint _planetId,
        uint _resourceId,
        uint _resourceValue
    )
    external
    onlyWhitelisted
    {
        require(_owner != address(0), "Owner param should be defined");
        require(_resourceValue > 0, "ResourceValue param should be bigger that zero");

        Planet memory planet = _getPlanet(_planetId);
        planet = _recountPlanetStateAndUpdateUserKnowledge(_owner, planet);

        require(planet.resourcesUpdated[_resourceId] >= _resourceValue, "Resource current should be bigger that ResourceValue");

        planet.resourcesUpdated[_resourceId] -= _resourceValue;
        _updatePlanetStateHash(_planetId, planet);
    }

    function spendResources(
        address _owner,
        uint[MAX_ID_LIST_LENGTH] _resourcesId,
        uint[MAX_ID_LIST_LENGTH] _resourcesNeeded
    ) external onlyWhitelisted {
        uint ...

// [truncated — 60259 bytes total]

Read Contract

PROMO_PLANETS_LIMIT 0xbdf22c66 → uint256
balanceOf 0x70a08231 → uint256
countPlanetsByRarity 0x414b5064 → uint256
countPlanetsByRarityInGroup 0xeb822fe5 → uint256
exists 0x4f558e79 → bool
getApproved 0x081812fc → address
getCurrentKnowledgeOfOwner 0x5a71e6d3 → uint256
getDiscoveredPlanetsDensity 0x672815c2 → uint256
getPlanet 0x34efcb8e → uint256, uint256, uint256, uint256, uint256[5], uint256[5]
getPlanetCurrentResources 0x3e573168 → uint256[5]
getPlanetUpdatedResources 0xb568ee2b → uint256, uint256[5], uint256[5]
isApprovedForAll 0xe985e9c5 → bool
lastKnowledgeSpentDateByOwner 0x64384a99 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
ownerToKnowledge 0x35bde22c → uint256
paused 0x5c975abb → bool
planets 0x26c1e750 → uint256
promoCreatedCount 0x05e45546 → uint256
saleAuction 0xe6cbe351 → address
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
treasurer 0xfda49eb4 → address
universeBalance 0x7c0f0ac9 → address
universePlanetExploration 0x30f18fb7 → address
whitelist 0x9b19251a → bool

Write Contract 27 functions

These functions modify contract state and require a wallet transaction to execute.

addAddressToWhitelist 0x7b9417c8
address addr
returns: bool
addAddressesToWhitelist 0xe2ec6ec3
address[] addrs
returns: bool
approve 0x095ea7b3
address _to
uint256 _tokenId
checkWhetherEnoughPromoPlanet 0xf6d016dc
No parameters
createPlanet 0xc58b1bdd
address _owner
uint256 _rarity
uint256 _sectorX
uint256 _sectorY
uint256 _startPopulation
returns: uint256
createSaleAuction 0x3d7d3f5a
uint256 _planetId
uint256 _startingPrice
uint256 _endingPrice
uint256 _duration
findAvailableResource 0x8b17b33b
address _owner
uint256 _rarity
returns: int8
initialize 0xc4d66de8
address _earthOwner
pause 0x8456cb59
No parameters
recountPlanetResourcesAndUserKnowledge 0xaac0b776
address _owner
uint256 _planetId
removeAddressFromWhitelist 0x286dd3f5
address addr
returns: bool
removeAddressesFromWhitelist 0x24953eaa
address[] addrs
returns: bool
safeTransferFrom 0x42842e0e
address _from
address _to
uint256 _tokenId
safeTransferFrom 0xb88d4fde
address _from
address _to
uint256 _tokenId
bytes _data
setApprovalForAll 0xa22cb465
address _to
bool _approved
setSaleAuctionAddress 0x6fbde40d
address _address
setUniverseBalanceAddress 0x4bbe9547
address _address
setUniversePlanetExplorationAddress 0x9272eb8b
address _address
spendKnowledge 0xf97fd58a
address _owner
uint256 _spentKnowledge
spendResourceOnPlanet 0x189052f1
address _owner
uint256 _planetId
uint256 _resourceId
uint256 _resourceValue
spendResources 0xcd216f0e
address _owner
uint256[5] _resourcesId
uint256[5] _resourcesNeeded
transferFrom 0x23b872dd
address _from
address _to
uint256 _tokenId
transferOwnership 0xf2fde38b
address newOwner
transferTreasurer 0x611e68d4
address _treasurer
unpause 0x3f4ba83a
No parameters
withdrawAuctionBalances 0x91876e57
No parameters
withdrawBalance 0x5fd8c710
No parameters

Recent Transactions

Transaction index is loading. Only unfinalized transactions are shown while the index starts up.