Address Contract Partially Verified
Address
0x26B4C9265f5B5A367BB85C9eF048908A72c4261b
Balance
0 ETH
Nonce
1
Code Size
13957 bytes
Creator
0xe4cf8D59...a872 at tx 0x172b416a...61af45
Indexed Transactions
0
Contract Bytecode
13957 bytes
0x6080604052600436106102515760003560e01c80636c0360eb11610139578063b88d4fde116100b6578063d8e66d601161007a578063d8e66d60146106c4578063e7af95d8146106e4578063e985e9c514610704578063f2fde38b1461074d578063f4f86cc61461076d578063f7c6ae901461078757600080fd5b8063b88d4fde14610631578063be3f4a5b14610651578063c03556a414610664578063c87b56dd14610684578063d4702936146106a457600080fd5b80638fa900c6116100fd5780638fa900c6146105a757806395d89b41146105bc5780639b035d98146105d1578063a22cb465146105f1578063a4f696571461061157600080fd5b80636c0360eb1461051f57806370a0823114610534578063715018a6146105545780638934478b146105695780638da5cb5b1461058957600080fd5b80633ccfd60b116101d257806355f804b31161019657806355f804b31461045f57806356c9d6ee1461047f578063620fb6751461049f5780636352211e146104bf578063658fb22c146104df57806365d9baa7146104ff57600080fd5b80633ccfd60b146103ca57806342842e0e146103df5780634c16a74e146103ff5780634f6ccce71461041f578063504334c21461043f57600080fd5b80630b3e37ef116102195780630b3e37ef1461032757806318160ddd1461035557806323b872dd1461036a5780632eb1985d1461038a5780632f745c59146103aa57600080fd5b806301ffc9a71461025657806306fdde031461028b578063081812fc146102ad57806308ce4b2c146102e5578063095ea7b314610307575b600080fd5b34801561026257600080fd5b50610276610271366004612ff4565b6107a7565b60405190151581526020015b60405180910390f35b34801561029757600080fd5b506102a06107d2565b6040516102829190613322565b3480156102b957600080fd5b506102cd6102c8366004612fdb565b610864565b6040516001600160a01b039091168152602001610282565b3480156102f157600080fd5b50610305610300366004612ce6565b6108f1565b005b34801561031357600080fd5b50610305610322366004612e52565b610955565b34801561033357600080fd5b5061034761034236600461302e565b610a6b565b604051908152602001610282565b34801561036157600080fd5b50600254610347565b34801561037657600080fd5b50610305610385366004612d34565b610b29565b34801561039657600080fd5b506103056103a53660046130c1565b610b5b565b3480156103b657600080fd5b506103476103c5366004612e52565b610dbd565b3480156103d657600080fd5b50610305610e70565b3480156103eb57600080fd5b506103056103fa366004612d34565b610ecd565b34801561040b57600080fd5b506102a061041a366004612ce6565b610ee8565b34801561042b57600080fd5b5061034761043a366004612fdb565b61100d565b34801561044b57600080fd5b5061030561045a366004613141565b61107a565b34801561046b57600080fd5b5061030561047a36600461302e565b6110ae565b34801561048b57600080fd5b5061030561049a366004612f43565b6110eb565b3480156104ab57600080fd5b506102766104ba36600461302e565b611128565b3480156104cb57600080fd5b506102cd6104da366004612fdb565b61120a565b3480156104eb57600080fd5b506103056104fa366004612e7c565b611296565b34801561050b57600080fd5b5061027661051a366004612fdb565b6113d3565b34801561052b57600080fd5b506102a06113fc565b34801561054057600080fd5b5061034761054f366004612ce6565b61148a565b34801561056057600080fd5b50610305611558565b34801561057557600080fd5b506102a0610584366004612fdb565b61158e565b34801561059557600080fd5b506005546001600160a01b03166102cd565b3480156105b357600080fd5b50610305611630565b3480156105c857600080fd5b506102a061166e565b3480156105dd57600080fd5b506102a06105ec366004612e28565b61167d565b3480156105fd57600080fd5b5061030561060c366004612dec565b6116a1565b34801561061d57600080fd5b5061030561062c366004612fdb565b611766565b34801561063d57600080fd5b5061030561064c366004612d70565b6117db565b61030561065f366004613063565b611813565b34801561067057600080fd5b5061027661067f366004612e28565b611afa565b34801561069057600080fd5b506102a061069f366004612fdb565b611c01565b3480156106b057600080fd5b506102a06106bf366004612e52565b611c82565b3480156106d057600080fd5b506103476106df366004612fdb565b611d34565b3480156106f057600080fd5b506103056106ff366004612e28565b611d55565b34801561071057600080fd5b5061027661071f366004612d01565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b34801561075957600080fd5b50610305610768366004612ce6565b611dbc565b34801561077957600080fd5b506009546102769060ff1681565b34801561079357600080fd5b506102cd6107a2366004613141565b611e57565b60006001600160e01b0319821663780e9d6360e01b14806107cc57506107cc82611ff6565b92915050565b6060600080546107e19061355d565b80601f016020809104026020016040519081016040528092919081815260200182805461080d9061355d565b801561085a5780601f1061082f5761010080835404028352916020019161085a565b820191906000526020600020905b81548152906001019060200180831161083d57829003601f168201915b5050505050905090565b600061086f82612046565b6108d55760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600360205260409020546001600160a01b031690565b6001600160a01b03811633146109425760405162461bcd60e51b815260206004820152601660248201527520b2323932b9b99034b9903737ba1031b0b63632b91760511b60448201526064016108cc565b50336000908152600d6020526040812055565b60006109608261120a565b9050806001600160a01b0316836001600160a01b031614156109ce5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108cc565b336001600160a01b03821614806109ea57506109ea813361071f565b610a5c5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108cc565b610a668383612090565b505050565b604051620cae8d60eb1b6020820152600090819060230160405160208183030381529060405280519060200120604051602001610ab2929190918252602082015260400190565b6040516020818303038152906040528051906020012090508082604051602001610adc91906131fc565b60405160208183030381529060405280519060200120604051602001610b0c929190918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b610b34335b826120fe565b610b505760405162461bcd60e51b81526004016108cc90613448565b610a668383836121e8565b610b658282611afa565b610b815760405162461bcd60e51b81526004016108cc90613335565b6001600160a01b0384166000908152600a6020908152604080832061ffff87168452909152902080543391610c3f91889190610bbc9061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054610be89061355d565b8015610c355780601f10610c0a57610100808354040283529160200191610c35565b820191906000526020600020905b815481529060010190602001808311610c1857829003601f168201915b5050505050611e57565b6001600160a01b031614610c8b5760405162461bcd60e51b81526020600482015260136024820152722737ba1037bbb732b210313c9031b0b63632b960691b60448201526064016108cc565b6001600160a01b0382166000908152600a6020908152604080832061ffff8516845290915281208054610cbd9061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054610ce99061355d565b8015610d365780601f10610d0b57610100808354040283529160200191610d36565b820191906000526020600020905b815481529060010190602001808311610d1957829003601f168201915b5050505050905060008682604051602001610d52929190613218565b60405160208183030381529060405290506000610d6e88610a6b565b6000818152600b602052604081205491925090610d8d9060019061351a565b6000818152600c602090815260409091208551929350610db1929091860190612a5a565b50505050505050505050565b6000610dc88361148a565b8210610de65760405162461bcd60e51b81526004016108cc90613376565b6000805b600254811015610e575760028181548110610e0757610e0761360d565b6000918252602090912001546001600160a01b0386811691161415610e455783821415610e375791506107cc9050565b81610e4181613592565b9250505b80610e4f81613592565b915050610dea565b5060405162461bcd60e51b81526004016108cc90613376565b6005546001600160a01b03163314610e9a5760405162461bcd60e51b81526004016108cc90613413565b6040514790339082156108fc029083906000818181858888f19350505050158015610ec9573d6000803e3d6000fd5b5050565b610a66838383604051806020016040528060008152506117db565b6001600160a01b0381166000908152600d602052604090205460609080610f5f5760405162461bcd60e51b815260206004820152602560248201527f5072696d617279204e616d65206e6f742073657420666f7220746865206164646044820152643932b9b99760d91b60648201526084016108cc565b600c6000610f6e60018461351a565b81526020019081526020016000208054610f879061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054610fb39061355d565b80156110005780601f10610fd557610100808354040283529160200191611000565b820191906000526020600020905b815481529060010190602001808311610fe357829003601f168201915b5050505050915050919050565b60025460009082106110765760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108cc565b5090565b6005546001600160a01b031633146110a45760405162461bcd60e51b81526004016108cc90613413565b610ec98282612349565b6005546001600160a01b031633146110d85760405162461bcd60e51b81526004016108cc90613413565b8051610ec9906006906020840190612a5a565b6005546001600160a01b031633146111155760405162461bcd60e51b81526004016108cc90613413565b8051610ec9906008906020840190612ada565b600080829050600f815111156111415750600092915050565b6003815110156111545750600092915050565b60005b81518110156112005760008282815181106111745761117461360d565b01602001516001600160f81b0319169050600360fc1b81108015906111a75750603960f81b6001600160f81b0319821611155b1580156111dd5750606160f81b6001600160f81b03198216108015906111db5750603d60f91b6001600160f81b0319821611155b155b156111ed57506000949350505050565b50806111f881613592565b915050611157565b5060019392505050565b600080600283815481106112205761122061360d565b6000918252602090912001546001600160a01b03169050806107cc5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108cc565b6005546001600160a01b031633146112c05760405162461bcd60e51b81526004016108cc90613413565b80518251146112ce57600080fd5b60005b81518160ff161015610a665760005b828260ff16815181106112f5576112f561360d565b6020026020010151518160ff1610156113c057828260ff168151811061131d5761131d61360d565b60200260200101518160ff16815181106113395761133961360d565b6020026020010151600a6000868560ff168151811061135a5761135a61360d565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008360ff1661ffff16815260200190815260200160002090805190602001906113ad929190612a5a565b50806113b8816135ad565b9150506112e0565b50806113cb816135ad565b9150506112d1565b6000818152600b6020526040812054156113ef57506001919050565b506000919050565b919050565b600680546114099061355d565b80601f01602080910402602001604051908101604052809291908181526020018280546114359061355d565b80156114825780601f1061145757610100808354040283529160200191611482565b820191906000526020600020905b81548152906001019060200180831161146557829003601f168201915b505050505081565b60006001600160a01b0382166114f55760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108cc565b6000805b60025481101561155157600281815481106115165761151661360d565b6000918252602090912001546001600160a01b03858116911614156115415761153e82613592565b91505b61154a81613592565b90506114f9565b5092915050565b6005546001600160a01b031633146115825760405162461bcd60e51b81526004016108cc90613413565b61158c6000612370565b565b6000818152600c602052604090208054606091906115ab9061355d565b80601f01602080910402602001604051908101604052809291908181526020018280546115d79061355d565b80156116245780601f106115f957610100808354040283529160200191611624565b820191906000526020600020905b81548152906001019060200180831161160757829003601f168201915b50505050509050919050565b6005546001600160a01b0316331461165a5760405162461bcd60e51b81526004016108cc90613413565b6009805460ff19811660ff90911615179055565b6060600180546107e19061355d565b600a602090815260009283526040808420909152908252902080546114099061355d565b6001600160a01b0382163314156116fa5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108cc565b3360008181526004602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b336117708261120a565b6001600160a01b0316146117bd5760405162461bcd60e51b81526020600482015260146024820152732737ba1037bbb732b210313c9031b0b63632b91760611b60448201526064016108cc565b6117c88160016134ee565b336000908152600d602052604090205550565b6117e533836120fe565b6118015760405162461bcd60e51b81526004016108cc90613448565b61180d848484846123c2565b50505050565b60095460ff166118655760405162461bcd60e51b815260206004820152601c60248201527f526567697374726174696f6e206d757374206265206163746976652e0000000060448201526064016108cc565b6000611870846123f5565b9050348111156118c25760405162461bcd60e51b815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f72726563740060448201526064016108cc565b6118cb84611128565b6119235760405162461bcd60e51b815260206004820152602360248201527f4e616d6520636f6e7461696e7320666f7262696464656e20636861726163746560448201526239399760e91b60648201526084016108cc565b6005546001600160a01b031633148061194157506119418383611afa565b61195d5760405162461bcd60e51b81526004016108cc90613335565b600061196885610a6b565b9050611973816113d3565b156119b75760405162461bcd60e51b81526020600482015260146024820152732730b6b29030b63932b0b23c9032bc34b9ba399760611b60448201526064016108cc565b6001600160a01b0384166000908152600a6020908152604080832061ffff87168452909152812080546119e99061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054611a159061355d565b8015611a625780601f10611a3757610100808354040283529160200191611a62565b820191906000526020600020905b815481529060010190602001808311611a4557829003601f168201915b5050505050905060008682604051602001611a7e929190613218565b6040516020818303038152906040529050611a9b33600754612481565b600754611aa99060016134ee565b6000848152600b60209081526040808320939093556007548252600c81529190208251611ad892840190612a5a565b50600160076000828254611aec91906134ee565b909155505050505050505050565b6000611b06838361249b565b611b525760405162461bcd60e51b815260206004820181905260248201527f5468697320636f6c6c656374696f6e206973206e6f7420656c696769626c652e60448201526064016108cc565b6001600160a01b038316301415611b6b575060016107cc565b6040516370a0823160e01b815233600482015283906000906001600160a01b038316906370a082319060240160206040518083038186803b158015611baf57600080fd5b505afa158015611bc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611be7919061319b565b1115611bf75760019150506107cc565b60009150506107cc565b6060611c0c82612046565b611c505760405162461bcd60e51b81526020600482015260156024820152742a37b5b2b7103237b2b9903737ba1032bc34b9ba1760591b60448201526064016108cc565b6006611c5b83612575565b604051602001611c6c929190613247565b6040516020818303038152906040529050919050565b60606000611c908484610dbd565b6000818152600c60205260409020805491925090611cad9061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054611cd99061355d565b8015611d265780601f10611cfb57610100808354040283529160200191611d26565b820191906000526020600020905b815481529060010190602001808311611d0957829003601f168201915b505050505091505092915050565b60088181548110611d4457600080fd5b600091825260209091200154905081565b6005546001600160a01b03163314611d7f5760405162461bcd60e51b81526004016108cc90613413565b60408051602080820180845260008084526001600160a01b0387168152600a835284812061ffff871682529092529290209051610a669290612a5a565b6005546001600160a01b03163314611de65760405162461bcd60e51b81526004016108cc90613413565b6001600160a01b038116611e4b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108cc565b611e5481612370565b50565b600080611e6384610a6b565b6000818152600b602052604081205491925090611e829060019061351a565b9050611e8d81612046565b611ed95760405162461bcd60e51b815260206004820152601b60248201527f4e616d65206973206e6f742072656769737465726564207965742e000000000060448201526064016108cc565b611f988585604051602001611eef929190613218565b60408051601f198184030181529181526000848152600c602052208054611f159061355d565b80601f0160208091040260200160405190810160405280929190818152602001828054611f419061355d565b8015611f8e5780601f10611f6357610100808354040283529160200191611f8e565b820191906000526020600020905b815481529060010190602001808311611f7157829003601f168201915b5050505050612673565b611fe45760405162461bcd60e51b815260206004820152601c60248201527f4e616d65206973206e6f74206f776e656420627920616e796f6e652e0000000060448201526064016108cc565b611fed8161120a565b95945050505050565b60006001600160e01b031982166380ac58cd60e01b148061202757506001600160e01b03198216635b5e139f60e01b145b806107cc57506301ffc9a760e01b6001600160e01b03198316146107cc565b600254600090821080156107cc575060006001600160a01b0316600283815481106120735761207361360d565b6000918252602090912001546001600160a01b0316141592915050565b600081815260036020526040902080546001600160a01b0319166001600160a01b03841690811790915581906120c58261120a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061210982612046565b61216a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108cc565b60006121758361120a565b9050806001600160a01b0316846001600160a01b031614806121b05750836001600160a01b03166121a584610864565b6001600160a01b0316145b806121e057506001600160a01b0380821660009081526004602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b03166121fb8261120a565b6001600160a01b0316146122635760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108cc565b6001600160a01b0382166122c55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108cc565b6122d083838361269b565b6122db600082612090565b81600282815481106122ef576122ef61360d565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b815161235c906000906020850190612a5a565b508051610a66906001906020840190612a5a565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6123cd8484846121e8565b6123d9848484846126b3565b61180d5760405162461bcd60e51b81526004016108cc906133c1565b805160009082906003141561242b5760086000815481106124185761241861360d565b9060005260206000200154915050919050565b8051600414156124495760086001815481106124185761241861360d565b8051600514156124675760086002815481106124185761241861360d565b60086003815481106124185761241861360d565b50919050565b610ec98282604051806020016040528060008152506127c0565b6001600160a01b0382166000908152600a6020908152604080832061ffff85168452909152812080548291906124d09061355d565b80601f01602080910402602001604051908101604052809291908181526020018280546124fc9061355d565b80156125495780601f1061251e57610100808354040283529160200191612549565b820191906000526020600020905b81548152906001019060200180831161252c57829003601f168201915b50505050509050600081905080516000141561256a576000925050506107cc565b6001925050506107cc565b6060816125995750506040805180820190915260018152600360fc1b602082015290565b8160005b81156125c357806125ad81613592565b91506125bc9050600a83613506565b915061259d565b60008167ffffffffffffffff8111156125de576125de613623565b6040519080825280601f01601f191660200182016040528015612608576020820181803683370190505b5090505b84156121e05761261d60018361351a565b915061262a600a866135cd565b6126359060306134ee565b60f81b81838151811061264a5761264a61360d565b60200101906001600160f81b031916908160001a90535061266c600a86613506565b945061260c565b6000818051906020012083805190602001201415612693575060016107cc565b5060006107cc565b6126a481612046565b15610a6657610a6683826127f3565b60006001600160a01b0384163b156127b557604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906126f79033908990889088906004016132e5565b602060405180830381600087803b15801561271157600080fd5b505af1925050508015612741575060408051601f3d908101601f1916820190925261273e91810190613011565b60015b61279b573d80801561276f576040519150601f19603f3d011682016040523d82523d6000602084013e612774565b606091505b5080516127935760405162461bcd60e51b81526004016108cc906133c1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506121e0565b506001949350505050565b6127ca8383612926565b6127d760008484846126b3565b610a665760405162461bcd60e51b81526004016108cc906133c1565b6127fc33610b2e565b6128525760405162461bcd60e51b815260206004820152602160248201527f43616c6c6572206973206e6f74206f776e6572206e6f7220617070726f7665646044820152601760f91b60648201526084016108cc565b816001600160a01b03166128658261120a565b6001600160a01b0316146128bb5760405162461bcd60e51b815260206004820152601760248201527f4164647265737320646f6573206e6f74206d617463682e00000000000000000060448201526064016108cc565b6001600160a01b0382166000908152600d60205260409020541580159061290657506001600160a01b0382166000908152600d602052604090205481906129049060019061351a565b145b15610ec957506001600160a01b03166000908152600d6020526040812055565b6001600160a01b03821661297c5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108cc565b61298581612046565b156129d25760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108cc565b6129de6000838361269b565b6002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0385169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b828054612a669061355d565b90600052602060002090601f016020900481019282612a885760008555612ace565b82601f10612aa157805160ff1916838001178555612ace565b82800160010185558215612ace579182015b82811115612ace578251825591602001919060010190612ab3565b50611076929150612b14565b828054828255906000526020600020908101928215612ace5791602002820182811115612ace578251825591602001919060010190612ab3565b5b808211156110765760008155600101612b15565b600067ffffffffffffffff831115612b4357612b43613623565b612b56601f8401601f1916602001613499565b9050828152838383011115612b6a57600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146113f757600080fd5b600082601f830112612ba957600080fd5b8135612bbc612bb7826134ca565b613499565b80828252602082019150602085018660208560051b8801011115612bdf57600080fd5b60005b84811015612ca15767ffffffffffffffff8083351115612c0157600080fd5b8235880189603f820112612c1457600080fd5b6020810135612c25612bb7826134ca565b80828252602082019150604084018d60408560051b8701011115612c4857600080fd5b60005b84811015612c86578682351115612c6157600080fd5b612c718f60408435890101612cad565b84526020938401939190910190600101612c4b565b50508852505060209586019593909301925050600101612be2565b50909695505050505050565b600082601f830112612cbe57600080fd5b612ccd83833560208501612b29565b9392505050565b803561ffff811681146113f757600080fd5b600060208284031215612cf857600080fd5b612ccd82612b81565b60008060408385031215612d1457600080fd5b612d1d83612b81565b9150612d2b60208401612b81565b90509250929050565b600080600060608486031215612d4957600080fd5b612d5284612b81565b9250612d6060208501612b81565b9150604084013590509250925092565b60008060008060808587031215612d8657600080fd5b612d8f85612b81565b9350612d9d60208601612b81565b925060408501359150606085013567ffffffffffffffff811115612dc057600080fd5b8501601f81018713612dd157600080fd5b612de087823560208401612b29565b91505092959194509250565b60008060408385031215612dff57600080fd5b612e0883612b81565b915060208301358015158114612e1d57600080fd5b809150509250929050565b60008060408385031215612e3b57600080fd5b612e4483612b81565b9150612d2b60208401612cd4565b60008060408385031215612e6557600080fd5b612e6e83612b81565b946020939093013593505050565b60008060408385031215612e8f57600080fd5b823567ffffffffffffffff80821115612ea757600080fd5b818501915085601f830112612ebb57600080fd5b81356020612ecb612bb7836134ca565b8083825282820191508286018a848660051b8901011115612eeb57600080fd5b600096505b84871015612f1557612f0181612b81565b835260019690960195918301918301612ef0565b5096505086013592505080821115612f2c57600080fd5b50612f3985828601612b98565b9150509250929050565b60006020808385031215612f5657600080fd5b823567ffffffffffffffff811115612f6d57600080fd5b8301601f81018513612f7e57600080fd5b8035612f8c612bb7826134ca565b80828252848201915084840188868560051b8701011115612fac57600080fd5b600094505b83851015612fcf578035835260019490940193918501918501612fb1565b50979650505050505050565b600060208284031215612fed57600080fd5b5035919050565b60006020828403121561300657600080fd5b8135612ccd81613639565b60006020828403121561302357600080fd5b8151612ccd81613639565b60006020828403121561304057600080fd5b813567ffffffffffffffff81111561305757600080fd5b6121e084828501612cad565b60008060006060848603121561307857600080fd5b833567ffffffffffffffff81111561308f57600080fd5b61309b86828701612cad565b9350506130aa60208501612b81565b91506130b860408501612cd4565b90509250925092565b600080600080600060a086880312156130d957600080fd5b853567ffffffffffffffff8111156130f057600080fd5b6130fc88828901612cad565b95505061310b60208701612b81565b935061311960408701612cd4565b925061312760608701612b81565b915061313560808701612cd4565b90509295509295909350565b6000806040838503121561315457600080fd5b823567ffffffffffffffff8082111561316c57600080fd5b61317886838701612cad565b9350602085013591508082111561318e57600080fd5b50612f3985828601612cad565b6000602082840312156131ad57600080fd5b5051919050565b600081518084526131cc816020860160208601613531565b601f01601f19169290920160200192915050565b600081516131f2818560208601613531565b9290920192915050565b6000825161320e818460208701613531565b9190910192915050565b6000835161322a818460208801613531565b83519083019061323e818360208801613531565b01949350505050565b600080845481600182811c91508083168061326357607f831692505b602080841082141561328357634e487b7160e01b86526022600452602486fd5b81801561329757600181146132a8576132d5565b60ff198616895284890196506132d5565b60008b81526020902060005b868110156132cd5781548b8201529085019083016132b4565b505084890196505b505050505050611fed81856131e0565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613318908301846131b4565b9695505050505050565b602081526000612ccd60208301846131b4565b60208082526021908201527f4e6f7420656c696769626c6520666f72207468697320636f6c6c656374696f6e6040820152601760f91b606082015260800190565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b604051601f8201601f1916810167ffffffffffffffff811182821017156134c2576134c2613623565b604052919050565b600067ffffffffffffffff8211156134e4576134e4613623565b5060051b60200190565b60008219821115613501576135016135e1565b500190565b600082613515576135156135f7565b500490565b60008282101561352c5761352c6135e1565b500390565b60005b8381101561354c578181015183820152602001613534565b8381111561180d5750506000910152565b600181811c9082168061357157607f821691505b6020821081141561247b57634e487b7160e01b600052602260045260246000fd5b60006000198214156135a6576135a66135e1565b5060010190565b600060ff821660ff8114156135c4576135c46135e1565b60010192915050565b6000826135dc576135dc6135f7565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114611e5457600080fdfea2646970667358221220da095bc0dc05dbd1e2ef5d994f3cce4c20d8f0b4f0308f31186f1eae4416615564736f6c63430008070033
Verified Source Code Partial Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (200 runs)
test.sol 1177 lines
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);
}
pragma solidity ^0.8.6;
library Address {
function isContract(address account) internal view returns (bool) {
uint size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
}
// OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
}
// OpenZeppelin Contracts v4.4.0 (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);
}
}
// OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
// OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
// OpenZeppelin Contracts v4.4.0 (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);
}
// OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
// OpenZeppelin Contracts v4.4.0 (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;
}
}
pragma solidity ^0.8.7;
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
// Mapping from token ID to owner address
address[] internal _owners;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner)
public
view
virtual
override
returns (uint)
{
require(owner != address(0), "ERC721: balance query for the zero address");
uint count;
for( uint i; i < _owners.length; ++i ){
if( owner == _owners[i] )
++count;
}
return count;
}
/**
* @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 view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function _setNameSymbol(string memory name_, string memory symbol_) internal {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.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
{
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_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"
);
_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"
);
_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 tokenId < _owners.length && _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 = ERC721.ownerOf(tokenId);
return (spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_owners.push(to);
emit Transfer(address(0), to, 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 = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_owners[tokenId] = address(0);
emit Transfer(owner, address(0), tokenId);
}
/**
* @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 {
require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer of token that is not own"
);
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_owners[tokenId] = to;
emit Transfer(from, to, 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(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @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;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
pragma solidity ^0.8.7;
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account but rips out the core of the gas-wasting processing that comes from OpenZeppelin.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _owners.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < _owners.length, "ERC721Enumerable: global index out of bounds");
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256 tokenId) {
require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
uint count;
for(uint i; i < _owners.length; i++){
if(owner == _owners[i]){
if(count == index) return i;
else count++;
}
}
revert("ERC721Enumerable: owner index out of bounds");
}
}
// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
}
pragma solidity 0.8.7;
contract Computation {
function _computeNamehash(string memory _name) public pure returns (bytes32 namehash) {
namehash = 0x0000000000000000000000000000000000000000000000000000000000000000;
namehash = keccak256(
abi.encodePacked(namehash, keccak256(abi.encodePacked('eth')))
);
namehash = keccak256(
abi.encodePacked(namehash, keccak256(abi.encodePacked(_name)))
);
}
function _checkASCII(string memory str) public pure returns (bool){
bytes memory b = bytes(str);
if(b.length > 15) return false;
if(b.length < 3) return false;
for(uint i; i<b.length; i++){
bytes1 char = b[i];
if(
!(char >= 0x30 && char <= 0x39) && //9-0
!(char >= 0x61 && char <= 0x7A) //a-z
)
return false;
}
return true;
}
function _checkIfSameStrings(string memory a, string memory b) internal pure returns (bool) {
if (keccak256(bytes(a)) == keccak256(bytes(b))) {
return true;
} else {
return false;
}
}
}
pragma solidity 0.8.7;
abstract contract URI is ERC721Enumerable, Ownable {
string public baseURI;
function setBaseURI(string memory _baseURI) public onlyOwner {
baseURI = _baseURI;
}
function tokenURI(uint256 _tokenId) public view override returns (string memory) {
require(_exists(_tokenId), "Token does not exist.");
return string(abi.encodePacked(baseURI, Strings.toString(_tokenId)));
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
contract test is ERC721Enumerable, Ownable, Computation, URI {
uint256 nextTokenID;
uint256[] public registrationCost;
bool public registrationIsActive = true;
//Collections mapping
mapping(address => mapping(uint16 => string)) public _addressToCollections;
//Names mapping
mapping(bytes32 => uint256) private _nameHashToToken;
mapping(uint256 => string) private _tokenToName;
//Primary names mapping
mapping(address => uint256) private _addressToTokenPrimary;
constructor(string memory name_, string memory symbol_, string memory _baseURI, uint256 _nextTokenID, uint256[] memory _cost, string memory _firstCollection) ERC721(name_, symbol_) {
baseURI = _baseURI;
nextTokenID = _nextTokenID;
registrationCost = _cost;
_addressToCollections[address(this)][0] = _firstCollection;
}
function registerName(string memory _name, address collection, uint16 collectionIndex) public payable {
require(registrationIsActive, "Registration must be active.");
uint256 _cost = _calculateRegistrationCost(_name);
require(_cost <= msg.value, "Ether value sent is not correct");
require(_checkASCII(_name), "Name contains forbidden characters.");
require(msg.sender == owner() || _checkEligibility(collection, collectionIndex), "Not eligible for this collection.");
bytes32 hash = _computeNamehash(_name);
require(_exists(hash) == false, "Name already exists.");
string memory _extension = _addressToCollections[collection][collectionIndex];
string memory _finalName = string(abi.encodePacked(_name, _extension));
_safeMint(msg.sender, nextTokenID);
_nameHashToToken[hash] = nextTokenID + 1;
_tokenToName[nextTokenID] = _finalName;
nextTokenID += 1;
}
function nameByTokenID(uint256 _tokenID) public view returns (string memory) {
return _tokenToName[_tokenID];
}
function namesOfOwnerByIndex(address _owner, uint256 _index) public view returns (string memory) {
uint256 _tokenID = tokenOfOwnerByIndex(_owner, _index);
return _tokenToName[_tokenID];
}
function ownerOfName(string memory _name, string memory _extension) public view returns (address) {
bytes32 hash = _computeNamehash(_name);
uint256 tokenID = _nameHashToToken[hash] - 1;
require(_exists(tokenID), "Name is not registered yet.");
require(_checkIfSameStrings(string(abi.encodePacked(_name, _extension)), _tokenToName[tokenID]), "Name is not owned by anyone.");
return ownerOf(tokenID);
}
function migrateExtension(string memory _name, address _oldCollection, uint16 _oldCollectionIndex, address _newCollection, uint16 _newCollectionIndex) public {
require(_checkEligibility(_newCollection, _newCollectionIndex), "Not eligible for this collection.");
require(ownerOfName(_name, _addressToCollections[_oldCollection][_oldCollectionIndex]) == msg.sender, "Not owned by caller");
string memory _newExtension = _addressToCollections[_newCollection][_newCollectionIndex];
string memory _newFinalName = string(abi.encodePacked(_name, _newExtension));
bytes32 hash = _computeNamehash(_name);
uint256 tokenID = _nameHashToToken[hash] - 1;
_tokenToName[tokenID] = _newFinalName;
}
function setPrimaryName(uint256 _tokenID) public {
require(ownerOf(_tokenID) == msg.sender, "Not owned by caller.");
_addressToTokenPrimary[msg.sender] = _tokenID + 1;
}
function getPrimaryName(address _address) public view returns (string memory) {
uint256 _tokenID = _addressToTokenPrimary[_address];
require(_tokenID != 0, "Primary Name not set for the address.");
return _tokenToName[_tokenID - 1];
}
function removePrimaryName(address _address) public {
require(_address == msg.sender, "Address is not caller.");
_addressToTokenPrimary[msg.sender] = 0;
}
function _removePrimaryName(address _address, uint256 _tokenID) internal {
require(_isApprovedOrOwner(_msgSender(), _tokenID), "Caller is not owner nor approved.");
require(ownerOf(_tokenID) == _address, "Address does not match.");
if (_addressToTokenPrimary[_address] != 0 && _addressToTokenPrimary[_address] - 1 == _tokenID) {
_addressToTokenPrimary[_address] = 0;
}
}
function _checkEligibility(address collection, uint16 collectionIndex) public view returns (bool) {
require(_collectionExists(collection, collectionIndex), "This collection is not eligible.");
if(collection == address(this)) {
return true;
} else {
ERC721 nftcontract = ERC721(collection);
if (nftcontract.balanceOf(msg.sender) > 0) {
return true;
} else {
return false;
}
}
}
function _collectionExists(address collection, uint16 collectionIndex) internal view returns(bool) {
string memory _extension = _addressToCollections[collection][collectionIndex];
bytes memory _bytesExtension = bytes(_extension); // Uses memory
if (_bytesExtension.length == 0) {
return false;
} else {
return true;
}
}
function addCollections(address[] memory addresses, string[][] memory domains) public onlyOwner {
require(addresses.length == domains.length);
for(uint8 i=0; i<domains.length;i++) {
for(uint8 j=0; j<domains[i].length; j++) {
_addressToCollections[addresses[i]][j] = domains[i][j];
}
}
}
function removeCollection(address _collectionAddress, uint16 _collectionIndex) public onlyOwner {
_addressToCollections[_collectionAddress][_collectionIndex] = "";
}
function _exists(bytes32 _hash) public view virtual returns (bool) {
if(_nameHashToToken[_hash] != 0) {
return true;
} else {
return false;
}
}
function _calculateRegistrationCost(string memory _name) internal view returns (uint256) {
bytes memory b = bytes(_name);
if(b.length == 3) return registrationCost[0];
else if(b.length == 4) return registrationCost[1];
else if(b.length == 5) return registrationCost[2];
else return registrationCost[3];
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
if(_exists(tokenId)) {
_removePrimaryName(from, tokenId);
}
}
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function setRegistrationCost(uint256[] memory _cost) public onlyOwner {
registrationCost = _cost;
}
function flipRegistrationState() public onlyOwner {
registrationIsActive = !registrationIsActive;
}
function setNameSymbol(string memory name_, string memory symbol_) public onlyOwner {
_setNameSymbol(name_, symbol_);
}
}
Read Contract
_addressToCollections 0x9b035d98 → string
_checkASCII 0x620fb675 → bool
_checkEligibility 0xc03556a4 → bool
_computeNamehash 0x0b3e37ef → bytes32
_exists 0x65d9baa7 → bool
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
getApproved 0x081812fc → address
getPrimaryName 0x4c16a74e → string
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
nameByTokenID 0x8934478b → string
namesOfOwnerByIndex 0xd4702936 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
ownerOfName 0xf7c6ae90 → address
registrationCost 0xd8e66d60 → uint256
registrationIsActive 0xf4f86cc6 → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
addCollections 0x658fb22c
address[] addresses
string[][] domains
approve 0x095ea7b3
address to
uint256 tokenId
flipRegistrationState 0x8fa900c6
No parameters
migrateExtension 0x2eb1985d
string _name
address _oldCollection
uint16 _oldCollectionIndex
address _newCollection
uint16 _newCollectionIndex
registerName 0xbe3f4a5b
string _name
address collection
uint16 collectionIndex
removeCollection 0xe7af95d8
address _collectionAddress
uint16 _collectionIndex
removePrimaryName 0x08ce4b2c
address _address
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _baseURI
setNameSymbol 0x504334c2
string name_
string symbol_
setPrimaryName 0xa4f69657
uint256 _tokenID
setRegistrationCost 0x56c9d6ee
uint256[] _cost
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address