Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x86cF8621b3ee3EB77D7EFFE9Dc677D1CD39E9Ce5
Balance 0 ETH
Nonce 9
Code Size 14788 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

14788 bytes
0x608060405234801561001057600080fd5b50600436106101825760003560e01c80638c2fb990116100d8578063b19666301161008c578063da1fdccf11610066578063da1fdccf14610373578063f0e113ea14610386578063f2fde38b1461039957600080fd5b8063b19666301461032d578063c265d19114610340578063c2ff84bc1461036057600080fd5b80639e409325116100bd5780639e409325146102e65780639e6d0ce4146102f9578063a0755f9b1461030c57600080fd5b80638c2fb990146102b55780638da5cb5b146102c857600080fd5b8063484455a71161013a578063715018a611610114578063715018a6146102875780637f17426f1461028f5780638a6f0b38146102a257600080fd5b8063484455a7146102415780635cf4ea66146102545780636d38718e1461026757600080fd5b8063202f9b8b1161016b578063202f9b8b146101dd5780633efebd4c146101f257806343add2e61461020757600080fd5b8063127f149814610187578063198bb095146101b0575b600080fd5b61019a6101953660046126f5565b6103ac565b6040516101a791906133f7565b60405180910390f35b6007546101d09073ffffffffffffffffffffffffffffffffffffffff1681565b6040516101a791906133e9565b6101e56104a8565b6040516101a79190613408565b610205610200366004612911565b610500565b005b6102336102153660046126f5565b60036020526000908152604090205460ff8082169161010090041682565b6040516101a7929190613419565b61020561024f3660046127f3565b6107d3565b61019a6102623660046127be565b610d49565b61027a6102753660046128aa565b610ef4565b6040516101a79190613434565b610205610f15565b6101d061029d366004612933565b610f72565b6102056102b03660046129bd565b610fb7565b6102056102c3366004612716565b6111ed565b60005473ffffffffffffffffffffffffffffffffffffffff166101d0565b6101e56102f4366004612933565b6114f5565b6102056103073660046126f5565b6115fd565b61031f61031a366004612933565b6116f5565b6040516101a792919061361d565b61019a61033b366004612966565b6117c6565b61035361034e36600461298a565b611971565b6040516101a79190613442565b61019a61036e3660046128aa565b611a62565b610205610381366004612766565b611b1f565b6102056103943660046128cb565b611d64565b6102056103a73660046126f5565b61201f565b73ffffffffffffffffffffffffffffffffffffffff811660009081526003602052604090205460609060ff16610417576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134ed565b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff82166000908152600360209081526040918290206001018054835181840281018401909452808452909183018282801561049c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610471575b50505050509050919050565b606060048054806020026020016040519081016040528092919081815260200182805480156104f657602002820191906000526020600020905b8154815260200190600101908083116104e2575b5050505050905090565b60005473ffffffffffffffffffffffffffffffffffffffff163314610551576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061358d565b600082815260056020526040902054610596576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134cd565b6000828152600660205260409020546105db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061359d565b6000828152600660205260408120805482906105f9576105f96138db565b6000918252602090912001546040517f04eff22f00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff909116915081906304eff22f9061065b908590600401613442565b60206040518083038186803b15801561067357600080fd5b505afa158015610687573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ab9190612889565b6106e1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061350d565b60006107054360405180606001604052806023815260200161396c602391396120c9565b6000858152600560209081526040808320815180830190925267ffffffffffffffff858116835282840189815282546001808201855593875295859020845160029097020180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001696909216959095178155935180519596509194610792939185019290910190612414565b505050837f2e0b754128214590dbbdce65044320682c315e980a335ca8dd839bac666ebd9d846040516107c59190613442565b60405180910390a250505050565b60075473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480610826575060005473ffffffffffffffffffffffffffffffffffffffff1633145b61085c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135ad565b8151835114801561086e575080518351145b6108a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061352d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60005b8251811015610d0b57818382600186516108e291906136f2565b6108ec91906136f2565b815181106108fc576108fc6138db565b60200260200101511061093b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061353d565b82816001855161094b91906136f2565b61095591906136f2565b81518110610965576109656138db565b60200260200101519150600085826001865161098191906136f2565b61098b91906136f2565b8151811061099b5761099b6138db565b6020026020010151905060008583600187516109b791906136f2565b6109c191906136f2565b815181106109d1576109d16138db565b6020026020010151905060008584600188516109ed91906136f2565b6109f791906136f2565b81518110610a0757610a076138db565b602002602001015190506000600560008581526020019081526020016000208054905011610a61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061354d565b73ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604090205460ff16610ac0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134ed565b600083815260066020526040902080548210610b08576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135bd565b8273ffffffffffffffffffffffffffffffffffffffff16818381548110610b3157610b316138db565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614610b8a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135cd565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040812080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016815590610be36001830182612498565b505080548190610bf5906001906136f2565b81548110610c0557610c056138db565b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16818381548110610c4257610c426138db565b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080805480610c9a57610c9a6138ac565b60008281526020902081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905501905550839250610d0391508290506137e6565b9150506108c8565b507f4d56c45d103a8ae2854f60aacac0d774062456c939b09e8e0e290d6ce0265f6683604051610d3b91906133f7565b60405180910390a150505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260036020526040902080546060919060ff16610dad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134ed565b600181015484108015610dc4575060018101548311155b8015610dcf57508383115b610e05576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134fd565b6000610e1185856136f2565b67ffffffffffffffff811115610e2957610e2961390a565b604051908082528060200260200182016040528015610e52578160200160208202803683370190505b509050845b84811015610ee857826001018181548110610e7457610e746138db565b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828281518110610eb157610eb16138db565b73ffffffffffffffffffffffffffffffffffffffff9092166020928302919091019091015280610ee0816137e6565b915050610e57565b509150505b9392505050565b60048181548110610f0457600080fd5b600091825260209091200154905081565b60005473ffffffffffffffffffffffffffffffffffffffff163314610f66576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061358d565b610f706000612117565b565b60066020528160005260406000208181548110610f8e57600080fd5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff169150829050565b60075473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16148061100a575060005473ffffffffffffffffffffffffffffffffffffffff1633145b611040576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135ad565b60008260405160200161105391906133dd565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152918152815160209283012060008181526005909352912054909150156110d0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061356d565b60006110f44360405180606001604052806023815260200161396c602391396120c9565b6000838152600560209081526040808320815180830190925267ffffffffffffffff858116835282840189815282546001808201855593875295859020845160029097020180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001696909216959095178155935180519596509194611181939185019290910190612414565b5050600480546001810182556000919091527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b018390555060405182907ff4f88b75ea75603596bb19030dca97baa92867f2c90e23f17424fd8764692bc8906107c590879087906134a8565b60075473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611240575060005473ffffffffffffffffffffffffffffffffffffffff1633145b611276576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135ad565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260409020805460ff166112d6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134ed565b60018101548210611313576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135bd565b8273ffffffffffffffffffffffffffffffffffffffff1681600101838154811061133f5761133f6138db565b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff1614611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135dd565b6001808201805490916113aa916136f2565b815481106113ba576113ba6138db565b60009182526020909120015460018201805473ffffffffffffffffffffffffffffffffffffffff90921691849081106113f5576113f56138db565b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600101805480611450576114506138ac565b60008281526020812082017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90810180547fffffffffffffffffffffffff000000000000000000000000000000000000000016905590910190915560405173ffffffffffffffffffffffffffffffffffffffff85811692908716917f7f790f03613072243bc742c7a02620360e73cd613ba25bf830ed9565997ecab49190a350505050565b6004546060908310801561150b57506004548211155b801561151657508282115b61154c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134fd565b600061155884846136f2565b67ffffffffffffffff8111156115705761157061390a565b604051908082528060200260200182016040528015611599578160200160208202803683370190505b509050835b838110156115f357600481815481106115b9576115b96138db565b90600052602060002001548282815181106115d6576115d66138db565b6020908102919091010152806115eb816137e6565b91505061159e565b5090505b92915050565b60075473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161480611650575060005473ffffffffffffffffffffffffffffffffffffffff1633145b611686576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135ad565b600780547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040517ff651cca2697714a5eb3c15b3a8f232f31396be21f290303418c95783d96095a390600090a250565b6005602052816000526040600020818154811061171157600080fd5b60009182526020909120600290910201805460018201805467ffffffffffffffff90921694509192506117439061376e565b80601f016020809104026020016040519081016040528092919081815260200182805461176f9061376e565b80156117bc5780601f10611791576101008083540402835291602001916117bc565b820191906000526020600020905b81548152906001019060200180831161179f57829003601f168201915b5050505050905082565b60008381526005602052604090205460609061180e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061354d565b6000848152600660205260409020548310801561183957506000848152600660205260409020548211155b801561184457508282115b61187a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134fd565b600061188684846136f2565b67ffffffffffffffff81111561189e5761189e61390a565b6040519080825280602002602001820160405280156118c7578160200160208202803683370190505b509050835b838110156119685760008681526006602052604090208054829081106118f4576118f46138db565b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16828281518110611931576119316138db565b73ffffffffffffffffffffffffffffffffffffffff9092166020928302919091019091015280611960816137e6565b9150506118cc565b50949350505050565b6000828152600560205260409020546060906119b9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134cd565b60008381526005602052604090206119d1908361218c565b80546119dc9061376e565b80601f0160208091040260200160405190810160405280929190818152602001828054611a089061376e565b8015611a555780601f10611a2a57610100808354040283529160200191611a55565b820191906000526020600020905b815481529060010190602001808311611a3857829003601f168201915b5050505050905092915050565b600081815260056020526040902054606090611aaa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061354d565b6000828152600660209081526040918290208054835181840281018401909452808452909183018282801561049c5760200282019190600052602060002090815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116104715750505050509050919050565b60026001541415611b5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135ed565b600260015573ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260409020805460ff16611bc1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134ed565b8054610100900460ff16611c01576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906135fd565b6000611c0c846123ab565b6001838101805491820181556000908152602090200180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8381169182179092556002546007546040517f246581f7000000000000000000000000000000000000000000000000000000008152949550919363246581f793611cb19392811692169033908990600401613464565b600060405180830381600087803b158015611ccb57600080fd5b505af1158015611cdf573d6000803e3d6000fd5b50505050611cea3390565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167f2d8719c61fe70e858668369ad9f3e733112b477977e6a7ee0b503be7e1afda7660405160405180910390a45050600180555050565b600083815260056020526040902054611da9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061354d565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260409020805460ff1615611e0a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061357d565b73ffffffffffffffffffffffffffffffffffffffff8316611e57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061355d565b6000611e7b4360405180606001604052806023815260200161396c602391396120c9565b90508373ffffffffffffffffffffffffffffffffffffffff166304eff22f611eb5600560008981526020019081526020016000208461218c565b6040518263ffffffff1660e01b8152600401611ed19190613453565b60206040518083038186803b158015611ee957600080fd5b505afa158015611efd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f219190612889565b611f57576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061351d565b815483151561010081027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000090921691909117600190811784556000878152600660209081526040808320805494850181558352908220909201805473ffffffffffffffffffffffffffffffffffffffff89167fffffffffffffffffffffffff0000000000000000000000000000000000000000909116811790915591517fe083a3eac9bf6ada3d51b16dcb52bf6a9f39ed3858f61507d933f5c36dc759e19190a35050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314612070576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061358d565b73ffffffffffffffffffffffffffffffffffffffff81166120bd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e906134dd565b6120c681612117565b50565b60008168010000000000000000841061210f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9190613442565b509192915050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000826000815481106121a1576121a16138db565b600091825260209091206002909102015467ffffffffffffffff90811690831610156121f9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040e9061360d565b82548390612209906001906136f2565b81548110612219576122196138db565b600091825260209091206002909102015467ffffffffffffffff90811690831610612276578254839061224e906001906136f2565b8154811061225e5761225e6138db565b906000526020600020906002020160010190506115f7565b82546000908190612289906001906136f2565b90505b8181111561237e57600060026122a284846136c6565b6122ad9060016136c6565b6122b791906136de565b90508467ffffffffffffffff168682815481106122d6576122d66138db565b600091825260209091206002909102015467ffffffffffffffff16141561232457858181548110612309576123096138db565b906000526020600020906002020160010193505050506115f7565b8467ffffffffffffffff16868281548110612341576123416138db565b600091825260209091206002909102015467ffffffffffffffff16101561236a57809250612378565b6123756001826136f2565b91505b5061228c565b848281548110612390576123906138db565b90600052602060002090600202016001019250505092915050565b6000808260601b90506040517f3d602d80600a3d3981f3363d3d373d3d3d363d7300000000000000000000000081528160148201527f5af43d82803e903d91602b57fd5bf3000000000000000000000000000000000060288201526037816000f0949350505050565b8280546124209061376e565b90600052602060002090601f0160209004810192826124425760008555612488565b82601f1061245b57805160ff1916838001178555612488565b82800160010185558215612488579182015b8281111561248857825182559160200191906001019061246d565b506124949291506124b2565b5090565b50805460008255906000526020600020908101906120c691905b5b8082111561249457600081556001016124b3565b60006124da6124d584613659565b61363d565b905080838252602082019050828560208602820111156124fc576124fc600080fd5b60005b8581101561252857816125128882612626565b84525060209283019291909101906001016124ff565b5050509392505050565b60006125406124d584613659565b9050808382526020820190508285602086028201111561256257612562600080fd5b60005b85811015612528578161257888826126bb565b8452506020928301929190910190600101612565565b600061259c6124d584613659565b905080838252602082019050828560208602820111156125be576125be600080fd5b60005b8581101561252857816125d488826126bb565b84525060209283019291909101906001016125c1565b60006125f86124d58461367d565b90508281526020810184848401111561261357612613600080fd5b61261e848285613732565b509392505050565b80356115f781613939565b600082601f83011261264557612645600080fd5b81356126558482602086016124c7565b949350505050565b600082601f83011261267157612671600080fd5b8135612655848260208601612532565b600082601f83011261269557612695600080fd5b813561265584826020860161258e565b80356115f78161394d565b80516115f78161394d565b80356115f781613955565b600082601f8301126126da576126da600080fd5b81356126558482602086016125ea565b80356115f78161395b565b60006020828403121561270a5761270a600080fd5b60006126558484612626565b60008060006060848603121561272e5761272e600080fd5b600061273a8686612626565b935050602061274b86828701612626565b925050604061275c868287016126bb565b9150509250925092565b6000806040838503121561277c5761277c600080fd5b60006127888585612626565b925050602083013567ffffffffffffffff8111156127a8576127a8600080fd5b6127b4858286016126c6565b9150509250929050565b6000806000606084860312156127d6576127d6600080fd5b60006127e28686612626565b935050602061274b868287016126bb565b60008060006060848603121561280b5761280b600080fd5b833567ffffffffffffffff81111561282557612825600080fd5b6128318682870161265d565b935050602084013567ffffffffffffffff81111561285157612851600080fd5b61285d86828701612631565b925050604084013567ffffffffffffffff81111561287d5761287d600080fd5b61275c86828701612681565b60006020828403121561289e5761289e600080fd5b600061265584846126b0565b6000602082840312156128bf576128bf600080fd5b600061265584846126bb565b6000806000606084860312156128e3576128e3600080fd5b60006128ef86866126bb565b935050602061290086828701612626565b925050604061275c868287016126a5565b6000806040838503121561292757612927600080fd5b600061278885856126bb565b6000806040838503121561294957612949600080fd5b600061295585856126bb565b92505060206127b4858286016126bb565b60008060006060848603121561297e5761297e600080fd5b60006127e286866126bb565b600080604083850312156129a0576129a0600080fd5b60006129ac85856126bb565b92505060206127b4858286016126ea565b600080604083850312156129d3576129d3600080fd5b823567ffffffffffffffff8111156129ed576129ed600080fd5b612788858286016126c6565b6000612a058383612a19565b505060200190565b6000612a058383612ab7565b612a2281613709565b82525050565b6000612a32825190565b80845260209384019383018060005b83811015612a66578151612a5588826129f9565b975060208301925050600101612a41565b509495945050505050565b6000612a7b825190565b80845260209384019383018060005b83811015612a66578151612a9e8882612a0d565b975060208301925050600101612a8a565b801515612a22565b80612a22565b6000612ac7825190565b808452602084019350612ade81856020860161373e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920192915050565b60008154612b1a8161376e565b808552602085019450600182168015612b3a5760018114612b6a57612b98565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083168652602086019350612b98565b60008581526020902060005b83811015612b9257815488820152600190910190602001612b76565b87019450505b50505092915050565b612a2281613727565b6000612bb4825190565b612bc281856020860161373e565b9290920192915050565b602f81526000602082017f436f6c6c656374696f6e466163746f72793a2065636f73797374656d2073657481527f74696e6773206e6f7420666f756e640000000000000000000000000000000000602082015291505b5060400190565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181527f646472657373000000000000000000000000000000000000000000000000000060208201529150612c22565b603481526000602082017f436f6c6c656374696f6e466163746f72793a20696d706c656d656e746174696f81527f6e2061646472657373206e6f7420666f756e642e00000000000000000000000060208201529150612c22565b602e81526000602082017f436f6c6c656374696f6e466163746f72793a20417272617920696e646963657381527f206f7574206f6620626f756e647300000000000000000000000000000000000060208201529150612c22565b605881526000602082017f436f6c6c656374696f6e466163746f72793a20696e76616c69642065636f737981527f7374656d2073657474696e6773206163636f7264696e6720746f20666972737460208201527f20696d706c656d656e746174696f6e20636f6e74726163740000000000000000604082015291505b5060600190565b605681526000602082017f436f6c6c656374696f6e466163746f72793a20696d706c656d656e746174696f81527f6e206164647265737320646f65736e27742070726f7065726c792076616c696460208201527f6174652065636f73797374656d2073657474696e67730000000000000000000060408201529150612db3565b603a81526000602082017f436f6c6c656374696f6e466163746f72793a206172726179732070726f76696481527f6564206d757374206265207468652073616d65206c656e67746800000000000060208201529150612c22565b603c81526000602082017f436f6c6c656374696f6e466163746f72793a20617272617973206d757374206281527f65206f726465726564206265666f72652070726f63657373696e672e0000000060208201529150612c22565b602a81526000602082017f436f6c6c656374696f6e466163746f72793a2065636f73797374656d20646f6581527f736e27742065786973740000000000000000000000000000000000000000000060208201529150612c22565b603d81526000602082017f436f6c6c656374696f6e466163746f72793a20696d706c656d656e746174696f81527f6e20616464726573732063616e6e6f742062652030206164647265737300000060208201529150612c22565b604181526000602082017f436f6c6c656374696f6e466163746f72793a2065636f73797374656d2073657481527f74696e677320666f722074686973206e616d6520616c7265616479206578697360208201527f740000000000000000000000000000000000000000000000000000000000000060408201529150612db3565b603881526000602082017f436f6c6c656374696f6e466163746f72793a20696d706c656d656e746174696f81527f6e206164647265737320616c726561647920657869737473000000000000000060208201529150612c22565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910190815260005b5060200190565b604181526000602082017f436f6c6c656374696f6e466163746f72793a206e6f20696d706c656d656e746181527f74696f6e2061646472657373657320666f7220746869732065636f737973746560208201527f6d0000000000000000000000000000000000000000000000000000000000000060408201529150612db3565b603d81526000602082017f436f6c6c656374696f6e466163746f72793a206d75737420626520656974686581527f7220666163746f7279206d61696e7461696e6572206f72206f776e657200000060208201529150612c22565b602d81526000602082017f436f6c6c656374696f6e466163746f72793a20617272617920696e646578206f81527f7574206f6620626f756e64732e0000000000000000000000000000000000000060208201529150612c22565b604e81526000602082017f436f6c6c656374696f6e466163746f72793a20656c656d656e7420617420617281527f72617920696e646578206e6f7420657175616c20746f20696d706c656d656e7460208201527f6174696f6e20616464726573732e00000000000000000000000000000000000060408201529150612db3565b604a81526000602082017f436f6c6c656374696f6e466163746f72793a20656c656d656e7420617420617281527f72617920696e646578206e6f7420657175616c20746f20636f6c6c656374696f60208201527f6e20616464726573732e0000000000000000000000000000000000000000000060408201529150612db3565b601f81526000602082017f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00815291506130aa565b603b81526000602082017f436f6c6c656374696f6e466163746f72793a20696d706c656d656e746174696f81527f6e2061646472657373206973206e6f7420636c6f6e6561626c652e000000000060208201529150612c22565b603b81526000602082017f436f6c6c656374696f6e466163746f72793a20426c6f636b206e756d6265722081527f6265666f72652066697273742073657474696e677320626c6f636b000000000060208201529150612c22565b67ffffffffffffffff8116612a22565b6000610eed8284612baa565b602081016115f78284612a19565b60208082528101610eed8184612a28565b60208082528101610eed8184612a71565b604081016134278285612aaf565b610eed6020830184612aaf565b602081016115f78284612ab7565b60208082528101610eed8184612abd565b60208082528101610eed8184612b0d565b608081016134728287612ba1565b61347f6020830186612a19565b61348c6040830185612a19565b818103606083015261349e8184612abd565b9695505050505050565b604080825281016134b98185612abd565b905081810360208301526126558184612abd565b602080825281016115f781612bcc565b602080825281016115f781612c29565b602080825281016115f781612c83565b602080825281016115f781612cdd565b602080825281016115f781612d37565b602080825281016115f781612dba565b602080825281016115f781612e3a565b602080825281016115f781612e94565b602080825281016115f781612eee565b602080825281016115f781612f48565b602080825281016115f781612fa2565b602080825281016115f781613022565b602080825281016115f78161307c565b602080825281016115f7816130b1565b602080825281016115f781613131565b602080825281016115f78161318b565b602080825281016115f7816131e5565b602080825281016115f781613265565b602080825281016115f7816132e5565b602080825281016115f781613319565b602080825281016115f781613373565b6040810161362b82856133cd565b81810360208301526126558184612abd565b600061364860405190565b9050613654828261379b565b919050565b600067ffffffffffffffff8211156136735761367361390a565b5060209081020190565b600067ffffffffffffffff8211156136975761369761390a565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011660200192915050565b600082198211156136d9576136d961381f565b500190565b6000826136ed576136ed61384e565b500490565b6000828210156137045761370461381f565b500390565b600073ffffffffffffffffffffffffffffffffffffffff82166115f7565b60006115f782613709565b82818337506000910152565b60005b83811015613759578181015183820152602001613741565b83811115613768576000848401525b50505050565b60028104600182168061378257607f821691505b602082108114156137955761379561387d565b50919050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f830116810181811067ffffffffffffffff821117156137df576137df61390a565b6040525050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156138185761381861381f565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61394281613709565b81146120c657600080fd5b801515613942565b80613942565b67ffffffffffffffff811661394256fe436f6c6c656374696f6e466163746f72793a206578636565647320363420626974732ea264697066735822122061fc7678b9d5816d860e24da8f50cd4679283b5aeec8724be2769ee61408477664736f6c63430008060033

Verified Source Code Full Match

Compiler: v0.8.6+commit.11564f7e EVM: berlin
ICollectionCloneable.sol 13 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import { IHashes } from "./IHashes.sol";

interface ICollectionCloneable {
    function initialize(
        IHashes _hashesToken,
        address _factoryMaintainerAddress,
        address _createCollectionCaller,
        bytes memory _initializationData
    ) external;
}
IOwnable.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

interface IOwnable {
    function renounceOwnership() external;

    function transferOwnership(address newOwner) external;

    function owner() external view returns (address);
}
IHashes.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

interface IHashes is IERC721Enumerable {
    function deactivateTokens(
        address _owner,
        uint256 _proposalId,
        bytes memory _signature
    ) external returns (uint256);

    function deactivated(uint256 _tokenId) external view returns (bool);

    function activationFee() external view returns (uint256);

    function verify(
        uint256 _tokenId,
        address _minter,
        string memory _phrase
    ) external view returns (bool);

    function getHash(uint256 _tokenId) external view returns (bytes32);

    function getPriorVotes(address account, uint256 blockNumber) external view returns (uint256);
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC721.sol 142 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
ICollectionFactory.sol 55 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

interface ICollectionFactory {
    function addImplementationAddress(
        bytes32 _hashedEcosystemName,
        address _implementationAddress,
        bool cloneable
    ) external;

    function createCollection(address _implementationAddress, bytes memory _initializationData) external;

    function setFactoryMaintainerAddress(address _factoryMaintainerAddress) external;

    function removeImplementationAddresses(
        bytes32[] memory _hashedEcosystemNames,
        address[] memory _implementationAddresses,
        uint256[] memory _indexes
    ) external;

    function removeCollection(
        address _implementationAddress,
        address _collectionAddress,
        uint256 _index
    ) external;

    function createEcosystemSettings(string memory _ecosystemName, bytes memory _settings) external;

    function updateEcosystemSettings(bytes32 _hashedEcosystemName, bytes memory _settings) external;

    function getEcosystemSettings(bytes32 _hashedEcosystemName, uint64 _blockNumber)
        external
        view
        returns (bytes memory);

    function getEcosystems() external view returns (bytes32[] memory);

    function getEcosystems(uint256 _start, uint256 _end) external view returns (bytes32[] memory);

    function getCollections(address _implementationAddress) external view returns (address[] memory);

    function getCollections(
        address _implementationAddress,
        uint256 _start,
        uint256 _end
    ) external view returns (address[] memory);

    function getImplementationAddresses(bytes32 _hashedEcosystemName) external view returns (address[] memory);

    function getImplementationAddresses(
        bytes32 _hashedEcosystemName,
        uint256 _start,
        uint256 _end
    ) external view returns (address[] memory);
}
ICollection.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

interface ICollection {
    function verifyEcosystemSettings(bytes memory _settings) external pure returns (bool);
}
ReentrancyGuard.sol 62 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
IERC721Enumerable.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
CollectionFactory.sol 471 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import { ICollectionFactory } from "../interfaces/ICollectionFactory.sol";
import { ICollection } from "../interfaces/ICollection.sol";
import { ICollectionCloneable } from "../interfaces/ICollectionCloneable.sol";
import { IOwnable } from "../interfaces/IOwnable.sol";
import { IHashes } from "../interfaces/IHashes.sol";
import { LibClone } from "../lib/LibClone.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

/**
 * @title CollectionFactory
 * @author DEX Labs
 * @notice This contract is the registry for Hashes Collections.
 */
contract CollectionFactory is ICollectionFactory, Ownable, ReentrancyGuard {
    /// @notice A checkpoint for ecosystem settings values. Settings are ABI encoded bytes
    ///         to provide the most flexibility towards various implementation contracts.
    struct SettingsCheckpoint {
        uint64 id;
        bytes settings;
    }

    /// @notice A structure for storing the contract addresses of collection instances.
    struct CollectionContracts {
        bool exists;
        bool cloneable;
        address[] contractAddresses;
    }

    IHashes hashesToken;

    /// @notice collections A mapping of implementation addresses to a struct which
    ///         contains an array of the cloned collections for that implementation.
    mapping(address => CollectionContracts) public collections;

    /// @notice ecosystems An array of the hashed ecosystem names which correspond to
    ///         a settings format which can be used by multiple implementation contracts.
    bytes32[] public ecosystems;

    /// @notice ecosystemSettings A mapping of hashed ecosystem names to an array of
    ///         settings checkpoints. Settings checkpoints contain ABI encoded data
    ///         which can be decoded in implementation addresses that consume them.
    mapping(bytes32 => SettingsCheckpoint[]) public ecosystemSettings;

    /// @notice implementationAddresses A mapping of hashed ecosystem names to an array
    ///         of the implementation addresses for that ecosystem.
    mapping(bytes32 => address[]) public implementationAddresses;

    /// @notice factoryMaintainerAddress An address which has some distinct maintenance abilities. These
    ///         include the ability to remove implementation addresses or collection instances, as well as
    ///         transfer this role to another address. Implementation addresses can choose to use this address
    ///         for certain roles since it is passed through to the initialize function upon creating
    ///         a cloned collection.
    address public factoryMaintainerAddress;

    /// @notice ImplementationAddressAdded Emitted when an implementation address is added.
    event ImplementationAddressAdded(address indexed implementationAddress, bool indexed cloneable);

    /// @notice CollectionCreated Emitted when a Collection is created.
    event CollectionCreated(
        address indexed implementationAddress,
        address indexed collectionAddress,
        address indexed creator
    );

    /// @notice FactoryMaintainerAddressSet Emitted when the factory maintainer address is set.
    event FactoryMaintainerAddressSet(address indexed factoryMaintainerAddress);

    /// @notice ImplementationAddressesRemoved Emitted when implementation addresses are removed.
    event ImplementationAddressesRemoved(address[] implementationAddresses);

    /// @notice CollectionAddressRemoved Emitted when a cloned collection contract address is removed.
    event CollectionAddressRemoved(address indexed implementationAddress, address indexed collectionAddress);

    /// @notice EcosystemSettingsCreated Emitted when ecosystem settings are created.
    event EcosystemSettingsCreated(string ecosystemName, bytes32 indexed hashedEcosystemName, bytes settings);

    /// @notice EcosystemSettingsUpdated Emitted when ecosystem settings are updated.
    event EcosystemSettingsUpdated(bytes32 indexed hashedEcosystemName, bytes settings);

    modifier onlyOwnerOrFactoryMaintainer() {
        require(
            _msgSender() == factoryMaintainerAddress || _msgSender() == owner(),
            "CollectionFactory: must be either factory maintainer or owner"
        );
        _;
    }

    /**
     * @notice Constructor for the Collection Factory.
     */
    constructor(IHashes _hashesToken) {
        // initially set the factoryMaintainerAddress to be the deployer, though this can transfered
        factoryMaintainerAddress = _msgSender();
        hashesToken = _hashesToken;

        // make HashesDAO the owner of this Factory contract
        transferOwnership(IOwnable(address(hashesToken)).owner());
    }

    /**
     * @notice This function adds an implementation address.
     * @param _hashedEcosystemName The ecosystem which this implementation address will reference.
     * @param _implementationAddress The address of the Collection contract.
     * @param _cloneable Whether this implementation address is cloneable.
     */
    function addImplementationAddress(
        bytes32 _hashedEcosystemName,
        address _implementationAddress,
        bool _cloneable
    ) external override {
        require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem doesn't exist");
        CollectionContracts storage collection = collections[_implementationAddress];
        require(!collection.exists, "CollectionFactory: implementation address already exists");
        require(_implementationAddress != address(0), "CollectionFactory: implementation address cannot be 0 address");

        uint64 blockNumber = safe64(block.number, "CollectionFactory: exceeds 64 bits.");
        require(
            ICollection(_implementationAddress).verifyEcosystemSettings(
                getCheckpointedSettings(ecosystemSettings[_hashedEcosystemName], blockNumber)
            ),
            "CollectionFactory: implementation address doesn't properly validate ecosystem settings"
        );

        collection.exists = true;
        collection.cloneable = _cloneable;

        implementationAddresses[_hashedEcosystemName].push(_implementationAddress);

        emit ImplementationAddressAdded(_implementationAddress, _cloneable);
    }

    /**
     * @notice This function clones a Hashes Collection implementation contract.
     * @param _implementationAddress The address of the cloneable implementation contract.
     * @param _initializationData The abi encoded initialization data which is consumable
     *        by the implementation contract in its initialize function.
     */
    function createCollection(address _implementationAddress, bytes memory _initializationData)
        external
        override
        nonReentrant
    {
        CollectionContracts storage collection = collections[_implementationAddress];
        require(collection.exists, "CollectionFactory: implementation address not found.");
        require(collection.cloneable, "CollectionFactory: implementation address is not cloneable.");

        ICollectionCloneable clonedCollection = ICollectionCloneable(LibClone.createClone(_implementationAddress));
        collection.contractAddresses.push(address(clonedCollection));

        clonedCollection.initialize(hashesToken, factoryMaintainerAddress, _msgSender(), _initializationData);

        emit CollectionCreated(_implementationAddress, address(clonedCollection), _msgSender());
    }

    /**
     * @notice This function sets the factory maintainer address.
     * @param _factoryMaintainerAddress The address of the factory maintainer.
     */
    function setFactoryMaintainerAddress(address _factoryMaintainerAddress)
        external
        override
        onlyOwnerOrFactoryMaintainer
    {
        factoryMaintainerAddress = _factoryMaintainerAddress;
        emit FactoryMaintainerAddressSet(_factoryMaintainerAddress);
    }

    /**
     * @notice This function removes implementation addresses from the factory.
     * @param _hashedEcosystemNames The ecosystems which these implementation addresses reference.
     * @param _implementationAddressesToRemove The implementation addresses to remove: either cloneable
     *        implementation addresses or a standalone contracts.
     * @param _indexes The array indexes to be removed. Must be monotonically increasing and match the items
     *        in the other two arrays. This array is provided to reduce the cost of removal.
     */
    function removeImplementationAddresses(
        bytes32[] memory _hashedEcosystemNames,
        address[] memory _implementationAddressesToRemove,
        uint256[] memory _indexes
    ) external override onlyOwnerOrFactoryMaintainer {
        require(
            _hashedEcosystemNames.length == _implementationAddressesToRemove.length &&
                _hashedEcosystemNames.length == _indexes.length,
            "CollectionFactory: arrays provided must be the same length"
        );

        // set this to max int to start so first less-than comparison is always true
        uint256 _previousIndex = 2**256 - 1;

        // iterate through items in reverse order
        for (uint256 i = 0; i < _indexes.length; i++) {
            require(
                _indexes[_indexes.length - 1 - i] < _previousIndex,
                "CollectionFactory: arrays must be ordered before processing."
            );
            _previousIndex = _indexes[_indexes.length - 1 - i];

            bytes32 _hashedEcosystemName = _hashedEcosystemNames[_indexes.length - 1 - i];
            address _implementationAddress = _implementationAddressesToRemove[_indexes.length - 1 - i];
            uint256 _currentIndex = _indexes[_indexes.length - 1 - i];

            require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem doesn't exist");
            require(collections[_implementationAddress].exists, "CollectionFactory: implementation address not found.");
            address[] storage _implementationAddresses = implementationAddresses[_hashedEcosystemName];
            require(_currentIndex < _implementationAddresses.length, "CollectionFactory: array index out of bounds.");
            require(
                _implementationAddresses[_currentIndex] == _implementationAddress,
                "CollectionFactory: element at array index not equal to implementation address."
            );

            // remove the implementation address from the mapping
            delete collections[_implementationAddress];

            // swap the last element of the array for the one we're removing
            _implementationAddresses[_currentIndex] = _implementationAddresses[_implementationAddresses.length - 1];
            _implementationAddresses.pop();
        }

        emit ImplementationAddressesRemoved(_implementationAddressesToRemove);
    }

    /**
     * @notice This function removes a cloned collection address from the factory.
     * @param _implementationAddress The implementation address of the cloneable contract.
     * @param _collectionAddress The cloned collection address to be removed.
     * @param _index The array index to be removed. This is provided to reduce the cost of removal.
     */
    function removeCollection(
        address _implementationAddress,
        address _collectionAddress,
        uint256 _index
    ) external override onlyOwnerOrFactoryMaintainer {
        CollectionContracts storage collection = collections[_implementationAddress];
        require(collection.exists, "CollectionFactory: implementation address not found.");
        require(_index < collection.contractAddresses.length, "CollectionFactory: array index out of bounds.");
        require(
            collection.contractAddresses[_index] == _collectionAddress,
            "CollectionFactory: element at array index not equal to collection address."
        );

        // swap the last element of the array for the one we're removing
        collection.contractAddresses[_index] = collection.contractAddresses[collection.contractAddresses.length - 1];
        collection.contractAddresses.pop();

        emit CollectionAddressRemoved(_implementationAddress, _collectionAddress);
    }

    /**
     * @notice This function creates a new ecosystem setting key in the mapping along with
     *         the initial ABI encoded settings value to be used for that key. The factory maintainer
     *         can create a new ecosystem setting to allow for efficient bootstrapping of a new
     *         ecosystem, but only HashesDAO can update an existing ecosystem.
     * @param _ecosystemName The name of the ecosystem.
     * @param _settings The ABI encoded settings data which can be decoded by implementation
     *        contracts which consume this ecosystem.
     */
    function createEcosystemSettings(string memory _ecosystemName, bytes memory _settings)
        external
        override
        onlyOwnerOrFactoryMaintainer
    {
        bytes32 hashedEcosystemName = keccak256(abi.encodePacked(_ecosystemName));
        require(
            ecosystemSettings[hashedEcosystemName].length == 0,
            "CollectionFactory: ecosystem settings for this name already exist"
        );

        uint64 blockNumber = safe64(block.number, "CollectionFactory: exceeds 64 bits.");
        ecosystemSettings[hashedEcosystemName].push(SettingsCheckpoint({ id: blockNumber, settings: _settings }));

        ecosystems.push(hashedEcosystemName);

        emit EcosystemSettingsCreated(_ecosystemName, hashedEcosystemName, _settings);
    }

    /**
     * @notice This function updates an ecosystem setting which means a new checkpoint is
     *         added to the array of settings checkpoints for that ecosystem. Only HashesDAO
     *         can call this function since these are likely to be more established ecosystems
     *         which have more impact.
     * @param _hashedEcosystemName The hashed name of the ecosystem.
     * @param _settings The ABI encoded settings data which can be decoded by implementation
     *        contracts which consume this ecosystem.
     */
    function updateEcosystemSettings(bytes32 _hashedEcosystemName, bytes memory _settings) external override onlyOwner {
        require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem settings not found");
        require(
            implementationAddresses[_hashedEcosystemName].length > 0,
            "CollectionFactory: no implementation addresses for this ecosystem"
        );

        ICollection firstImplementationAddress = ICollection(implementationAddresses[_hashedEcosystemName][0]);
        require(
            firstImplementationAddress.verifyEcosystemSettings(_settings),
            "CollectionFactory: invalid ecosystem settings according to first implementation contract"
        );

        uint64 blockNumber = safe64(block.number, "CollectionFactory: exceeds 64 bits.");
        ecosystemSettings[_hashedEcosystemName].push(SettingsCheckpoint({ id: blockNumber, settings: _settings }));

        emit EcosystemSettingsUpdated(_hashedEcosystemName, _settings);
    }

    /**
     * @notice This function gets the ecosystem settings from a particular ecosystem checkpoint.
     * @param _hashedEcosystemName The hashed name of the ecosystem.
     * @param _blockNumber The block number in which the new Collection was initialized. This is
     *        used to determine which settings were active at the time of Collection creation.
     */
    function getEcosystemSettings(bytes32 _hashedEcosystemName, uint64 _blockNumber)
        external
        view
        override
        returns (bytes memory)
    {
        require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem settings not found");

        return getCheckpointedSettings(ecosystemSettings[_hashedEcosystemName], _blockNumber);
    }

    /**
     * @notice This function returns an array of the Hashes Collections
     *         created through this registry for a particular implementation address.
     * @param _implementationAddress The implementation address.
     * @return An array of Collection addresses.
     */
    function getCollections(address _implementationAddress) external view override returns (address[] memory) {
        require(collections[_implementationAddress].exists, "CollectionFactory: implementation address not found.");
        return collections[_implementationAddress].contractAddresses;
    }

    /**
     * @notice This function returns an array of the Hashes Collections
     *         created through this registry for a particular implementation address.
     * @param _implementationAddress The implementation address.
     * @param _start The array start index (inclusive).
     * @param _end The array end index (exclusive).
     * @return An array of Collection addresses.
     */
    function getCollections(
        address _implementationAddress,
        uint256 _start,
        uint256 _end
    ) external view override returns (address[] memory) {
        CollectionContracts storage collection = collections[_implementationAddress];

        require(collection.exists, "CollectionFactory: implementation address not found.");
        require(
            _start < collection.contractAddresses.length &&
                _end <= collection.contractAddresses.length &&
                _end > _start,
            "CollectionFactory: Array indices out of bounds"
        );

        address[] memory collectionsForImplementation = new address[](_end - _start);
        for (uint256 i = _start; i < _end; i++) {
            collectionsForImplementation[i] = collection.contractAddresses[i];
        }
        return collectionsForImplementation;
    }

    /**
     * @notice This function gets the list of hashed ecosystem names.
     * @return An array of the hashed ecosystem names.
     */
    function getEcosystems() external view override returns (bytes32[] memory) {
        return ecosystems;
    }

    /**
     * @notice This function gets the list of hashed ecosystem names.
     * @param _start The array start index (inclusive).
     * @param _end The array end index (exclusive).
     * @return An array of the hashed ecosystem names.
     */
    function getEcosystems(uint256 _start, uint256 _end) external view override returns (bytes32[] memory) {
        require(
            _start < ecosystems.length && _end <= ecosystems.length && _end > _start,
            "CollectionFactory: Array indices out of bounds"
        );

        bytes32[] memory _ecosystems = new bytes32[](_end - _start);
        for (uint256 i = _start; i < _end; i++) {
            _ecosystems[i] = ecosystems[i];
        }
        return _ecosystems;
    }

    /**
     * @notice This function returns an array of the implementation addresses.
     * @param _hashedEcosystemName The ecosystem to fetch implementation addresses from.
     * @return Array of Hashes Collection implementation addresses.
     */
    function getImplementationAddresses(bytes32 _hashedEcosystemName)
        external
        view
        override
        returns (address[] memory)
    {
        require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem doesn't exist");
        return implementationAddresses[_hashedEcosystemName];
    }

    /**
     * @notice This function returns an array of the implementation addresses.
     * @param _hashedEcosystemName The ecosystem to fetch implementation addresses from.
     * @param _start The array start index (inclusive).
     * @param _end The array end index (exclusive).
     * @return Array of Hashes Collection implementation addresses.
     */
    function getImplementationAddresses(
        bytes32 _hashedEcosystemName,
        uint256 _start,
        uint256 _end
    ) external view override returns (address[] memory) {
        require(ecosystemSettings[_hashedEcosystemName].length > 0, "CollectionFactory: ecosystem doesn't exist");
        require(
            _start < implementationAddresses[_hashedEcosystemName].length &&
                _end <= implementationAddresses[_hashedEcosystemName].length &&
                _end > _start,
            "CollectionFactory: Array indices out of bounds"
        );

        address[] memory _implementationAddresses = new address[](_end - _start);
        for (uint256 i = _start; i < _end; i++) {
            _implementationAddresses[i] = implementationAddresses[_hashedEcosystemName][i];
        }
        return _implementationAddresses;
    }

    function getCheckpointedSettings(SettingsCheckpoint[] storage _settingsCheckpoints, uint64 _blockNumber)
        private
        view
        returns (bytes storage)
    {
        require(
            _blockNumber >= _settingsCheckpoints[0].id,
            "CollectionFactory: Block number before first settings block"
        );

        // If blocknumber greater than highest checkpoint, just return the latest checkpoint
        if (_blockNumber >= _settingsCheckpoints[_settingsCheckpoints.length - 1].id)
            return _settingsCheckpoints[_settingsCheckpoints.length - 1].settings;

        // Binary search for the matching checkpoint
        uint256 min = 0;
        uint256 max = _settingsCheckpoints.length - 1;
        while (max > min) {
            uint256 mid = (max + min + 1) / 2;

            if (_settingsCheckpoints[mid].id == _blockNumber) {
                return _settingsCheckpoints[mid].settings;
            }
            if (_settingsCheckpoints[mid].id < _blockNumber) {
                min = mid;
            } else {
                max = mid - 1;
            }
        }
        return _settingsCheckpoints[min].settings;
    }

    function safe64(uint256 n, string memory errorMessage) internal pure returns (uint64) {
        require(n < 2**64, errorMessage);
        return uint64(n);
    }
}
LibClone.sol 52 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

/*
    The MIT License (MIT)
    Copyright (c) 2018 Murray Software, LLC.
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:
    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly

library LibClone {
    function createClone(address target) internal returns (address result) {
        bytes20 targetBytes = bytes20(target);
        assembly {
            let clone := mload(0x40)
            mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(clone, 0x14), targetBytes)
            mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            result := create(0, clone, 0x37)
        }
    }

    function isClone(address target, address query) internal view returns (bool result) {
        bytes20 targetBytes = bytes20(target);
        assembly {
            let clone := mload(0x40)
            mstore(clone, 0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000)
            mstore(add(clone, 0xa), targetBytes)
            mstore(add(clone, 0x1e), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)

            let other := add(clone, 0x40)
            extcodecopy(query, other, 0, 0x2d)
            result := and(eq(mload(clone), mload(other)), eq(mload(add(clone, 0xd)), mload(add(other, 0xd))))
        }
    }
}

Read Contract

collections 0x43add2e6 → bool, bool
ecosystemSettings 0xa0755f9b → uint64, bytes
ecosystems 0x6d38718e → bytes32
factoryMaintainerAddress 0x198bb095 → address
getCollections 0x127f1498 → address[]
getCollections 0x5cf4ea66 → address[]
getEcosystemSettings 0xc265d191 → bytes
getEcosystems 0x202f9b8b → bytes32[]
getEcosystems 0x9e409325 → bytes32[]
getImplementationAddresses 0xb1966630 → address[]
getImplementationAddresses 0xc2ff84bc → address[]
implementationAddresses 0x7f17426f → address
owner 0x8da5cb5b → address

Write Contract 9 functions

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

addImplementationAddress 0xf0e113ea
bytes32 _hashedEcosystemName
address _implementationAddress
bool _cloneable
createCollection 0xda1fdccf
address _implementationAddress
bytes _initializationData
createEcosystemSettings 0x8a6f0b38
string _ecosystemName
bytes _settings
removeCollection 0x8c2fb990
address _implementationAddress
address _collectionAddress
uint256 _index
removeImplementationAddresses 0x484455a7
bytes32[] _hashedEcosystemNames
address[] _implementationAddressesToRemove
uint256[] _indexes
renounceOwnership 0x715018a6
No parameters
setFactoryMaintainerAddress 0x9e6d0ce4
address _factoryMaintainerAddress
transferOwnership 0xf2fde38b
address newOwner
updateEcosystemSettings 0x3efebd4c
bytes32 _hashedEcosystemName
bytes _settings

Recent Transactions

No transactions found for this address