Address Contract Verified
Address
0x4D232CD85294Acd53Ec03F4A57F57888c9Ea1946
Balance
0 ETH
Nonce
1
Code Size
17660 bytes
Creator
0x0230Eb06...B33E at tx 0x70895563...65265e
Indexed Transactions
0
Contract Bytecode
17660 bytes
0x608060405234801561001057600080fd5b506004361061027e5760003560e01c80636c2f5acd11610156578063b88d4fde116100d3578063c4ed6e7611610097578063f2fde38b11610071578063f2fde38b14610603578063f47c84c514610616578063ffe119ec1461061f57600080fd5b8063c4ed6e76146105a1578063c87b56dd146105b4578063e985e9c5146105c757600080fd5b8063b88d4fde14610532578063b9c4d9fb14610545578063bb3bafd614610565578063bd227e5714610586578063bff356181461058e57600080fd5b80638da5cb5b1161011a5780638da5cb5b146104c757806395d89b41146104d85780639b0946b1146104f9578063a22cb4651461050c578063a7d1ab8c1461051f57600080fd5b80636c2f5acd1461047d5780636d73e669146104905780636f39cf40146104a357806370a08231146104ac578063715018a6146104bf57600080fd5b80632ca15122116101ff5780633fce3529116101c3578063465bcea11161019d578063465bcea114610441578063626b5419146104575780636352211e1461046a57600080fd5b80633fce35291461040857806342842e0e1461041b57806342966c681461042e57600080fd5b80632ca15122146103b05780632d345670146103b85780632f2fc416146103cb57806331ae450b146103e0578063356e0281146103f557600080fd5b80630ebd4c7f116102465780630ebd4c7f146103305780630f15f4c01461035057806323b872dd1461035857806324d7806c1461036b5780632a55205a1461037e57600080fd5b8063017f776d1461028357806301ffc9a71461029857806306fdde03146102c0578063081812fc146102f2578063095ea7b31461031d575b600080fd5b610296610291366004613692565b610632565b005b6102ab6102a63660046136c1565b61068a565b60405190151581526020015b60405180910390f35b60408051808201909152600d81526c4d6574616d6f7270686f73697360981b60208201525b6040516102b79190613736565b610305610300366004613692565b610721565b6040516001600160a01b0390911681526020016102b7565b61029661032b36600461375e565b6107b6565b61034361033e366004613692565b6108e9565b6040516102b791906137c5565b610296610945565b6102966103663660046137d8565b610a58565b6102ab610379366004613819565b610add565b61039161038c366004613836565b610b16565b604080516001600160a01b0390931683526020830191909152016102b7565b610296610b51565b6102966103c6366004613819565b610d51565b6103d3610e00565b6040516102b79190613858565b6103e8610f3e565b6040516102b79190613903565b610296610403366004613995565b610fed565b610296610416366004613b33565b6112b7565b6102966104293660046137d8565b611314565b61029661043c366004613692565b61132f565b610449600a81565b6040519081526020016102b7565b610449610465366004613692565b6113f9565b610305610478366004613692565b61146c565b61029661048b36600461375e565b6114e3565b61029661049e366004613819565b611553565b610449600a5481565b6104496104ba366004613819565b6115fd565b610296611684565b6000546001600160a01b0316610305565b60408051808201909152600581526409a9ea4a0960db1b60208201526102e5565b610296610507366004613be9565b6116ea565b61029661051a366004613dbb565b611915565b61044961052d366004613692565b611920565b610296610540366004613df0565b61196e565b610558610553366004613692565b6119f9565b6040516102b79190613ea9565b610578610573366004613692565b611a72565b6040516102b7929190613ebc565b61044960fa81565b61029661059c366004613eea565b611b26565b6102966105af366004613f05565b611b83565b6102e56105c2366004613692565b611e24565b6102ab6105d5366004613f41565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b610296610611366004613819565b612612565b61044960095481565b61029661062d366004613f8e565b6126da565b336106456000546001600160a01b031690565b6001600160a01b031614806106605750610660600133612982565b6106855760405162461bcd60e51b815260040161067c906140ae565b60405180910390fd5b600a55565b60006001600160e01b031982166380ac58cd60e01b14806106bb57506001600160e01b03198216635b5e139f60e01b145b806106d657506001600160e01b03198216635d9dd7eb60e11b145b806106f157506001600160e01b0319821663152a902d60e11b145b8061070c57506001600160e01b03198216632dde656160e21b145b8061071b575061071b826129a7565b92915050565b6000818152600360205260408120546001600160a01b031661079a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161067c565b506000908152600560205260409020546001600160a01b031690565b60006107c18261146c565b9050806001600160a01b0316836001600160a01b03160361082e5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161067c565b336001600160a01b038216148061086857506001600160a01b038116600090815260066020908152604080832033845290915290205460ff165b6108da5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161067c565b6108e483836129dc565b505050565b6010546060906001600160a01b031615610940576040805160018082528183019092529060208083019080368337019050509050600f5481600081518110610933576109336140f2565b6020026020010181815250505b919050565b336109586000546001600160a01b031690565b6001600160a01b031614806109735750610973600133612982565b61098f5760405162461bcd60e51b815260040161067c906140ae565b600e5460ff16156109d65760405162461bcd60e51b8152602060048201526011602482015270105b1c9958591e481858dd1a5d985d1959607a1b604482015260640161067c565b60005b600b54811015610a37576000600b82815481106109f8576109f86140f2565b60009182526020909120600290910201805467ffffffffffffffff60a81b191664050000000560a91b1790555080610a2f8161411e565b9150506109d9565b50600b54610a469060fa614137565b600955600e805460ff19166001179055565b610a63335b82612a4a565b610a7f5760405162461bcd60e51b815260040161067c90614156565b60085460ff1615610ad25760405162461bcd60e51b815260206004820152601e60248201527f4552433732313a207472616e73666572206e6f74207065726d69747465640000604482015260640161067c565b6108e4838383612b41565b6000816001600160a01b0316610afb6000546001600160a01b031690565b6001600160a01b0316148061071b575061071b600183612982565b601054600f5460009182916001600160a01b039091169061271090610b3b9086614137565b610b4591906141bd565b915091505b9250929050565b600e5460ff16610b935760405162461bcd60e51b815260206004820152600d60248201526c139bdd081858dd1a5d985d1959609a1b604482015260640161067c565b6000805b600b54811015610d0057336001600160a01b0316600b8281548110610bbe57610bbe6140f2565b60009182526020909120600290910201546001600160a01b031603610cee57600b8181548110610bf057610bf06140f2565b6000918252602090912060029091020154600160a01b900460ff1615610c585760405162461bcd60e51b815260206004820152601760248201527f596f75206861766520616c7265616479207369676e6564000000000000000000604482015260640161067c565b600191506001600b8281548110610c7157610c716140f2565b6000918252602082206002909102018054921515600160a01b0260ff60a01b19909316929092179091555b600a811015610ce857600081610cb360fa85614137565b610cbd91906141d1565b610cc89060016141d1565b9050610cd5333383612ce7565b5080610ce08161411e565b915050610c9c565b50610d00565b80610cf88161411e565b915050610b97565b5080610d4e5760405162461bcd60e51b815260206004820152601660248201527f596f7520617265206e6f7420616e2063726561746f7200000000000000000000604482015260640161067c565b50565b6000546001600160a01b03163314610dab5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067c565b610db6600182612982565b15610d4e5760405133906001600160a01b038316907f7c0c3c84c67c85fcac635147348bfe374c24a1a93d0366d1cfe9d8853cbf89d590600090a3610dfc600182612e88565b5050565b6060600b805480602002602001604051908101604052809291908181526020016000905b82821015610f355760008481526020908190206040805160a0810182526002860290920180546001600160a01b038116845260ff600160a01b82041615159484019490945263ffffffff600160a81b8504811692840192909252600160c81b909304166060820152600182018054919291608084019190610ea4906141e9565b80601f0160208091040260200160405190810160405280929190818152602001828054610ed0906141e9565b8015610f1d5780601f10610ef257610100808354040283529160200191610f1d565b820191906000526020600020905b815481529060010190602001808311610f0057829003601f168201915b50505050508152505081526020019060010190610e24565b50505050905090565b6060610f4a6001612e9d565b67ffffffffffffffff811115610f6257610f626139e1565b604051908082528060200260200182016040528015610f8b578160200160208202803683370190505b50905060005b610f9b6001612e9d565b811015610fe957610fad600182612ea7565b828281518110610fbf57610fbf6140f2565b6001600160a01b039092166020928302919091019091015280610fe18161411e565b915050610f91565b5090565b60085460ff16156110365760405162461bcd60e51b8152602060048201526013602482015272135bdc9c1a081b9bdd081c195c9b5a5d1d1959606a1b604482015260640161067c565b6004811461107c5760405162461bcd60e51b8152602060048201526013602482015272496e73756666696369656e7420746f6b656e7360681b604482015260640161067c565b60006110878461146c565b9050336001600160a01b038216146110d75760405162461bcd60e51b815260206004820152601360248201527226bab9ba103132903a37b5b2b71037bbb732b960691b604482015260640161067c565b6000848152600c6020526040902054600a546110f48260016141d1565b106111345760405162461bcd60e51b815260206004820152601060248201526f13585e08199bdc9b481c995858da195960821b604482015260640161067c565b60005b83811015611290576000858583818110611153576111536140f2565b90506020020135905080871415801561117c5750336111718261146c565b6001600160a01b0316145b801561119657506000818152600c60205260409020548311155b6111e25760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420746f6b656e20746f206275726e0000000000000000000000604482015260640161067c565b60006111ef8360016141d1565b90505b858110156112735786868281811061120c5761120c6140f2565b9050602002013582036112615760405162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742068617665206475706c696361746520746f6b656e7300000000604482015260640161067c565b8061126b8161411e565b9150506111f2565b5061127d81612eb3565b50806112888161411e565b915050611137565b506000858152600c602052604081208054916112ab8361411e565b91905055505050505050565b336112ca6000546001600160a01b031690565b6001600160a01b031614806112e557506112e5600133612982565b6113015760405162461bcd60e51b815260040161067c906140ae565b8051610dfc9060079060208401906134fe565b6108e48383836040518060200160405280600081525061196e565b61133833610a5d565b61139d5760405162461bcd60e51b815260206004820152603060248201527f4552433732314275726e61626c653a2063616c6c6572206973206e6f74206f7760448201526f1b995c881b9bdc88185c1c1c9bdd995960821b606482015260840161067c565b60085460ff16156113f05760405162461bcd60e51b815260206004820152601e60248201527f4552433732313a207472616e73666572206e6f74207065726d69747465640000604482015260640161067c565b610d4e81612eb3565b6000818152600360205260408120546001600160a01b031661142d5760405162461bcd60e51b815260040161067c90614223565b600b61143883612fb8565b81548110611448576114486140f2565b6000918252602090912060029091020154600160c81b900463ffffffff1692915050565b6000818152600360205260408120546001600160a01b03168061071b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161067c565b336114f66000546001600160a01b031690565b6001600160a01b031614806115115750611511600133612982565b61152d5760405162461bcd60e51b815260040161067c906140ae565b601080546001600160a01b0319166001600160a01b039390931692909217909155600f55565b6000546001600160a01b031633146115ad5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067c565b6115b8600182612982565b610d4e5760405133906001600160a01b038316907f7e1a1a08d52e4ba0e21554733d66165fd5151f99460116223d9e3a608eec5cb190600090a3610dfc600182612fd1565b60006001600160a01b0382166116685760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161067c565b506001600160a01b031660009081526004602052604090205490565b6000546001600160a01b031633146116de5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067c565b6116e86000612fe6565b565b336116fd6000546001600160a01b031690565b6001600160a01b031614806117185750611718600133612982565b6117345760405162461bcd60e51b815260040161067c906140ae565b6000821180156117465750600a548211155b6117815760405162461bcd60e51b815260206004820152600c60248201526b496e76616c696420666f726d60a01b604482015260640161067c565b60005b81518110156108e45760008282815181106117a1576117a16140f2565b60200260200101519050600080805b600b548110156118185783600001516001600160a01b0316600b82815481106117db576117db6140f2565b60009182526020909120600290910201546001600160a01b0316036118065760019250809150611818565b806118108161411e565b9150506117b0565b50816118665760405162461bcd60e51b815260206004820152601660248201527f43726561746f7220646f6573206e6f7420657869737400000000000000000000604482015260640161067c565b6020830151600d600061187a60018a61426e565b8152602080820192909252604090810160009081208582528352208251805191926118aa92849290910190613557565b5060208281015180516118c39260018501920190613557565b50604082015180516118df916002840191602090910190613557565b50606082015180516118fb916003840191602090910190613557565b50905050505050808061190d9061411e565b915050611784565b610dfc338383613036565b6000818152600360205260408120546001600160a01b03166119545760405162461bcd60e51b815260040161067c90614223565b6000828152600c602052604090205461071b9060016141d1565b6119783383612a4a565b6119945760405162461bcd60e51b815260040161067c90614156565b60085460ff16156119e75760405162461bcd60e51b815260206004820152601e60248201527f4552433732313a207472616e73666572206e6f74207065726d69747465640000604482015260640161067c565b6119f384848484613104565b50505050565b6010546060906001600160a01b031615610940576040805160018082528183019092529060208083019080368337505060105482519293506001600160a01b031691839150600090611a4d57611a4d6140f2565b60200260200101906001600160a01b031690816001600160a01b031681525050919050565b60105460609081906001600160a01b031615611b21576040805160018082528183019092529060208083019080368337505060105482519294506001600160a01b031691849150600090611ac857611ac86140f2565b6001600160a01b0392909216602092830291909101820152604080516001808252818301909252918281019080368337019050509050600f5481600081518110611b1457611b146140f2565b6020026020010181815250505b915091565b33611b396000546001600160a01b031690565b6001600160a01b03161480611b545750611b54600133612982565b611b705760405162461bcd60e51b815260040161067c906140ae565b6008805460ff1916911515919091179055565b33611b966000546001600160a01b031690565b6001600160a01b03161480611bb15750611bb1600133612982565b611bcd5760405162461bcd60e51b815260040161067c906140ae565b60008060005b600b54811015611c3757856001600160a01b0316600b8281548110611bfa57611bfa6140f2565b60009182526020909120600290910201546001600160a01b031603611c255760019150809250611c37565b80611c2f8161411e565b915050611bd3565b5080611c795760405162461bcd60e51b815260206004820152601160248201527010dc99585d1bdc881b9bdd08199bdd5b99607a1b604482015260640161067c565b6000600b8381548110611c8e57611c8e6140f2565b60009182526020909120600290910201805490915060fa90611cbe908690600160a81b900463ffffffff166141d1565b1115611d015760405162461bcd60e51b8152602060048201526012602482015271151bdbc81b585b9e481c995c5d595cdd195960721b604482015260640161067c565b60005b84811015611d98576000868683818110611d2057611d206140f2565b9050602002016020810190611d359190613819565b83549091506000908390600160a81b900463ffffffff16611d5760fa89614137565b611d6191906141d1565b611d6b91906141d1565b611d769060016141d1565b9050611d83898383612ce7565b50508080611d909061411e565b915050611d04565b50805484908290601590611dba908490600160a81b900463ffffffff16614285565b92506101000a81548163ffffffff021916908363ffffffff160217905550848490508160000160198282829054906101000a900463ffffffff16611dfe9190614285565b92506101000a81548163ffffffff021916908363ffffffff160217905550505050505050565b6000818152600360205260409020546060906001600160a01b0316611ea35760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161067c565b6000611eae83612fb8565b6000848152600c60209081526040808320548352600d82528083208484529091528082208151608081019092528054939450919290919082908290611ef2906141e9565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1e906141e9565b8015611f6b5780601f10611f4057610100808354040283529160200191611f6b565b820191906000526020600020905b815481529060010190602001808311611f4e57829003601f168201915b50505050508152602001600182018054611f84906141e9565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb0906141e9565b8015611ffd5780601f10611fd257610100808354040283529160200191611ffd565b820191906000526020600020905b815481529060010190602001808311611fe057829003601f168201915b50505050508152602001600282018054612016906141e9565b80601f0160208091040260200160405190810160405280929190818152602001828054612042906141e9565b801561208f5780601f106120645761010080835404028352916020019161208f565b820191906000526020600020905b81548152906001019060200180831161207257829003601f168201915b505050505081526020016003820180546120a8906141e9565b80601f01602080910402602001604051908101604052809291908181526020018280546120d4906141e9565b80156121215780601f106120f657610100808354040283529160200191612121565b820191906000526020600020905b81548152906001019060200180831161210457829003601f168201915b50505050508152505090506000600b8381548110612141576121416140f2565b60009182526020918290206040805160a081018252600290930290910180546001600160a01b038116845260ff600160a01b82041615159484019490945263ffffffff600160a81b8504811692840192909252600160c81b9093041660608201526001820180549192916080840191906121ba906141e9565b80601f01602080910402602001604051908101604052809291908181526020018280546121e6906141e9565b80156122335780601f1061220857610100808354040283529160200191612233565b820191906000526020600020905b81548152906001019060200180831161221657829003601f168201915b5050505050815250509050606060005b6007548110156126085761229160078281548110612263576122636140f2565b90600052602060002001604051806040016040528060068152602001651e2720a6a29f60d11b815250613137565b156122bf5783516040516122a99184916020016142ad565b60405160208183030381529060405291506125f6565b61230a600782815481106122d5576122d56140f2565b906000526020600020016040518060400160405280600d81526020016c1e2222a9a1a924a82a24a7a71f60991b815250613137565b15612326578184602001516040516020016122a99291906142ad565b61236d6007828154811061233c5761233c6140f2565b90600052602060002001604051806040016040528060098152602001681e21a922a0aa27a91f60b91b815250613137565b156123885760808301516040516122a99184916020016142ad565b6123cd6007828154811061239e5761239e6140f2565b90600052602060002001604051806040016040528060078152602001661e24a6a0a3a29f60c91b815250613137565b156123e9578184604001516040516020016122a99291906142ad565b612432600782815481106123ff576123ff6140f2565b906000526020600020016040518060400160405280600b81526020016a1e20a724a6a0aa24a7a71f60a91b815250613137565b1561244d5760608401516040516122a99184916020016142ad565b61249160078281548110612463576124636140f2565b90600052602060002001604051806040016040528060068152602001651e2327a9269f60d11b815250613137565b156124cc576000878152600c602052604090205482906124bb906124b69060016141d1565b613190565b6040516020016122a99291906142ad565b612513600782815481106124e2576124e26140f2565b90600052602060002001604051806040016040528060098152602001681e22a224aa24a7a71f60b91b815250613137565b1561253157816124bb61252760fa88614137565b6124b6908a61426e565b61257660078281548110612547576125476140f2565b90600052602060002001604051806040016040528060078152602001661e2a27aa20a61f60c91b815250613137565b156125b557816124bb600b8781548110612592576125926140f2565b6000918252602090912060029091020154600160c81b900463ffffffff16613190565b81600782815481106125c9576125c96140f2565b906000526020600020016040516020016125e492919061436b565b60405160208183030381529060405291505b806126008161411e565b915050612243565b5095945050505050565b6000546001600160a01b0316331461266c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161067c565b6001600160a01b0381166126d15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161067c565b610d4e81612fe6565b336126ed6000546001600160a01b031690565b6001600160a01b031614806127085750612708600133612982565b6127245760405162461bcd60e51b815260040161067c906140ae565b600e5460ff16156127835760405162461bcd60e51b8152602060048201526024808201527f43616e6e6f74207365742063726561746f7273206166746572206163746976616044820152633a34b7b760e11b606482015260840161067c565b61278f600b60006135d7565b60005b8151811015610dfc5760008282815181106127af576127af6140f2565b6020026020010151905080602001511561280b5760405162461bcd60e51b815260206004820152601460248201527f7369676e6564206d7573742062652066616c7365000000000000000000000000604482015260640161067c565b604081015163ffffffff1615801561282b5750606081015163ffffffff16155b6128775760405162461bcd60e51b815260206004820152601b60248201527f65646974696f6e20616e6420746f74616c206d75737420626520300000000000604482015260640161067c565b600b8054600181018255600091909152815160029091027f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db9810180546020808601516040870151606088015163ffffffff908116600160c81b0263ffffffff60c81b1991909216600160a81b021667ffffffffffffffff60a81b19921515600160a01b0274ffffffffffffffffffffffffffffffffffffffffff199095166001600160a01b0390981697909717939093171694909417178155608084015180518594929361296b937f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01dba909101920190613557565b50505050808061297a9061411e565b915050612792565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b60006001600160e01b03198216632a9f3abf60e11b148061071b57506301ffc9a760e01b6001600160e01b031983161461071b565b600081815260056020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612a118261146c565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600360205260408120546001600160a01b0316612ac35760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161067c565b6000612ace8361146c565b9050806001600160a01b0316846001600160a01b03161480612b095750836001600160a01b0316612afe84610721565b6001600160a01b0316145b80612b3957506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b61deac196001600160a01b03831601612b5d576108e481612eb3565b826001600160a01b0316612b708261146c565b6001600160a01b031614612bd45760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b606482015260840161067c565b6001600160a01b038216612c365760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161067c565b612c416000826129dc565b6001600160a01b0383166000908152600460205260408120805460019290612c6a90849061426e565b90915550506001600160a01b0382166000908152600460205260408120805460019290612c989084906141d1565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716916000805160206144a783398151915291a4505050565b6001600160a01b038216612d3d5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161067c565b6000818152600360205260409020546001600160a01b031615612da25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161067c565b6001600160a01b0382166000908152600460205260408120805460019290612dcb9084906141d1565b9091555050600081815260036020526040902080546001600160a01b0319166001600160a01b0384811691821790925590841603612e2e5760405181906001600160a01b038416906000906000805160206144a7833981519152908290a4505050565b60405181906001600160a01b038516906000906000805160206144a7833981519152908290a480826001600160a01b0316846001600160a01b03166000805160206144a783398151915260405160405180910390a4505050565b60006129a0836001600160a01b038416613291565b600061071b825490565b60006129a08383613384565b6000612ebe8261146c565b9050600b612ecb83612fb8565b81548110612edb57612edb6140f2565b600091825260209091206002909102018054600160c81b900463ffffffff16906019612f0683614389565b91906101000a81548163ffffffff021916908363ffffffff16021790555050600c600083815260200190815260200160002060009055612f476000836129dc565b6001600160a01b0381166000908152600460205260408120805460019290612f7090849061426e565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416906000805160206144a7833981519152908390a45050565b600060fa612fc760018461426e565b61071b91906141bd565b60006129a0836001600160a01b0384166133ae565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b816001600160a01b0316836001600160a01b0316036130975760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161067c565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61310f848484612b41565b61311b848484846133fd565b6119f35760405162461bcd60e51b815260040161067c906143a9565b60008160405160200161314a91906143fb565b60405160208183030381529060405280519060200120836040516020016131719190614417565b6040516020818303038152906040528051906020012014905092915050565b6060816000036131b75750506040805180820190915260018152600360fc1b602082015290565b8160005b81156131e157806131cb8161411e565b91506131da9050600a836141bd565b91506131bb565b60008167ffffffffffffffff8111156131fc576131fc6139e1565b6040519080825280601f01601f191660200182016040528015613226576020820181803683370190505b5090505b8415612b395761323b60018361426e565b9150613248600a86614423565b6132539060306141d1565b60f81b818381518110613268576132686140f2565b60200101906001600160f81b031916908160001a90535061328a600a866141bd565b945061322a565b6000818152600183016020526040812054801561337a5760006132b560018361426e565b85549091506000906132c99060019061426e565b905081811461332e5760008660000182815481106132e9576132e96140f2565b906000526020600020015490508087600001848154811061330c5761330c6140f2565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061333f5761333f614437565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061071b565b600091505061071b565b600082600001828154811061339b5761339b6140f2565b9060005260206000200154905092915050565b60008181526001830160205260408120546133f55750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561071b565b50600061071b565b60006001600160a01b0384163b156134f357604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061344190339089908890889060040161444d565b6020604051808303816000875af192505050801561347c575060408051601f3d908101601f1916820190925261347991810190614489565b60015b6134d9573d8080156134aa576040519150601f19603f3d011682016040523d82523d6000602084013e6134af565b606091505b5080516000036134d15760405162461bcd60e51b815260040161067c906143a9565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612b39565b506001949350505050565b82805482825590600052602060002090810192821561354b579160200282015b8281111561354b578251805161353b918491602090910190613557565b509160200191906001019061351e565b50610fe99291506135f8565b828054613563906141e9565b90600052602060002090601f01602090048101928261358557600085556135cb565b82601f1061359e57805160ff19168380011785556135cb565b828001600101855582156135cb579182015b828111156135cb5782518255916020019190600101906135b0565b50610fe9929150613615565b5080546000825560020290600052602060002090810190610d4e919061362a565b80821115610fe957600061360c8282613658565b506001016135f8565b5b80821115610fe95760008155600101613616565b80821115610fe95780546001600160e81b0319168155600061364f6001830182613658565b5060020161362a565b508054613664906141e9565b6000825580601f10613674575050565b601f016020900490600052602060002090810190610d4e9190613615565b6000602082840312156136a457600080fd5b5035919050565b6001600160e01b031981168114610d4e57600080fd5b6000602082840312156136d357600080fd5b81356129a0816136ab565b60005b838110156136f95781810151838201526020016136e1565b838111156119f35750506000910152565b600081518084526137228160208601602086016136de565b601f01601f19169290920160200192915050565b6020815260006129a0602083018461370a565b6001600160a01b0381168114610d4e57600080fd5b6000806040838503121561377157600080fd5b823561377c81613749565b946020939093013593505050565b600081518084526020808501945080840160005b838110156137ba5781518752958201959082019060010161379e565b509495945050505050565b6020815260006129a0602083018461378a565b6000806000606084860312156137ed57600080fd5b83356137f881613749565b9250602084013561380881613749565b929592945050506040919091013590565b60006020828403121561382b57600080fd5b81356129a081613749565b6000806040838503121561384957600080fd5b50508035926020909101359150565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b838110156138f557888303603f19018552815180516001600160a01b03168452878101511515888501528681015163ffffffff908116888601526060808301519091169085015260809081015160a0918501829052906138e18186018361370a565b96890196945050509086019060010161387f565b509098975050505050505050565b6020808252825182820181905260009190848201906040850190845b818110156139445783516001600160a01b03168352928401929184019160010161391f565b50909695505050505050565b60008083601f84011261396257600080fd5b50813567ffffffffffffffff81111561397a57600080fd5b6020830191508360208260051b8501011115610b4a57600080fd5b6000806000604084860312156139aa57600080fd5b83359250602084013567ffffffffffffffff8111156139c857600080fd5b6139d486828701613950565b9497909650939450505050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613a1a57613a1a6139e1565b60405290565b6040516080810167ffffffffffffffff81118282101715613a1a57613a1a6139e1565b60405160a0810167ffffffffffffffff81118282101715613a1a57613a1a6139e1565b604051601f8201601f1916810167ffffffffffffffff81118282101715613a8f57613a8f6139e1565b604052919050565b600067ffffffffffffffff821115613ab157613ab16139e1565b5060051b60200190565b600067ffffffffffffffff831115613ad557613ad56139e1565b613ae8601f8401601f1916602001613a66565b9050828152838383011115613afc57600080fd5b828260208301376000602084830101529392505050565b600082601f830112613b2457600080fd5b6129a083833560208501613abb565b60006020808385031215613b4657600080fd5b823567ffffffffffffffff80821115613b5e57600080fd5b818501915085601f830112613b7257600080fd5b8135613b85613b8082613a97565b613a66565b81815260059190911b83018401908481019088831115613ba457600080fd5b8585015b83811015613bdc57803585811115613bc05760008081fd5b613bce8b89838a0101613b13565b845250918601918601613ba8565b5098975050505050505050565b60008060408385031215613bfc57600080fd5b8235915067ffffffffffffffff8060208501351115613c1a57600080fd5b6020840135840185601f820112613c3057600080fd5b613c3d613b808235613a97565b81358082526020808301929160051b84010188811115613c5c57600080fd5b602084015b81811015613d9c578581351115613c7757600080fd5b80358501601f196040828d0382011215613c9057600080fd5b613c986139f7565b613ca56020840135613749565b602083013581528860408401351115613cbd57600080fd5b604083013583019250608082848f03011215613cd857600080fd5b613ce0613a20565b91508860208401351115613cf357600080fd5b613d058d602080860135860101613b13565b82528860408401351115613d1857600080fd5b613d2b8d60206040860135860101613b13565b60208301528860608401351115613d4157600080fd5b613d548d60206060860135860101613b13565b60408301528860808401351115613d6a57600080fd5b613d7d8d60206080860135860101613b13565b6060830152602081810192909252865294850194919091019050613c61565b50959890975095505050505050565b8035801515811461094057600080fd5b60008060408385031215613dce57600080fd5b8235613dd981613749565b9150613de760208401613dab565b90509250929050565b60008060008060808587031215613e0657600080fd5b8435613e1181613749565b93506020850135613e2181613749565b925060408501359150606085013567ffffffffffffffff811115613e4457600080fd5b8501601f81018713613e5557600080fd5b613e6487823560208401613abb565b91505092959194509250565b600081518084526020808501945080840160005b838110156137ba5781516001600160a01b031687529582019590820190600101613e84565b6020815260006129a06020830184613e70565b604081526000613ecf6040830185613e70565b8281036020840152613ee1818561378a565b95945050505050565b600060208284031215613efc57600080fd5b6129a082613dab565b600080600060408486031215613f1a57600080fd5b8335613f2581613749565b9250602084013567ffffffffffffffff8111156139c857600080fd5b60008060408385031215613f5457600080fd5b8235613f5f81613749565b91506020830135613f6f81613749565b809150509250929050565b803563ffffffff8116811461094057600080fd5b60006020808385031215613fa157600080fd5b823567ffffffffffffffff80821115613fb957600080fd5b818501915085601f830112613fcd57600080fd5b8135613fdb613b8082613a97565b81815260059190911b83018401908481019088831115613ffa57600080fd5b8585015b83811015613bdc578035858111156140165760008081fd5b860160a0818c03601f190181131561402e5760008081fd5b614036613a43565b8983013561404381613749565b81526040614052848201613dab565b8b8301526060614063818601613f7a565b8284015260809150614076828601613f7a565b9083015291830135918883111561408d5760008081fd5b61409b8e8c85870101613b13565b9082015285525050918601918601613ffe565b60208082526024908201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616040820152633236b4b760e11b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820161413057614130614108565b5060010190565b600081600019048311821515161561415157614151614108565b500290565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b6000826141cc576141cc6141a7565b500490565b600082198211156141e4576141e4614108565b500190565b600181811c908216806141fd57607f821691505b60208210810361421d57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602b908201527f4552433732314d657461646174613a20717565727920666f72206e6f6e65786960408201526a39ba32b73a103a37b5b2b760a91b606082015260800190565b60008282101561428057614280614108565b500390565b600063ffffffff8083168185168083038211156142a4576142a4614108565b01949350505050565b600083516142bf8184602088016136de565b8351908301906142a48183602088016136de565b8054600090600181811c90808316806142ed57607f831692505b6020808410820361430e57634e487b7160e01b600052602260045260246000fd5b81801561432257600181146143335761435f565b60ff1986168952848901965061435f565b876000528160002060005b868110156143575781548b82015290850190830161433e565b505084890196505b50505050505092915050565b6000835161437d8184602088016136de565b613ee1818401856142d3565b600063ffffffff82168061439f5761439f614108565b6000190192915050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000825161440d8184602087016136de565b9190910192915050565b60006129a082846142d3565b600082614432576144326141a7565b500690565b634e487b7160e01b600052603160045260246000fd5b60006001600160a01b0380871683528086166020840152508360408301526080606083015261447f608083018461370a565b9695505050505050565b60006020828403121561449b57600080fd5b81516129a0816136ab56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220801bdc4f936662df5842978e84cc82b85e82b50805cb93e877ace97f2fedd3db64736f6c634300080d0033
Verified Source Code Full Match
Compiler: v0.8.13+commit.abaa5c0e
EVM: london
Optimization: Yes (300 runs)
Metamorphosis.sol 665 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @creator: Pak
/// @author: manifold.xyz
import "@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/Address.sol";
///////////////////////////////////////////////////////////////////////////////////////////////////
// _____ _____ _____ _____ _____ _____ _____ //
// | || | || _ || _ ||_ _|| __|| __ | //
// | --|| || || __| | | | __|| -| //
// |_____||__|__||__|__||__| |_| |_____||__|__| //
// _____ _ _ _ _____ //
// |_ _|| | | || | //
// | | | | | || | | //
// |_| |_____||_____| //
// _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ //
// | || __||_ _|| _ || || || __ || _ || | || || __|| || __| //
// | | | || __| | | | || | | || | || -|| __|| || | ||__ ||- -||__ | //
// |_|_|_||_____| |_| |__|__||_|_|_||_____||__|__||__| |__|__||_____||_____||_____||_____| //
// //
///////////////////////////////////////////////////////////////////////////////////////////////////
contract Metamorphosis is AdminControl, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
struct Creator {
address address_;
bool signed;
uint32 editions;
uint32 total;
string name;
}
struct CreatorNFT {
string name;
string description;
string imageURI;
string animationURI;
}
struct CreatorNFTConfig {
address creator;
CreatorNFT nft;
}
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// URI tags and data
string constant private _NAME_TAG = '<NAME>';
string constant private _DESCRIPTION_TAG = '<DESCRIPTION>';
string constant private _CREATOR_TAG = '<CREATOR>';
string constant private _EDITION_TAG = '<EDITION>';
string constant private _TOTAL_TAG = '<TOTAL>';
string constant private _IMAGE_TAG = '<IMAGE>';
string constant private _ANIMATION_TAG = '<ANIMATION>';
string constant private _FORM_TAG = '<FORM>';
string[] private _uriParts;
bool private _transferLock;
// Token configuration
uint256 public MAX_TOKENS;
uint256 public constant CREATOR_TOKENS = 10;
uint256 public constant CREATOR_MAX_TOKENS = 250;
uint256 public MAX_FORM;
Creator[] private _creators;
// tokenId -> form
mapping(uint256 => uint256) private _tokenForm;
// form -> creatorIndex -> CreatorNFT
mapping(uint256 => mapping(uint256 => CreatorNFT)) private _creatorNFTs;
bool private _activated;
uint256 private _royaltyBps;
address payable private _royaltyRecipient;
bytes4 private constant _INTERFACE_ID_ROYALTIES_CREATORCORE = 0xbb3bafd6;
bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x2a55205a;
bytes4 private constant _INTERFACE_ID_ROYALTIES_RARIBLE = 0xb7799584;
constructor() {
_uriParts = [
'data:application/json;utf8,{"name":"',_NAME_TAG,' #',_EDITION_TAG,'", "description":"',_DESCRIPTION_TAG,
'", "created_by":"',_CREATOR_TAG,'", "image":"',_IMAGE_TAG,'", "animation_url":"',_ANIMATION_TAG,
'", "attributes":[{"trait_type":"Creator","value":"',_CREATOR_TAG,'"},{"trait_type":"Form","value":"',_FORM_TAG,'"}]}'
];
_transferLock = true;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(AdminControl, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == _INTERFACE_ID_ROYALTIES_CREATORCORE ||
interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981 ||
interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public pure virtual override returns (string memory) {
return "Metamorphosis";
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return "MORPH";
}
/**
* View list of all creators
*/
function creators() external view returns(Creator[] memory) {
return _creators;
}
/**
* Set participating creators
*/
function setCreators(Creator[] memory creators_) external adminRequired {
require(!_activated, "Cannot set creators after activation");
delete _creators;
for (uint i; i < creators_.length; i++) {
Creator memory creator = creators_[i];
require(!creator.signed, "signed must be false");
require(creator.editions == 0 && creator.total == 0, "edition and total must be 0");
_creators.push(creator);
}
}
/**
* Update nft configuration
*/
function configureNFTs(uint256 form, CreatorNFTConfig[] memory nftConfigs) external adminRequired {
require(form > 0 && form <= MAX_FORM, "Invalid form");
for (uint i; i < nftConfigs.length; i++) {
CreatorNFTConfig memory nftConfig = nftConfigs[i];
bool found = false;
uint creatorIndex;
for (uint j; j < _creators.length; j++) {
if (_creators[j].address_ == nftConfig.creator) {
found = true;
creatorIndex = j;
break;
}
}
require(found, "Creator does not exist");
_creatorNFTs[form-1][creatorIndex] = nftConfig.nft;
}
}
/**
* Activate
*/
function activate() external adminRequired {
require(!_activated, "Already activated");
for (uint i; i < _creators.length; i++) {
Creator storage creator = _creators[i];
creator.editions = uint32(CREATOR_TOKENS);
creator.total = uint32(CREATOR_TOKENS);
}
MAX_TOKENS = CREATOR_MAX_TOKENS*_creators.length;
_activated = true;
}
/**
* Set the max form
*/
function setMaxForm(uint256 maxForm) external adminRequired {
MAX_FORM = maxForm;
}
function updateTokenURIParts(string[] memory uriParts) external adminRequired {
_uriParts = uriParts;
}
/**
* Sign the collection as an creator. Mints the first NFT to them
*/
function sign() external {
require(_activated, "Not activated");
bool found;
for (uint i; i < _creators.length; i++) {
if (_creators[i].address_ == msg.sender) {
require(!_creators[i].signed, "You have already signed");
found = true;
_creators[i].signed = true;
for (uint j; j < CREATOR_TOKENS; j++) {
uint256 tokenId = i*CREATOR_MAX_TOKENS+j+1;
_mint(msg.sender, msg.sender, tokenId);
}
break;
}
}
require(found, "You are not an creator");
}
/**
* @dev Deliver tokens to holders
*/
function deliver(address creatorAddress, address[] calldata recipients) external adminRequired {
uint256 creatorIndex;
bool found;
for (uint i; i < _creators.length; i++) {
if (_creators[i].address_ == creatorAddress) {
found = true;
creatorIndex = i;
break;
}
}
require(found, "Creator not found");
Creator storage creator = _creators[creatorIndex];
require(creator.editions+recipients.length <= CREATOR_MAX_TOKENS, "Too many requested");
for (uint i; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 tokenId = creatorIndex*CREATOR_MAX_TOKENS+creator.editions+i+1;
_mint(creatorAddress, recipient, tokenId);
}
creator.editions += uint32(recipients.length);
creator.total += uint32(recipients.length);
}
function _mint(address creator, address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_balances[to] += 1;
_owners[tokenId] = to;
if (creator == to) {
emit Transfer(address(0), to, tokenId);
} else {
emit Transfer(address(0), creator, tokenId);
emit Transfer(creator, to, tokenId);
}
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
uint256 creatorIndex = tokenCreatorIndex(tokenId);
CreatorNFT memory creatorNFT = _creatorNFTs[_tokenForm[tokenId]][creatorIndex];
Creator memory creator = _creators[creatorIndex];
bytes memory byteString;
for (uint i; i < _uriParts.length; i++) {
if (_checkTag(_uriParts[i], _NAME_TAG)) {
byteString = abi.encodePacked(byteString, creatorNFT.name);
} else if (_checkTag(_uriParts[i], _DESCRIPTION_TAG)) {
byteString = abi.encodePacked(byteString, creatorNFT.description);
} else if (_checkTag(_uriParts[i], _CREATOR_TAG)) {
byteString = abi.encodePacked(byteString, creator.name);
} else if (_checkTag(_uriParts[i], _IMAGE_TAG)) {
byteString = abi.encodePacked(byteString, creatorNFT.imageURI);
} else if (_checkTag(_uriParts[i], _ANIMATION_TAG)) {
byteString = abi.encodePacked(byteString, creatorNFT.animationURI);
} else if (_checkTag(_uriParts[i], _FORM_TAG)) {
byteString = abi.encodePacked(byteString, (_tokenForm[tokenId]+1).toString());
} else if (_checkTag(_uriParts[i], _EDITION_TAG)) {
byteString = abi.encodePacked(byteString, (tokenId-creatorIndex*CREATOR_MAX_TOKENS).toString());
} else if (_checkTag(_uriParts[i], _TOTAL_TAG)) {
byteString = abi.encodePacked(byteString, uint256(_creators[creatorIndex].total).toString());
} else {
byteString = abi.encodePacked(byteString, _uriParts[i]);
}
}
return string(byteString);
}
function _checkTag(string storage a, string memory b) private pure returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
function setTransferLock(bool lock) public adminRequired {
_transferLock = lock;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
require(!_transferLock, "ERC721: transfer not permitted");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
require(!_transferLock, "ERC721: transfer not permitted");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @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.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
// Transfers to 0xdead are burnt
if (to == address(0xdead)) {
_burn(tokenId);
return;
}
require(ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*
* Requirements:
*
* - The caller must own `tokenId` or be an approved operator.
*/
function burn(uint256 tokenId) public virtual {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
require(!_transferLock, "ERC721: transfer not permitted");
_burn(tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ownerOf(tokenId);
_creators[tokenCreatorIndex(tokenId)].total--;
delete _tokenForm[tokenId];
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* 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 bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* Get token form
*/
function tokenForm(uint256 tokenId) external view returns (uint256) {
require(_exists(tokenId), "ERC721Metadata: query for nonexistent token");
return _tokenForm[tokenId]+1;
}
/**
* Get total count for a given token
*/
function tokenTotalCount(uint256 tokenId) external view returns (uint256) {
require(_exists(tokenId), "ERC721Metadata: query for nonexistent token");
return _creators[tokenCreatorIndex(tokenId)].total;
}
function tokenCreatorIndex(uint256 tokenId) private pure returns (uint256) {
return (tokenId - 1) / CREATOR_MAX_TOKENS;
}
/**
* Morph a token
*/
function morph(uint256 tokenId, uint256[] calldata burnedTokenIds) external {
require(!_transferLock, "Morph not permitted");
require(burnedTokenIds.length == 4, "Insufficient tokens");
address tokenOwner = ownerOf(tokenId);
require(msg.sender == tokenOwner, "Must be token owner");
uint256 currentForm = _tokenForm[tokenId];
require(currentForm+1 < MAX_FORM, "Max form reached");
for (uint i; i < burnedTokenIds.length; i++) {
uint256 burnedTokenId = burnedTokenIds[i];
require(tokenId != burnedTokenId && ownerOf(burnedTokenId) == msg.sender && _tokenForm[burnedTokenId] >= currentForm, "Invalid token to burn");
for (uint j=i+1; j < burnedTokenIds.length; j++) {
require(burnedTokenId != burnedTokenIds[j], "Cannot have duplicate tokens");
}
_burn(burnedTokenId);
}
_tokenForm[tokenId]++;
}
/**
* ROYALTY FUNCTIONS
*/
function updateRoyalties(address payable recipient, uint256 bps) external adminRequired {
_royaltyRecipient = recipient;
_royaltyBps = bps;
}
function getRoyalties(uint256) external view returns (address payable[] memory recipients, uint256[] memory bps) {
if (_royaltyRecipient != address(0x0)) {
recipients = new address payable[](1);
recipients[0] = _royaltyRecipient;
bps = new uint256[](1);
bps[0] = _royaltyBps;
}
return (recipients, bps);
}
function getFeeRecipients(uint256) external view returns (address payable[] memory recipients) {
if (_royaltyRecipient != address(0x0)) {
recipients = new address payable[](1);
recipients[0] = _royaltyRecipient;
}
return recipients;
}
function getFeeBps(uint256) external view returns (uint[] memory bps) {
if (_royaltyRecipient != address(0x0)) {
bps = new uint256[](1);
bps[0] = _royaltyBps;
}
return bps;
}
function royaltyInfo(uint256, uint256 value) external view returns (address, uint256) {
return (_royaltyRecipient, value*_royaltyBps/10000);
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
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;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
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() {
_transferOwnership(_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 {
_transferOwnership(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");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
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;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
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);
}
EnumerableSet.sol 357 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly {
result := store
}
return result;
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
AdminControl.sol 72 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IAdminControl.sol";
abstract contract AdminControl is Ownable, IAdminControl, ERC165 {
using EnumerableSet for EnumerableSet.AddressSet;
// Track registered admins
EnumerableSet.AddressSet private _admins;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IAdminControl).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev Only allows approved admins to call the specified function
*/
modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
/**
* @dev See {IAdminControl-getAdmins}.
*/
function getAdmins() external view override returns (address[] memory admins) {
admins = new address[](_admins.length());
for (uint i = 0; i < _admins.length(); i++) {
admins[i] = _admins.at(i);
}
return admins;
}
/**
* @dev See {IAdminControl-approveAdmin}.
*/
function approveAdmin(address admin) external override onlyOwner {
if (!_admins.contains(admin)) {
emit AdminApproved(admin, msg.sender);
_admins.add(admin);
}
}
/**
* @dev See {IAdminControl-revokeAdmin}.
*/
function revokeAdmin(address admin) external override onlyOwner {
if (_admins.contains(admin)) {
emit AdminRevoked(admin, msg.sender);
_admins.remove(admin);
}
}
/**
* @dev See {IAdminControl-isAdmin}.
*/
function isAdmin(address admin) public override view returns (bool) {
return (owner() == admin || _admins.contains(admin));
}
}
IAdminControl.sol 38 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author: manifold.xyz
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/**
* @dev Interface for admin control
*/
interface IAdminControl is IERC165 {
event AdminApproved(address indexed account, address indexed sender);
event AdminRevoked(address indexed account, address indexed sender);
/**
* @dev gets address of all admins
*/
function getAdmins() external view returns (address[] memory);
/**
* @dev add an admin. Can only be called by contract owner.
*/
function approveAdmin(address admin) external;
/**
* @dev remove an admin. Can only be called by contract owner.
*/
function revokeAdmin(address admin) external;
/**
* @dev checks whether or not given address is an admin
* Returns True if they are
*/
function isAdmin(address admin) external view returns (bool);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
Read Contract
CREATOR_MAX_TOKENS 0xbd227e57 → uint256
CREATOR_TOKENS 0x465bcea1 → uint256
MAX_FORM 0x6f39cf40 → uint256
MAX_TOKENS 0xf47c84c5 → uint256
balanceOf 0x70a08231 → uint256
creators 0x2f2fc416 → tuple[]
getAdmins 0x31ae450b → address[]
getApproved 0x081812fc → address
getFeeBps 0x0ebd4c7f → uint256[]
getFeeRecipients 0xb9c4d9fb → address[]
getRoyalties 0xbb3bafd6 → address[], uint256[]
isAdmin 0x24d7806c → bool
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenForm 0xa7d1ab8c → uint256
tokenTotalCount 0x626b5419 → uint256
tokenURI 0xc87b56dd → string
Write Contract 20 functions
These functions modify contract state and require a wallet transaction to execute.
activate 0x0f15f4c0
No parameters
approve 0x095ea7b3
address to
uint256 tokenId
approveAdmin 0x6d73e669
address admin
burn 0x42966c68
uint256 tokenId
configureNFTs 0x0db479b7
uint256 form
tuple[] nftConfigs
deliver 0xc4ed6e76
address creatorAddress
address[] recipients
morph 0x356e0281
uint256 tokenId
uint256[] burnedTokenIds
renounceOwnership 0x715018a6
No parameters
revokeAdmin 0x2d345670
address admin
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setCreators 0x32eda700
tuple[] creators_
setMaxForm 0x017f776d
uint256 maxForm
setTransferLock 0xbff35618
bool lock
sign 0x2ca15122
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateRoyalties 0x6c2f5acd
address recipient
uint256 bps
updateTokenURIParts 0x3fce3529
string[] uriParts
Recent Transactions
No transactions found for this address