Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x64C612acBDc537230f1B00DA99356c736aFfA7bE
Balance 0 ETH
Nonce 1
Code Size 24383 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

24383 bytes
0x60806040526004361061026b5760003560e01c806366fe08a411610144578063b64b21ca116100b6578063cec10b801161007a578063cec10b80146107e5578063dbceb005146107f8578063e657e7231461080b578063e985e9c51461082b578063f1a311a914610874578063f2fde38b1461089457600080fd5b8063b64b21ca146106a3578063b88d4fde146106c3578063b9599aa1146106e3578063c87b56dd1461072b578063cc33c8751461074b57600080fd5b80637f649783116101085780637f6497831461060a578063894cfe691461062a5780638da5cb5b1461063d5780638f2239f81461065b57806395d89b411461066e578063a22cb4651461068357600080fd5b806366fe08a4146105715780636817c76c146105aa5780636c0360eb146105c057806370a08231146105d5578063715018a6146105f557600080fd5b80633ccfd60b116101dd5780634f6ccce7116101a15780634f6ccce7146104a05780634fddc979146104c0578063528bc6db146104ec5780635ecf091f1461051c57806360a02e1d146105315780636352211e1461055157600080fd5b80633ccfd60b1461040b5780633dae1a3a1461041357806342842e0e14610433578063438b63001461045357806344a0d68a1461048057600080fd5b806317ea01e91161022f57806317ea01e91461036357806318160ddd14610383578063234c0ae51461039857806323b872dd146103ab5780632f745c59146103cb578063338e8d88146103eb57600080fd5b806301ffc9a71461027757806306fdde03146102ac578063073f0116146102ce578063081812fc14610309578063095ea7b31461034157600080fd5b3661027257005b600080fd5b34801561028357600080fd5b50610297610292366004614ea3565b6108b4565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102c16108df565b6040516102a39190615a77565b3480156102da57600080fd5b506102fb6102e9366004614afb565b60146020526000908152604090205481565b6040519081526020016102a3565b34801561031557600080fd5b50610329610324366004615063565b610971565b6040516001600160a01b0390911681526020016102a3565b34801561034d57600080fd5b5061036161035c366004614c2a565b6109fe565b005b34801561036f57600080fd5b5061036161037e366004615097565b610b14565b34801561038f57600080fd5b506008546102fb565b6103616103a6366004614e35565b610b9d565b3480156103b757600080fd5b506103616103c6366004614b49565b6112ad565b3480156103d757600080fd5b506102fb6103e6366004614c2a565b6112de565b3480156103f757600080fd5b506103616104063660046150c1565b611374565b6103616113b4565b34801561041f57600080fd5b5061036161042e36600461507c565b611404565b34801561043f57600080fd5b5061036161044e366004614b49565b611455565b34801561045f57600080fd5b5061047361046e366004614afb565b611470565b6040516102a391906159f8565b34801561048c57600080fd5b5061036161049b366004615063565b611511565b3480156104ac57600080fd5b506102fb6104bb366004615063565b611540565b3480156104cc57600080fd5b506013546104da9060ff1681565b60405160ff90911681526020016102a3565b3480156104f857600080fd5b5061050c610507366004614e79565b6115d3565b6040516102a39493929190615a3c565b34801561052857600080fd5b506102c1611696565b34801561053d57600080fd5b5061036161054c36600461507c565b611724565b34801561055d57600080fd5b5061032961056c366004615063565b61176a565b34801561057d57600080fd5b5061059161058c366004614edd565b6117e1565b6040516001600160f81b031990911681526020016102a3565b3480156105b657600080fd5b506102fb60115481565b3480156105cc57600080fd5b506102c16117fe565b3480156105e157600080fd5b506102fb6105f0366004614afb565b61180b565b34801561060157600080fd5b50610361611892565b34801561061657600080fd5b50610361610625366004614c54565b6118c6565b610361610638366004615063565b61196a565b34801561064957600080fd5b50600a546001600160a01b0316610329565b610361610669366004614dba565b611d6d565b34801561067a57600080fd5b506102c16127d1565b34801561068f57600080fd5b5061036161069e366004614c00565b6127e0565b3480156106af57600080fd5b506103616106be366004614f87565b6127eb565b3480156106cf57600080fd5b506103616106de366004614b85565b612841565b3480156106ef57600080fd5b506107166106fe366004614e79565b60106020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016102a3565b34801561073757600080fd5b506102c1610746366004615063565b612879565b34801561075757600080fd5b506107a7610766366004615063565b60156020526000908152604090205460f881901b9063ffffffff6101008204811691600160281b8104821691600160481b8204811691600160681b90041685565b604080516001600160f81b0319909616865263ffffffff9485166020870152928416928501929092528216606084015216608082015260a0016102a3565b6103616107f3366004614cf2565b6129eb565b610361610806366004615063565b612f30565b34801561081757600080fd5b50610361610826366004614fcb565b61319d565b34801561083757600080fd5b50610297610846366004614b16565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b34801561088057600080fd5b5061036161088f366004614fcb565b6133a9565b3480156108a057600080fd5b506103616108af366004614afb565b6135fc565b60006001600160e01b0319821663780e9d6360e01b14806108d957506108d982613697565b92915050565b6060600080546108ee90615e1b565b80601f016020809104026020016040519081016040528092919081815260200182805461091a90615e1b565b80156109675780601f1061093c57610100808354040283529160200191610967565b820191906000526020600020905b81548152906001019060200180831161094a57829003601f168201915b5050505050905090565b600061097c826136e7565b6109e25760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b6000610a098261176a565b9050806001600160a01b0316836001600160a01b03161415610a775760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016109d9565b336001600160a01b0382161480610a935750610a938133610846565b610b055760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016109d9565b610b0f8383613704565b505050565b600a546001600160a01b03163314610b3e5760405162461bcd60e51b81526004016109d990615b07565b63ffffffff821615610b6e57600f80546bffffffff00000000000000001916600160401b63ffffffff8516021790555b63ffffffff811615610b9957600f805463ffffffff60601b1916600160601b63ffffffff8416021790555b5050565b6001825111610bee5760405162461bcd60e51b815260206004820152601b60248201527f61746c65617374203220656c656d656e7473207265717569726564000000000060448201526064016109d9565b600a82511115610c4c5760405162461bcd60e51b815260206004820152602360248201527f63616e277420636f6d62696e65206d6f7265207468616e20313020656c656d656044820152626e747360e81b60648201526084016109d9565b610c568282613772565b15610c975760405162461bcd60e51b81526020600482015260116024820152706475706c69636174657320746f6b656e7360781b60448201526064016109d9565b8015610d4057610ca6816136e7565b610ce95760405162461bcd60e51b8152602060048201526014602482015273189d5c9b881d1bdad95b881b9bdd08195e1a5cdd60621b60448201526064016109d9565b33610cf38261176a565b6001600160a01b031614610d405760405162461bcd60e51b8152602060048201526014602482015273189d5c9b881d1bdad95b881b9bdd081bdddb995960621b60448201526064016109d9565b60006015600084600081518110610d5957610d59615ec7565b602090810291909101810151825281019190915260400160009081205460f81b9150808080805b8751811015610fc757610dab888281518110610d9e57610d9e615ec7565b60200260200101516136e7565b610de95760405162461bcd60e51b815260206004820152600f60248201526e1d1bdad95b881b9bdd08195e1a5cdd608a1b60448201526064016109d9565b336001600160a01b0316610e15898381518110610e0857610e08615ec7565b602002602001015161176a565b6001600160a01b031614610e5d5760405162461bcd60e51b815260206004820152600f60248201526e1d1bdad95b881b9bdd081bdddb9959608a1b60448201526064016109d9565b6000601560008a8481518110610e7557610e75615ec7565b6020908102919091018101518252818101929092526040908101600020815160a08101835290546001600160f81b031960f882901b811680845263ffffffff6101008404811696850196909652600160281b8304861694840194909452600160481b820485166060840152600160681b9091049093166080820152925090881614610f425760405162461bcd60e51b815260206004820152601a60248201527f616c6c2073686f756c642062652073616d6520656c656d656e7400000000000060448201526064016109d9565b6020810151610f519087615cd2565b955080602001518160600151610f679190615d50565b610f719086615cd2565b945080602001518160400151610f879190615d50565b610f919085615cd2565b935080602001518160800151610fa79190615d50565b610fb19084615cd2565b9250508080610fbf90615e56565b915050610d80565b50610fd28484615d0e565b610fdd906001615cd2565b9250610fe98483615d0e565b9150610ff58482615d0e565b905085156110df57600086815260156020526040902054600161010090910463ffffffff161115611094576000868152601560205260409020805460019190829061104c908290610100900463ffffffff16615d93565b825463ffffffff9182166101009390930a92830291909202199091161790555060008681526015602052604081205461108f9160f89190911b9060018181613843565b6110bd565b6000868152601560205260409020546110b49060f81b6001808080613843565b6110bd86613aa1565b6110da85600189516110cf9190615d7c565b600060016000613843565b61115f565b6110ea600185615d93565b935060018463ffffffff1611156111435760405162461bcd60e51b815260206004820152601c60248201527f616464206d6f726520656c656d656e747320746f20636f6d62696e650000000060448201526064016109d9565b61115f85600189516111559190615d7c565b6001806001613843565b60015b875181101561119f5761118d88828151811061118057611180615ec7565b6020026020010151613aa1565b8061119781615e56565b915050611162565b506040518060a00160405280866001600160f81b03191681526020018563ffffffff1681526020018363ffffffff1681526020018463ffffffff1681526020018263ffffffff16815250601560008960008151811061120057611200615ec7565b6020908102919091018101518252818101929092526040908101600020835181549385015192850151606086015160809096015160f89290921c64ffffffffff199095169490941761010063ffffffff948516021767ffffffffffffffff60281b1916600160281b9484169490940263ffffffff60481b191693909317600160481b948316949094029390931763ffffffff60681b1916600160681b919092160217905550505050505050565b6112b73382613ad0565b6112d35760405162461bcd60e51b81526004016109d990615b3c565b610b0f838383613bba565b60006112e98361180b565b821061134b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016109d9565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b0316331461139e5760405162461bcd60e51b81526004016109d990615b07565b6013805460ff191660ff92909216919091179055565b600a546001600160a01b031633146113de5760405162461bcd60e51b81526004016109d990615b07565b60405133904780156108fc02916000818181858888f1935050505061140257600080fd5b565b600a546001600160a01b0316331461142e5760405162461bcd60e51b81526004016109d990615b07565b600f805463ffffffff909216600160201b0267ffffffff0000000019909216919091179055565b610b0f83838360405180602001604052806000815250612841565b6060600061147d8361180b565b90506000816001600160401b0381111561149957611499615edd565b6040519080825280602002602001820160405280156114c2578160200160208202803683370190505b50905060005b82811015611509576114da85826112de565b8282815181106114ec576114ec615ec7565b60209081029190910101528061150181615e56565b9150506114c8565b509392505050565b600a546001600160a01b0316331461153b5760405162461bcd60e51b81526004016109d990615b07565b601155565b600061154b60085490565b82106115ae5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016109d9565b600882815481106115c1576115c1615ec7565b90600052602060002001549050919050565b600b602052600090815260409020805481906115ee90615e1b565b80601f016020809104026020016040519081016040528092919081815260200182805461161a90615e1b565b80156116675780601f1061163c57610100808354040283529160200191611667565b820191906000526020600020905b81548152906001019060200180831161164a57829003601f168201915b5050506002909301549192505063ffffffff80821691600160201b81049091169060ff600160401b9091041684565b601780546116a390615e1b565b80601f01602080910402602001604051908101604052809291908181526020018280546116cf90615e1b565b801561171c5780601f106116f15761010080835404028352916020019161171c565b820191906000526020600020905b8154815290600101906020018083116116ff57829003601f168201915b505050505081565b600a546001600160a01b0316331461174e5760405162461bcd60e51b81526004016109d990615b07565b600f805463ffffffff191663ffffffff92909216919091179055565b6000818152600260205260408120546001600160a01b0316806108d95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016109d9565b805160009082906117f55750600092915050565b50506001015190565b601680546116a390615e1b565b60006001600160a01b0382166118765760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016109d9565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146118bc5760405162461bcd60e51b81526004016109d990615b07565b6114026000613d61565b600a546001600160a01b031633146118f05760405162461bcd60e51b81526004016109d990615b07565b60005b8151811015610b9957600f60049054906101000a900463ffffffff1663ffffffff166014600084848151811061192b5761192b615ec7565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002081905550808061196290615e56565b9150506118f3565b611973816136e7565b61198f5760405162461bcd60e51b81526004016109d990615adc565b336119998261176a565b6001600160a01b0316146119e35760405162461bcd60e51b815260206004820152601160248201527008081d1bdad95b881b9bdd081bdddb9959607a1b60448201526064016109d9565b6000818152601560209081526040808320815160a08101835290546001600160f81b031960f882901b1680835263ffffffff6101008304811684870152600160281b8304811684860152600160481b830481166060850152600160681b90920490911660808301528452600b90925290912060010154611aa55760405162461bcd60e51b815260206004820152601c60248201527f73686f756c64206e6f742062652061206261736520656c656d656e740000000060448201526064016109d9565b611abc816000015160018360200151600180613843565b80516001600160f81b0319166000908152600b602052604081206001018054611b1b9290611aec57611aec615ec7565b90600052602060002090602091828204019190069054906101000a900460f81b60018360200151600080613843565b6040805160a08101825282516001600160f81b0319166000908152600b602052918220600101805491928392611b5357611b53615ec7565b600091825260209182902082820401546001600160f81b0319601f9092166101000a900460f81b1682528381015163ffffffff1690820152604080840151910190611b9f906001615cd2565b63ffffffff9081168252606080850151821660208085019190915260808087015184166040958601526000888152601583528590208651815493880151968801519488015197909201518516600160681b0263ffffffff60681b19978616600160481b0263ffffffff60481b19958716600160281b029590951667ffffffffffffffff60281b19979096166101000264ffffffffff1990941660f89390931c92909217929092179490941692909217179290921617905560015b81516001600160f81b0319166000908152600b6020526040902060010154811015610b0f5781516001600160f81b0319166000908152600b602052604090206001018054611ce1919083908110611cb257611cb2615ec7565b90600052602060002090602091828204019190069054906101000a900460f81b60018460200151600080613843565b81516001600160f81b0319166000908152600b602052604090206001018054611d5b91339184908110611d1657611d16615ec7565b90600052602060002090602091828204019190069054906101000a900460f81b8460200151856060015186604001516001611d519190615cd2565b8760800151613db3565b80611d6581615e56565b915050611c59565b60018451118015611d7f575082516001145b8015611d91575060008263ffffffff16115b8015611d9d5750600081115b611de95760405162461bcd60e51b815260206004820152601960248201527f746f6b656e7320726571756972656d6e74206e6f74206d65740000000000000060448201526064016109d9565b6000611df484615db8565b6001600160f81b031981166000908152600b6020526040902060019081015491925010611e755760405162461bcd60e51b815260206004820152602960248201527f726573756c7420746f6b656e2073686f756c64206e6f742062652061206261736044820152681948195b195b595b9d60ba1b60648201526084016109d9565b33611e7f8361176a565b6001600160a01b031614611ecc5760405162461bcd60e51b8152602060048201526014602482015273189d5c9b881d1bdad95b881b9bdd081bdddb995960621b60448201526064016109d9565b611ed68583613772565b15611f165760405162461bcd60e51b815260206004820152601060248201526f6475706c696361746520746f6b656e7360801b60448201526064016109d9565b600085516001600160401b03811115611f3157611f31615edd565b604051908082528060200260200182016040528015611f5a578160200160208202803683370190505b506001600160f81b031983166000908152600b6020526040812060010154919250906001600160401b03811115611f9357611f93615edd565b604051908082528060200260200182016040528015611fbc578160200160208202803683370190505b50905060005b875181101561231257611fe0888281518110610d9e57610d9e615ec7565b61201e5760405162461bcd60e51b815260206004820152600f60248201526e1d1bdad95b881b9bdd08195e1a5cdd608a1b60448201526064016109d9565b336001600160a01b031661203d898381518110610e0857610e08615ec7565b6001600160a01b0316146120855760405162461bcd60e51b815260206004820152600f60248201526e1d1bdad95b881b9bdd081bdddb9959608a1b60448201526064016109d9565b6000601560008a848151811061209d5761209d615ec7565b60209081029190910181015182528181019290925260409081016000908120825160a08101845290546001600160f81b031960f882901b16825263ffffffff6101008204811695830195909552600160281b8104851693820193909352600160481b830484166060820152600160681b909204909216608082015291505b6001600160f81b031986166000908152600b60205260409020600101548110156122fd5781516001600160f81b03198781166000908152600b6020526040902060010180549190921691908390811061217657612176615ec7565b90600052602060002090602091828204019190069054906101000a900460f81b6001600160f81b0319161480156121d157508763ffffffff168482815181106121c1576121c1615ec7565b602002602001015163ffffffff16105b156122eb5760008482815181106121ea576121ea615ec7565b6020026020010151896121fd9190615d93565b90508063ffffffff16836020015163ffffffff161161228557826020015185838151811061222d5761222d615ec7565b602002602001018181516122419190615cd2565b63ffffffff169052506020830151865187908690811061226357612263615ec7565b602002602001018181516122779190615cd2565b63ffffffff169052506122e9565b8085838151811061229857612298615ec7565b602002602001018181516122ac9190615cd2565b63ffffffff16905250855181908790869081106122cb576122cb615ec7565b602002602001018181516122df9190615cd2565b63ffffffff169052505b505b806122f581615e56565b91505061211b565b5050808061230a90615e56565b915050611fc2565b5060005b6001600160f81b031984166000908152600b60205260409020600101548110156123c0578563ffffffff1682828151811061235357612353615ec7565b602002602001015163ffffffff16146123ae5760405162461bcd60e51b815260206004820152601860248201527f6d61737320726571756972656d656e74206e6f74206d6574000000000000000060448201526064016109d9565b806123b881615e56565b915050612316565b5060008060008060005b8b51811015612685576000601560008e84815181106123eb576123eb615ec7565b60209081029190910181015182528181019290925260409081016000908120825160a08101845290546001600160f81b031960f882901b16825263ffffffff6101008204811695830195909552600160281b8104851693820193909352600160481b830484166060820152600160681b9092049092166080820152895190925089908490811061247d5761247d615ec7565b602002602001015163ffffffff161115612672578782815181106124a3576124a3615ec7565b602002602001015163ffffffff16816020015163ffffffff16111561256a578782815181106124d4576124d4615ec7565b602002602001015181602001516124eb9190615d93565b601560008f858151811061250157612501615ec7565b6020026020010151815260200190815260200160002060000160016101000a81548163ffffffff021916908363ffffffff160217905550612565816000015160008a858151811061255457612554615ec7565b602002602001015160006001613843565b6125ab565b612596816000015160018a858151811061258657612586615ec7565b6020026020010151600180613843565b6125ab8d838151811061118057611180615ec7565b8782815181106125bd576125bd615ec7565b6020026020010151866125d09190615cd2565b95508782815181106125e4576125e4615ec7565b602002602001015181606001516125fb9190615d50565b6126059086615cd2565b945087828151811061261957612619615ec7565b602002602001015181604001516126309190615d50565b61263a9085615cd2565b935087828151811061264e5761264e615ec7565b602002602001015181608001516126659190615d50565b61266f9084615cd2565b92505b508061267d81615e56565b9150506123ca565b50600088815260156020908152604091829020825160a08101845290546001600160f81b031960f882901b16825263ffffffff61010082048116938301849052600160281b8204811694830194909452600160481b810484166060830152600160681b900490921660808301526001101561275e5760008981526015602052604090208054600191908290612726908290610100900463ffffffff16615d93565b92506101000a81548163ffffffff021916908363ffffffff16021790555061275981600001516000600160006001613843565b612777565b805161276e906001808080613843565b61277789613aa1565b6127818585615d0e565b61278c906001615cd2565b93506127988584615d0e565b92506127a48583615d0e565b91506127b433898c878787613db3565b6127c38860018c600080613843565b505050505050505050505050565b6060600180546108ee90615e1b565b610b99338383613f2a565b600a546001600160a01b031633146128155760405162461bcd60e51b81526004016109d990615b07565b801561282e578151610b0f906017906020850190614818565b8151610b0f906016906020850190614818565b61284b3383613ad0565b6128675760405162461bcd60e51b81526004016109d990615b3c565b61287384848484613ff9565b50505050565b6060612884826136e7565b6128a05760405162461bcd60e51b81526004016109d990615adc565b6000601680546128af90615e1b565b9050116128ee5760405162461bcd60e51b815260206004820152600d60248201526c3130b9b2bab9349032b93937b960991b60448201526064016109d9565b600082815260156020526040902054730666b387167fec46b2efbad730c0a14dfd6f052f9063111b1d629084906129449063ffffffff6101008204811691600160481b8104821691600160281b9091041661402c565b6000868152601560209081526040808320805460f81b6001600160f81b0319168452600b90925291829020915160e086901b6001600160e01b031916815261299794939290601790601690600401615b8d565b60006040518083038186803b1580156129af57600080fd5b505af41580156129c3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108d99190810190614f11565b60135460ff16612a3d5760405162461bcd60e51b815260206004820152601e60248201527f7072656d696e742f7075626c6963206d696e74206e6f7420616374697665000060448201526064016109d9565b8051825114612a845760405162461bcd60e51b815260206004820152601360248201527277726f6e6720656c656d656e74732f6d61737360681b60448201526064016109d9565b6000805b8351811015612bf3576000848281518110612aa557612aa5615ec7565b6020026020010151612ab690615db8565b6001600160f81b031981166000908152600b602052604090206001015490915015612b1a5760405162461bcd60e51b815260206004820152601460248201527308139bdd08184818985cda58c8115b195b595b9d60621b60448201526064016109d9565b600f54845163ffffffff90911690859084908110612b3a57612b3a615ec7565b6020908102919091018101516001600160f81b0319841660009081526010909252604090912054612b749160ff169063ffffffff16615cd2565b63ffffffff161115612bb55760405162461bcd60e51b815260206004820152600a6024820152690737570706c79206361760b41b60448201526064016109d9565b838281518110612bc757612bc7615ec7565b602002602001015160ff1683612bdd9190615cd2565b9250508080612beb90615e56565b915050612a88565b5060008163ffffffff1611612c415760405162461bcd60e51b8152602060048201526014602482015273139bc8195b195b595b9d1cc81cd95b1958dd195960621b60448201526064016109d9565b60135460ff1660011415612ca8573360009081526014602052604090205463ffffffff82161115612ca35760405162461bcd60e51b815260206004820152600c60248201526b0574c20416c6c6f63204361760a41b60448201526064016109d9565b612d5a565b60135460ff1660021415612d0a573360009081526014602052604090205463ffffffff82161115612d0a5760405162461bcd60e51b815260206004820152600c60248201526b0574c20416c6c6f63204361760a41b60448201526064016109d9565b346011548263ffffffff16612d1f9190615d31565b1115612d5a5760405162461bcd60e51b815260206004820152600a602482015269616d6f756e74206c6f7760b01b60448201526064016109d9565b600f5463ffffffff600160201b90910481169082161115612dad5760405162461bcd60e51b815260206004820152600d60248201526c075736572206d696e742063617609c1b60448201526064016109d9565b601354600260ff90911611612dec57336000908152601460205260408120805463ffffffff84169290612de1908490615d7c565b90915550612dec9050565b60005b8351811015612873576000848281518110612e0c57612e0c615ec7565b6020026020010151612e1d90615db8565b9050838281518110612e3157612e31615ec7565b6020908102919091018101516001600160f81b031983166000908152601090925260408220805460ff909216929091612e7190849063ffffffff16615cd2565b92506101000a81548163ffffffff021916908363ffffffff160217905550612eba816001868581518110612ea757612ea7615ec7565b602002602001015160ff16600080613843565b612f1d3382868581518110612ed157612ed1615ec7565b602002602001015160ff16612f01888781518110612ef157612ef1615ec7565b602002602001015160ff1661409d565b612f16898881518110612ef157612ef1615ec7565b6000613db3565b5080612f2881615e56565b915050612def565b612f39816136e7565b612f555760405162461bcd60e51b81526004016109d990615adc565b33612f5f8261176a565b6001600160a01b031614612fa95760405162461bcd60e51b815260206004820152601160248201527008081d1bdad95b881b9bdd081bdddb9959607a1b60448201526064016109d9565b600081815260156020908152604091829020825160a08101845290546001600160f81b031960f882901b16825263ffffffff61010082048116938301849052600160281b8204811694830194909452600160481b810484166060830152600160681b90049092166080830152600211156130505760405162461bcd60e51b81526020600482015260086024820152676c6f77206d61737360c01b60448201526064016109d9565b6000816040015160016130639190615cd2565b6040805160a08101825284516001600160f81b03191681526001602080830182815263ffffffff8087168587019081526060808b015183169087019081526080808c0151841690880190815260008d81526015909652979094209551865493519151945197518316600160681b0263ffffffff60681b19988416600160481b0263ffffffff60481b19968516600160281b029690961667ffffffffffffffff60281b19939094166101000264ffffffffff1990951660f89290921c9190911793909317161791909117939093169290921790559091505b826020015163ffffffff168110156131795761316733846000015160018660600151868860800151613db3565b8061317181615e56565b91505061313a565b50610b0f8260000151600184602001516131939190615d93565b6000806000613843565b600a546001600160a01b031633146131c75760405162461bcd60e51b81526004016109d990615b07565b60006131d285615db8565b90506131dd81614193565b6132155760405162461bcd60e51b8152602060048201526009602482015268139bdd08115e1a5cdd60ba1b60448201526064016109d9565b600083516001600160401b0381111561323057613230615edd565b604051908082528060200260200182016040528015613259578160200160208202803683370190505b50905060005b845181101561330f57600085828151811061327c5761327c615ec7565b602002602001015161328d90615db8565b905061329881614193565b6132d05760405162461bcd60e51b8152602060048201526009602482015268139bdd08115e1a5cdd60ba1b60448201526064016109d9565b808383815181106132e3576132e3615ec7565b6001600160f81b031990921660209283029190910190910152508061330781615e56565b91505061325f565b506001600160f81b031982166000908152600b60209081526040909120865161333a92880190614818565b506001600160f81b031982166000908152600b60209081526040909120825161336b9260019092019184019061489c565b50506001600160f81b0319166000908152600b60205260409020600201805460ff909216600160401b0260ff60401b19909216919091179055505050565b600a546001600160a01b031633146133d35760405162461bcd60e51b81526004016109d990615b07565b60006133de85615db8565b90506133e981614193565b1561341e5760405162461bcd60e51b8152602060048201526005602482015264115e1a5cdd60da1b60448201526064016109d9565b600083516001600160401b0381111561343957613439615edd565b604051908082528060200260200182016040528015613462578160200160208202803683370190505b50905060005b84518110156134d25784818151811061348357613483615ec7565b602002602001015161349490615db8565b826000815181106134a7576134a7615ec7565b6001600160f81b031990921660209283029190910190910152806134ca81615e56565b915050613468565b506040805160a081018252868152602080820184905260008284018190526060830181905260ff871660808401526001600160f81b031986168152600b825292909220815180519293919261352a9284920190614818565b506020828101518051613543926001850192019061489c565b5060408201516002919091018054606084015160809094015163ffffffff93841667ffffffffffffffff1990921691909117600160201b93909416929092029290921760ff60401b1916600160401b60ff9283160217909155600c80546001810182556000919091527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c760208204018054601f9092166101000a9283021990911660f89490941c91909102929092179091555050505050565b600a546001600160a01b031633146136265760405162461bcd60e51b81526004016109d990615b07565b6001600160a01b03811661368b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109d9565b61369481613d61565b50565b60006001600160e01b031982166380ac58cd60e01b14806136c857506001600160e01b03198216635b5e139f60e01b145b806108d957506301ffc9a760e01b6001600160e01b03198316146108d9565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906137398261176a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000805b835181101561383957600061378c826001615cba565b90505b84518110156137ef578481815181106137aa576137aa615ec7565b60200260200101518583815181106137c4576137c4615ec7565b602002602001015114156137dd576001925050506108d9565b806137e781615e56565b91505061378f565b5060008311801561381857508284828151811061380e5761380e615ec7565b6020026020010151145b156138275760019150506108d9565b8061383181615e56565b915050613776565b5060009392505050565b63ffffffff84161561395f57811561390e576001600160f81b031985166000908152600b602052604090206002015463ffffffff808616911610156138b95760405162461bcd60e51b815260206004820152600c60248201526b77726f6e6720737570706c7960a01b60448201526064016109d9565b6001600160f81b031985166000908152600b6020526040812060020180548692906138eb90849063ffffffff16615d93565b92506101000a81548163ffffffff021916908363ffffffff16021790555061395f565b6001600160f81b031985166000908152600b60205260408120600201805486929061394090849063ffffffff16615cd2565b92506101000a81548163ffffffff021916908363ffffffff1602179055505b63ffffffff831615613a9a578015613a3f576001600160f81b031985166000908152600b602052604090206002015463ffffffff808516600160201b9092041610156139e05760405162461bcd60e51b815260206004820152601060248201526f77726f6e6720737570706c794d61737360801b60448201526064016109d9565b6001600160f81b031985166000908152600b602052604090206002018054849190600490613a1c908490600160201b900463ffffffff16615d93565b92506101000a81548163ffffffff021916908363ffffffff160217905550613a9a565b6001600160f81b031985166000908152600b602052604090206002018054849190600490613a7b908490600160201b900463ffffffff16615cd2565b92506101000a81548163ffffffff021916908363ffffffff1602179055505b5050505050565b6000818152601560205260409020805470ffffffffffffffffffffffffffffffffff191690556136948161420e565b6000613adb826136e7565b613b3c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016109d9565b6000613b478361176a565b9050806001600160a01b0316846001600160a01b03161480613b825750836001600160a01b0316613b7784610971565b6001600160a01b0316145b80613bb257506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316613bcd8261176a565b6001600160a01b031614613c315760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016109d9565b6001600160a01b038216613c935760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109d9565b613c9e8383836142b5565b613ca9600082613704565b6001600160a01b0383166000908152600360205260408120805460019290613cd2908490615d7c565b90915550506001600160a01b0382166000908152600360205260408120805460019290613d00908490615cba565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b613dbc85614193565b613dfd5760405162461bcd60e51b8152602060048201526012602482015271456c656d656e74204e6f742045786973747360701b60448201526064016109d9565b60128054906000613e0d83615e56565b90915550506040805160a0810182526001600160f81b03198716815263ffffffff8681166020808401918252868316848601908152888416606086019081528785166080870190815260128054600090815260159095529790932095518654945192519151935160f89190911c64ffffffffff1990951694909417610100928616929092029190911767ffffffffffffffff60281b1916600160281b9185169190910263ffffffff60481b191617600160481b918416919091021763ffffffff60681b1916600160681b919092160217905554613eeb908790614337565b6012546040516001600160a01b038816907f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688590600090a3505050505050565b816001600160a01b0316836001600160a01b03161415613f8c5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109d9565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b614004848484613bba565b61401084848484614351565b6128735760405162461bcd60e51b81526004016109d990615a8a565b600f546000908190600160401b900463ffffffff168361404c8688615cd2565b6140569190615cd2565b6140609190615d0e565b600f5463ffffffff9182169250600160601b900416811015614083579050614096565b5050600f54600160601b900463ffffffff165b9392505050565b600080805b8381101561413b57600e54600d8054429133919060006140c183615e56565b919050556040516020016140fa9392919092835260609190911b6bffffffffffffffffffffffff19166020830152603482015260540190565b6040516020818303038152906040528051906020012060001c61411d9190615e71565b6141279083615cba565b91508061413381615e56565b9150506140a2565b5060018311156141525761414f8382615cfa565b90505b600e818154811061416557614165615ec7565b90600052602060002090600891828204019190066004029054906101000a900463ffffffff16915050919050565b600080805b600c5481101561420757600c81815481106141b5576141b5615ec7565b90600052602060002090602091828204019190069054906101000a900460f81b6001600160f81b031916846001600160f81b03191614156141f557600191505b806141ff81615e56565b915050614198565b5092915050565b60006142198261176a565b9050614227816000846142b5565b614232600083613704565b6001600160a01b038116600090815260036020526040812080546001929061425b908490615d7c565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6142c083838361445e565b6001600160a01b038216158015906142e057506001600160a01b03831615155b15610b0f576000818152601560205260409020805460019190600d90614314908490600160681b900463ffffffff16615cd2565b92506101000a81548163ffffffff021916908363ffffffff160217905550505050565b610b99828260405180602001604052806000815250614516565b60006001600160a01b0384163b1561445357604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906143959033908990889088906004016159bb565b602060405180830381600087803b1580156143af57600080fd5b505af19250505080156143df575060408051601f3d908101601f191682019092526143dc91810190614ec0565b60015b614439573d80801561440d576040519150601f19603f3d011682016040523d82523d6000602084013e614412565b606091505b5080516144315760405162461bcd60e51b81526004016109d990615a8a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050613bb2565b506001949350505050565b6001600160a01b0383166144b9576144b481600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6144dc565b816001600160a01b0316836001600160a01b0316146144dc576144dc8382614549565b6001600160a01b0382166144f357610b0f816145e6565b826001600160a01b0316826001600160a01b031614610b0f57610b0f8282614695565b61452083836146d9565b61452d6000848484614351565b610b0f5760405162461bcd60e51b81526004016109d990615a8a565b600060016145568461180b565b6145609190615d7c565b6000838152600760205260409020549091508082146145b3576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906145f890600190615d7c565b6000838152600960205260408120546008805493945090928490811061462057614620615ec7565b90600052602060002001549050806008838154811061464157614641615ec7565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061467957614679615eb1565b6001900381819060005260206000200160009055905550505050565b60006146a08361180b565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b03821661472f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109d9565b614738816136e7565b156147855760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109d9565b614791600083836142b5565b6001600160a01b03821660009081526003602052604081208054600192906147ba908490615cba565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461482490615e1b565b90600052602060002090601f016020900481019282614846576000855561488c565b82601f1061485f57805160ff191683800117855561488c565b8280016001018555821561488c579182015b8281111561488c578251825591602001919060010190614871565b50614898929150614939565b5090565b82805482825590600052602060002090601f0160209004810192821561488c5791602002820160005b8382111561490357835183826101000a81548160ff021916908360f81c021790555092602001926001016020816000010492830192600103026148c5565b80156149305782816101000a81549060ff0219169055600101602081600001049283019260010302614903565b50506148989291505b5b80821115614898576000815560010161493a565b600061496161495c84615c93565b615c40565b905082815283838301111561497557600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b03811681146149a357600080fd5b919050565b600082601f8301126149b957600080fd5b813560206149c961495c83615c70565b80838252828201915082860187848660051b89010111156149e957600080fd5b6000805b86811015614a2b5782356001600160401b03811115614a0a578283fd5b614a188b88838d0101614ab6565b86525093850193918501916001016149ed565b509198975050505050505050565b600082601f830112614a4a57600080fd5b81356020614a5a61495c83615c70565b80838252828201915082860187848660051b8901011115614a7a57600080fd5b60005b85811015614a9957813584529284019290840190600101614a7d565b5090979650505050505050565b803580151581146149a357600080fd5b600082601f830112614ac757600080fd5b6140968383356020850161494e565b803563ffffffff811681146149a357600080fd5b803560ff811681146149a357600080fd5b600060208284031215614b0d57600080fd5b6140968261498c565b60008060408385031215614b2957600080fd5b614b328361498c565b9150614b406020840161498c565b90509250929050565b600080600060608486031215614b5e57600080fd5b614b678461498c565b9250614b756020850161498c565b9150604084013590509250925092565b60008060008060808587031215614b9b57600080fd5b614ba48561498c565b9350614bb26020860161498c565b92506040850135915060608501356001600160401b03811115614bd457600080fd5b8501601f81018713614be557600080fd5b614bf48782356020840161494e565b91505092959194509250565b60008060408385031215614c1357600080fd5b614c1c8361498c565b9150614b4060208401614aa6565b60008060408385031215614c3d57600080fd5b614c468361498c565b946020939093013593505050565b60006020808385031215614c6757600080fd5b82356001600160401b03811115614c7d57600080fd5b8301601f81018513614c8e57600080fd5b8035614c9c61495c82615c70565b80828252848201915084840188868560051b8701011115614cbc57600080fd5b600094505b83851015614ce657614cd28161498c565b835260019490940193918501918501614cc1565b50979650505050505050565b60008060408385031215614d0557600080fd5b82356001600160401b0380821115614d1c57600080fd5b614d28868387016149a8565b9350602091508185013581811115614d3f57600080fd5b85019050601f81018613614d5257600080fd5b8035614d6061495c82615c70565b80828252848201915084840189868560051b8701011115614d8057600080fd5b600094505b83851015614daa57614d9681614aea565b835260019490940193918501918501614d85565b5080955050505050509250929050565b60008060008060808587031215614dd057600080fd5b84356001600160401b0380821115614de757600080fd5b614df388838901614a39565b95506020870135915080821115614e0957600080fd5b50614e1687828801614ab6565b935050614e2560408601614ad6565b9396929550929360600135925050565b60008060408385031215614e4857600080fd5b82356001600160401b03811115614e5e57600080fd5b614e6a85828601614a39565b95602094909401359450505050565b600060208284031215614e8b57600080fd5b81356001600160f81b03198116811461409657600080fd5b600060208284031215614eb557600080fd5b813561409681615ef3565b600060208284031215614ed257600080fd5b815161409681615ef3565b600060208284031215614eef57600080fd5b81356001600160401b03811115614f0557600080fd5b613bb284828501614ab6565b600060208284031215614f2357600080fd5b81516001600160401b03811115614f3957600080fd5b8201601f81018413614f4a57600080fd5b8051614f5861495c82615c93565b818152856020838501011115614f6d57600080fd5b614f7e826020830160208601615def565b95945050505050565b60008060408385031215614f9a57600080fd5b82356001600160401b03811115614fb057600080fd5b614fbc85828601614ab6565b925050614b4060208401614aa6565b60008060008060808587031215614fe157600080fd5b84356001600160401b0380821115614ff857600080fd5b61500488838901614ab6565b9550602087013591508082111561501a57600080fd5b61502688838901614ab6565b9450604087013591508082111561503c57600080fd5b50615049878288016149a8565b92505061505860608601614aea565b905092959194509250565b60006020828403121561507557600080fd5b5035919050565b60006020828403121561508e57600080fd5b61409682614ad6565b600080604083850312156150aa57600080fd5b6150b383614ad6565b9150614b4060208401614ad6565b6000602082840312156150d357600080fd5b61409682614aea565b6001600160f81b0319169052565b60008151808452615102816020860160208601615def565b601f01601f19169290920160200192915050565b8054600090600181811c908083168061513057607f831692505b602080841082141561515257634e487b7160e01b600052602260045260246000fd5b838852818015615169576001811461517d576151ab565b60ff198616898301526040890196506151ab565b876000528160002060005b868110156151a35781548b8201850152908501908301615188565b8a0183019750505b50505050505092915050565b600060a08084526151ca81850184615116565b60018085016020878403818901528382546151e9818790815260200190565b600094855260208520965091505b80601f85011015615474578554615211838260f81b6150dc565b6001600160f81b031961522c84860160f084901b83166150dc565b604061523f818601838560e81b166150dc565b606060e06152538288018587841b166150dc565b61526560808801858760d81b166150dc565b6152768c8801858760d01b166150dc565b61528860c08801858760c81b166150dc565b615299818801858760c01b166150dc565b506152ad6101008701848660b81b166150dc565b6152c06101208701848660b01b166150dc565b6152d36101408701848660a81b166150dc565b6152e5610160870184868e1b166150dc565b6152f86101808701848660981b166150dc565b61530b6101a08701848660901b166150dc565b61531e6101c08701848660881b166150dc565b6153316101e08701848660801b166150dc565b6153446102008701848660781b166150dc565b6153576102208701848660701b166150dc565b61536a6102408701848660681b166150dc565b61537c61026087018486841b166150dc565b506153906102808601838560581b166150dc565b6153a36102a08601838560501b166150dc565b6153b66102c08601838560481b166150dc565b6153c86102e086018385841b166150dc565b506153dc6103008501828460381b166150dc565b6153ef6103208501828460301b166150dc565b6154026103408501828460281b166150dc565b61541461036085018284881b166150dc565b6154276103808501828460181b166150dc565b61543a6103a08501828460101b166150dc565b61544d6103c08501828460081b166150dc565b61545d6103e085018284166150dc565b5050948401949282019261040091909101906151f7565b945494808410156154955761548c828760f81b6150dc565b92840192908201905b808410156154be576154b58260f088901b6001600160f81b0319166150dc565b92840192908201905b808410156154e7576154de8260e888901b6001600160f81b0319166150dc565b92840192908201905b80841015615510576155078260e088901b6001600160f81b0319166150dc565b92840192908201905b80841015615539576155308260d888901b6001600160f81b0319166150dc565b92840192908201905b80841015615562576155598260d088901b6001600160f81b0319166150dc565b92840192908201905b8084101561558b576155828260c888901b6001600160f81b0319166150dc565b92840192908201905b808410156155b4576155ab8260c088901b6001600160f81b0319166150dc565b92840192908201905b808410156155dd576155d48260b888901b6001600160f81b0319166150dc565b92840192908201905b80841015615606576155fd8260b088901b6001600160f81b0319166150dc565b92840192908201905b8084101561562f576156268260a888901b6001600160f81b0319166150dc565b92840192908201905b808410156156565761564d8287891b6001600160f81b0319166150dc565b92840192908201905b8084101561567f5761567682609888901b6001600160f81b0319166150dc565b92840192908201905b808410156156a85761569f82609088901b6001600160f81b0319166150dc565b92840192908201905b808410156156d1576156c882608888901b6001600160f81b0319166150dc565b92840192908201905b808410156156fa576156f182608088901b6001600160f81b0319166150dc565b92840192908201905b808410156157235761571a82607888901b6001600160f81b0319166150dc565b92840192908201905b8084101561574c5761574382607088901b6001600160f81b0319166150dc565b92840192908201905b808410156157755761576c82606888901b6001600160f81b0319166150dc565b92840192908201905b8084101561579e5761579582606088901b6001600160f81b0319166150dc565b92840192908201905b808410156157c7576157be82605888901b6001600160f81b0319166150dc565b92840192908201905b808410156157f0576157e782605088901b6001600160f81b0319166150dc565b92840192908201905b808410156158195761581082604888901b6001600160f81b0319166150dc565b92840192908201905b808410156158425761583982604088901b6001600160f81b0319166150dc565b92840192908201905b8084101561586b5761586282603888901b6001600160f81b0319166150dc565b92840192908201905b808410156158945761588b82603088901b6001600160f81b0319166150dc565b92840192908201905b808410156158bd576158b482602888901b6001600160f81b0319166150dc565b92840192908201905b808410156158e4576158db8287851b6001600160f81b0319166150dc565b92840192908201905b8084101561590d5761590482601888901b6001600160f81b0319166150dc565b92840192908201905b808410156159365761592d82601088901b6001600160f81b0319166150dc565b92840192908201905b8084101561595f5761595682600888901b6001600160f81b0319166150dc565b92840192908201905b808410156159805761597b826001600160f81b031988166150dc565b908201905b506002979097015463ffffffff80821660408b8101919091529282901c1660608a015260ff911c166080909701969096525092949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906159ee908301846150ea565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015615a3057835183529284019291840191600101615a14565b50909695505050505050565b608081526000615a4f60808301876150ea565b63ffffffff958616602084015293909416604082015260ff9190911660609091015292915050565b60208152600061409660208301846150ea565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601190820152703737b732bc34b9ba32b73a103a37b5b2b760791b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6000610140888352876020840152865460ff60f81b8160f81b16604085015263ffffffff808260081c166060860152808260281c166080860152615bde60a08601828460481c1663ffffffff169052565b615bf560c08601828460681c1663ffffffff169052565b50508060e0840152615c09818401876151b7565b9050828103610100840152615c1e8186615116565b9050828103610120840152615c338185615116565b9998505050505050505050565b604051601f8201601f191681016001600160401b0381118282101715615c6857615c68615edd565b604052919050565b60006001600160401b03821115615c8957615c89615edd565b5060051b60200190565b60006001600160401b03821115615cac57615cac615edd565b50601f01601f191660200190565b60008219821115615ccd57615ccd615e85565b500190565b600063ffffffff808316818516808303821115615cf157615cf1615e85565b01949350505050565b600082615d0957615d09615e9b565b500490565b600063ffffffff80841680615d2557615d25615e9b565b92169190910492915050565b6000816000190483118215151615615d4b57615d4b615e85565b500290565b600063ffffffff80831681851681830481118215151615615d7357615d73615e85565b02949350505050565b600082821015615d8e57615d8e615e85565b500390565b600063ffffffff83811690831681811015615db057615db0615e85565b039392505050565b805160208201516001600160f81b03198082169291906001831015615de75780818460010360031b1b83161693505b505050919050565b60005b83811015615e0a578181015183820152602001615df2565b838111156128735750506000910152565b600181811c90821680615e2f57607f821691505b60208210811415615e5057634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615e6a57615e6a615e85565b5060010190565b600082615e8057615e80615e9b565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b03198116811461369457600080fdfea2646970667358221220a826e17a6fa15aa68cfb351aa0f0df6542241d651958b2f28cd885fe78089a3564736f6c63430008070033

Verified Source Code Partial Match

Compiler: v0.8.7+commit.e28d00a7 EVM: london Optimization: Yes (200 runs)
base64.sol 90 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // Loads the table into memory
        string memory table = _TABLE;

        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
        // and split into 4 numbers of 6 bits.
        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
        // - `data.length + 2`  -> Round up
        // - `/ 3`              -> Number of 3-bytes chunks
        // - `4 *`              -> 4 characters for each chunk
        string memory result = new string(4 * ((data.length + 2) / 3));

        assembly {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 32)

            // Run over the input, 3 bytes at a time
            for {
                let dataPtr := data
                let endPtr := add(data, mload(data))
            } lt(dataPtr, endPtr) {

            } {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 bytes (18 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F which is the number of
                // the previous character in the ASCII table prior to the Base64 Table
                // The result is then added to the table to get the character to write,
                // and finally write it in the result pointer but with a left shift
                // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // When data `bytes` is not exactly 3 bytes long
            // it is padded with `=` characters at the end
            switch mod(mload(data), 3)
            case 1 {
                mstore8(sub(resultPtr, 1), 0x3d)
                mstore8(sub(resultPtr, 2), 0x3d)
            }
            case 2 {
                mstore8(sub(resultPtr, 1), 0x3d)
            }
        }

        return result;
    }
}

 
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;
}
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);
}
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);
    }
}
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);
}
ERC721Enumerable.sol 163 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @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.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

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

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

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

    /**
     * @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-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @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` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * 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 override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}
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);
    }
}
ERC721.sol 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // 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;

    /**
     * @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 (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 view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @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 {
        _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");

        _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 _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);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);

        _afterTokenTransfer(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);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);

        _afterTokenTransfer(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 from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(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 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;
        }
    }

    /**
     * @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 {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}
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;
    }
}
elements.sol 573 lines
// SPDX-License-Identifier: GPL-3.0


//  ███████╗██╗     ███████╗███╗   ███╗███████╗███╗   ██╗████████╗███████╗
//  ██╔════╝██║     ██╔════╝████╗ ████║██╔════╝████╗  ██║╚══██╔══╝██╔════╝
//  █████╗  ██║     █████╗  ██╔████╔██║█████╗  ██╔██╗ ██║   ██║   ███████╗
//  ██╔══╝  ██║     ██╔══╝  ██║╚██╔╝██║██╔══╝  ██║╚██╗██║   ██║   ╚════██║
//  ███████╗███████╗███████╗██║ ╚═╝ ██║███████╗██║ ╚████║   ██║   ███████║
//  ╚══════╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═══╝   ╚═╝   ╚══════╝

// Created By: https://elements.blue

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";



import {NFTDetails,Element,Meta} from "./meta.sol";


contract Elements is ERC721Enumerable, Ownable {
    using Strings for uint256;
    event Mint(address indexed owner, uint256 indexed tokenId);

    receive() external payable {}

    mapping(bytes1 => Element) public elements;
    bytes1[] elementIds=[bytes1('1'),bytes1('2'),bytes1('3'),bytes1('4') ];

    uint randNonce = 1;
    uint32[] raritykeys=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,4,4,5];
    uint32 basicElementSupplyCap = 37500;
    uint32 basicElementPreMintCap = 24;
    uint32 artLevelWeight = 4;
    uint32 maxLevelWeight = 20;
    mapping(bytes1 => uint32) public basicElementMintedCount;

    // ----- Minting -----
    uint256 public mintPrice = 0.003 ether;
    uint256 private lastTokenId=1000;
    // Minting Stage:
    // 0 - Not open
    // 1 - freeMint
    // 2 - preMint
    // 3 - publicMint
    uint8 public mintingStage=0; 
    mapping(address => uint256) public preMintAddresses;


    mapping(uint256 => NFTDetails) public tokenInfo;
    string public baseURI = "";
    string public externalURI = "https://elements.blue";

    constructor() ERC721("Elements", "Elements") {
         // Adding basic Elements
         bytes1[] memory _parents;
         elements["1"] = Element({name: "Fire", parents:  _parents,supply: 0,supplyMass:0, tier:0 });
         elements["2"] = Element({name: "Water", parents:  _parents,supply: 0, supplyMass:0, tier:0 });
         elements["3"] = Element({name: "Air", parents:  _parents,supply: 0,supplyMass:0, tier:0 });
         elements["4"] = Element({name: "Earth", parents:  _parents,supply: 0,supplyMass:0, tier:0 });
          
 
        // Initial Creatures before mint
        bytes1[] memory _parents2=new bytes1[](2);
        _parents2[0]=bytes1('1');
        _parents2[1]=bytes1('4');
        elements["M"] = Element({name: "Roc", parents: _parents2,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('M'));

        bytes1[] memory _parents3=new bytes1[](2);
        _parents3[0]=bytes1('2');
        _parents3[1]=bytes1('3');
        elements["L"] = Element({name: "Erawan", parents: _parents3,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('l'));

        bytes1[] memory _parents4=new bytes1[](2);
        _parents4[0]=bytes1('2');
        _parents4[1]=bytes1('4');
        elements["E"] = Element({name: "Mandrake", parents: _parents4,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('E'));


        bytes1[] memory _parents5=new bytes1[](2);
        _parents5[0]=bytes1('1');
        _parents5[1]=bytes1('3');
        elements["D"] = Element({name: "Vethal", parents: _parents5,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('D'));


        bytes1[] memory _parents7=new bytes1[](2);
        _parents7[0]=bytes1('M');
        _parents7[1]=bytes1('3');
        elements["F"] = Element({name: "Anga", parents: _parents7,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('F'));


        bytes1[] memory _parents8=new bytes1[](2);
        _parents8[0]=bytes1('L');
        _parents8[1]=bytes1('4');
        elements["O"] = Element({name: "Titan", parents: _parents8,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('O'));

        bytes1[] memory _parents9=new bytes1[](2);
        _parents9[0]=bytes1('D');
        _parents9[1]=bytes1('2');
        elements["J"] = Element({name: "Wukong", parents: _parents9,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('J'));

        bytes1[] memory _parents10=new bytes1[](2);
        _parents10[0]=bytes1('E');
        _parents10[1]=bytes1('1');
        elements["H"] = Element({name: "Herbant", parents: _parents10,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('H'));

        bytes1[] memory _parents11=new bytes1[](2);
        _parents11[0]=bytes1('E');
        _parents11[1]=bytes1('D');
        elements["C"] = Element({name: "Flus", parents: _parents11,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('C'));

        bytes1[] memory _parents12=new bytes1[](2);
        _parents12[0]=bytes1('M');
        _parents12[1]=bytes1('L');
        elements["G"] = Element({name: "Lado", parents: _parents12,supply: 0,supplyMass:0, tier:2});
        elementIds.push(bytes1('G'));

        bytes1[] memory _parents13=new bytes1[](2);
        _parents13[0]=bytes1('C');
        _parents13[1]=bytes1('G');
        elements["N"] = Element({name: "Demon", parents: _parents13,supply: 0,supplyMass:0, tier:3});
        elementIds.push(bytes1('N'));

        bytes1[] memory _parents14=new bytes1[](2);
        _parents14[0]=bytes1('O');
        _parents14[1]=bytes1('H');
        elements["K"] = Element({name: "Deacon", parents: _parents14,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('K'));

        bytes1[] memory _parents15=new bytes1[](2);
        _parents15[0]=bytes1('F');
        _parents15[1]=bytes1('J');
        elements["I"] = Element({name: "Makara", parents: _parents15,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('I'));

        bytes1[] memory _parents16=new bytes1[](2);
        _parents16[0]=bytes1('N');
        _parents16[1]=bytes1('K');
        elements["A"] = Element({name: "Vamp", parents: _parents16,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('A'));

        bytes1[] memory _parents17=new bytes1[](2);
        _parents17[0]=bytes1('N');
        _parents17[1]=bytes1('I');
        elements["B"] = Element({name: "Dragon", parents: _parents17,supply: 0,supplyMass:0, tier:1});
        elementIds.push(bytes1('B')); 
    }

    function addToWhitelist(address[] memory toAdd) external onlyOwner {
        for (uint256 i = 0; i < toAdd.length; i++) {
            preMintAddresses[toAdd[i]] = basicElementPreMintCap;
            
        }
    }
   
    
    // Spit higher mass to one mass
    function split (uint256    _tokenId) external payable {
        require( _exists(_tokenId), "nonexistent token" );
        require(ownerOf(_tokenId)==msg.sender,"  token not owned");
        NFTDetails memory tokenDetails= tokenInfo[_tokenId];
        require(  tokenDetails.mass>= 2 , "low mass" );
        uint32 newImmunity=tokenDetails.immunity+1;  
        tokenInfo[_tokenId]=NFTDetails({elementId:tokenDetails.elementId, mass: 1, power:tokenDetails.power, immunity:newImmunity, experience:tokenDetails.experience});
        for (uint256 i = 1; i < tokenDetails.mass; i++) {
            _mintWithoutValidation(msg.sender, tokenDetails.elementId, 1,tokenDetails.power,newImmunity,tokenDetails.experience);
        }  
        addElementSupply(tokenDetails.elementId,(tokenDetails.mass-1),0,false,false);
        // No Change in Supply Mass
    }
    // Split NFT into parent NFTs
    function fision (uint256 _tokenId ) external payable {
        require( _exists(_tokenId), "nonexistent token" );
        require(ownerOf(_tokenId)==msg.sender,"  token not owned");
        NFTDetails memory tokenDetails= tokenInfo[_tokenId];
        require( elements[tokenDetails.elementId].parents.length>0, "should not be a base element" );
        //Adjust Mass
        addElementSupply(tokenDetails.elementId,1, tokenDetails.mass,true,true );
        addElementSupply(elements[tokenDetails.elementId].parents[0],1, tokenDetails.mass,false,false);
        tokenInfo[_tokenId]=NFTDetails({elementId:elements[tokenDetails.elementId].parents[0], mass: tokenDetails.mass, power:tokenDetails.power, immunity:tokenDetails.immunity+1, experience:tokenDetails.experience});
        for (uint256 i = 1; i < elements[tokenDetails.elementId].parents.length; i++) {
            addElementSupply(elements[tokenDetails.elementId].parents[i],1, tokenDetails.mass,false,false);
            _mintWithoutValidation(msg.sender, elements[tokenDetails.elementId].parents[i] , tokenDetails.mass,tokenDetails.power, tokenDetails.immunity+1, tokenDetails.experience);
        }
    }
    // Adjust Supply on every action
    function addElementSupply(bytes1 elementId, uint32 supply, uint32 supplyMass ,bool subSupply, bool subMass ) private {
        if(supply!=0){
            if(subSupply){
                require(elements[elementId].supply>=supply,"wrong supply");
                elements[elementId].supply-=supply;
            }else{
                elements[elementId].supply+=supply;
            }
        }
         if(supplyMass!=0){
            if(subMass){
                require(elements[elementId].supplyMass>=supplyMass,"wrong supplyMass");
                elements[elementId].supplyMass-=supplyMass;
            }else{
                elements[elementId].supplyMass+=supplyMass;
            } 
        }
    }
    // Combine Same Elements to increase mass
    function combine (uint256[]  memory  _tokenIds, uint256    _burnTokenId) external payable {
        require(_tokenIds.length>1,"atleast 2 elements required");
        require(_tokenIds.length<=10,"can't combine more than 10 elements");
        require(!hasDuplicates(_tokenIds,_burnTokenId),"duplicates tokens");
        if(_burnTokenId>0){
            require(_exists(_burnTokenId),"burn token not exist");
            require(ownerOf(_burnTokenId)==msg.sender,"burn token not owned");
        }
        bytes1 _resultElementId=tokenInfo[_tokenIds[0]].elementId;
        uint32 newMass=0;
        uint32 newPower=0;  
        uint32 newImmunity=0;  
        uint32 newExperience=0;
        for (uint256 i = 0; i < _tokenIds.length; i++) {
            require(_exists(_tokenIds[i]),"token not exist");
            require(ownerOf(_tokenIds[i])==msg.sender,"token not owned");
            NFTDetails memory tokenDetails= tokenInfo[_tokenIds[i]];
            require(tokenDetails.elementId==_resultElementId,"all should be same element"); 
            newMass+=tokenDetails.mass;
            newPower+=(tokenDetails.power*tokenDetails.mass);
            newImmunity+=(tokenDetails.immunity*tokenDetails.mass);
            newExperience+=(tokenDetails.experience*tokenDetails.mass);
        }
        newPower=(newPower/newMass)+1;  
        newImmunity=newImmunity/newMass;  
        newExperience=newExperience/newMass;
        // Burn all tokens
        if(_burnTokenId>0){
            //mass of burn id is greater than one
            if(tokenInfo[_burnTokenId].mass>1){
                tokenInfo[_burnTokenId].mass-=1;
                addElementSupply(tokenInfo[_burnTokenId].elementId,0,1,false,true);
            }else{ // burn token id mass is one
                addElementSupply(tokenInfo[_burnTokenId].elementId,1,1, true, true);
                _burnToken(_burnTokenId);
            }
            addElementSupply(_resultElementId,uint32(_tokenIds.length-1),0, true, false);
        }else{
            newMass-=1;
            require(newMass<=1,"add more elements to combine");
            addElementSupply(_resultElementId,uint32(_tokenIds.length-1),1, true, true);
        }
        for (uint256 i = 1; i < _tokenIds.length; i++) {
             _burnToken(_tokenIds[i]);
        }
        tokenInfo[_tokenIds[0]]=NFTDetails({elementId:_resultElementId, mass: newMass, power:newPower, immunity:newImmunity, experience:newExperience});
    }

 
    // Check duplicates
     function hasDuplicates(uint256[] memory _tokenIds,uint256 _burnTokenId) internal pure returns (bool) {
          for (uint256 i = 0; i < _tokenIds.length; i++) {
              for (uint256 j = i+1; j < _tokenIds.length; j++) {
                  if(_tokenIds[i]==_tokenIds[j]){
                      return true;
                  }
              }
              if(_burnTokenId>0 && _tokenIds[i]==_burnTokenId){
                      return true;
              }
          }
          return false;
     }
    
    
    // Combine nfts to create higher tier NFts
    function fusion (uint256[] memory _tokenIds, string memory __resultId, uint32 _resultMass, uint256 _burnTokenId) external payable {
        require(_tokenIds.length>1 
                && bytes(__resultId).length==1
                && _resultMass>0
                && _burnTokenId>0 , "tokens requiremnt not met" );
        bytes1 _resultId= bytes1( bytes(__resultId) );
        require(elements[_resultId].parents.length>1,"result token should not be a base element");
        require(ownerOf(_burnTokenId)==msg.sender,"burn token not owned");
        require(!hasDuplicates(_tokenIds,_burnTokenId),"duplicate tokens");
        uint32[] memory massToBurn  =new uint32[](_tokenIds.length) ; // Mass to burn for each token
        uint32[] memory massRequired =new uint32[](elements[_resultId].parents.length) ; // To Check enough elements added
        
        for (uint256 i = 0; i < _tokenIds.length; i++) {
             require(_exists(_tokenIds[i]),"token not exist");
             require(ownerOf(_tokenIds[i])==msg.sender,"token not owned");
             NFTDetails memory tokenDetails= tokenInfo[_tokenIds[i]];
            for (uint256 j = 0; j < elements[_resultId].parents.length; j++) {
                 
                if(elements[_resultId].parents[j]==tokenDetails.elementId  // incoming token contains required element 
                    && massRequired[j]<_resultMass){ // required mass not meet
                       
                        uint32 newMassRequirement=_resultMass-massRequired[j];
                        
                        if(tokenDetails.mass<=newMassRequirement){ // dont have enough mass or equal
                            massRequired[j]+=tokenDetails.mass;
                            massToBurn[i]+=tokenDetails.mass;
                        }else{
                            massRequired[j]+=newMassRequirement;
                            massToBurn[i]+=newMassRequirement;
                        }
                    }
             }
        }
         
        //Check input tokens have enough mass
        for (uint256 j = 0; j < elements[_resultId].parents.length; j++) {
             require(massRequired[j]==_resultMass, "mass requirement not met"); 
        }
        
        uint32 massBurned=0; 
        uint32 powerBurned=0;  
        uint32 immunityBurned=0;  
        uint32 experienceBurned=0;
        // Burn Parents and Mint if there is additional mass
         for (uint256 i = 0; i < _tokenIds.length; i++) {
             NFTDetails memory tokenDetails= tokenInfo[_tokenIds[i]];
             if(massToBurn[i]>0 ){
                 if(tokenDetails.mass>massToBurn[i]){
                     
                     tokenInfo[_tokenIds[i]].mass=tokenDetails.mass-massToBurn[i];
                     addElementSupply(tokenDetails.elementId,0,  massToBurn[i], false, true);
                      
                 }else{
                     addElementSupply(tokenDetails.elementId, 1,  massToBurn[i], true, true);
                     _burnToken(_tokenIds[i]);
                 }
                 massBurned+=massToBurn[i];
                 powerBurned+=(tokenDetails.power*massToBurn[i]);
                 immunityBurned+=(tokenDetails.immunity*massToBurn[i]);
                 experienceBurned+=(tokenDetails.experience*massToBurn[i]);

             }
         }
         // Burn Burn Element
          NFTDetails memory burnTokenDetails= tokenInfo[_burnTokenId];
          if(burnTokenDetails.mass>1){
                tokenInfo[_burnTokenId].mass-=1;
                addElementSupply(burnTokenDetails.elementId,0, 1, false, true);
          }else{
                addElementSupply(burnTokenDetails.elementId, 1, 1, true, true);
                _burnToken(_burnTokenId);
                
          }

          powerBurned =(powerBurned/massBurned)+1;
          immunityBurned=immunityBurned/massBurned;
          experienceBurned=experienceBurned/massBurned;

          // Mint result NFT
          _mintWithoutValidation(msg.sender, _resultId, _resultMass,powerBurned, immunityBurned, experienceBurned);
          addElementSupply(_resultId,1,_resultMass, false, false);
    }  
    
    function stringToBytes1(string memory source) public pure returns (bytes1  result) {
    bytes memory tempEmptyStringTest = bytes(source);
    if (tempEmptyStringTest.length == 0) {
        return 0x0;
    }

    assembly {
        result := mload(add(source, 1))
    }
}

    function mint (string[] memory _elements, uint8[] memory _mass) external payable {
        require(mintingStage>0, "premint/public mint not active" );
        require(_elements.length == _mass.length, "wrong elements/mass" );
        uint32 totalWeight=0;
        // Additional Validation
        for (uint256 i = 0; i < _elements.length; i++) {
             bytes1   elementId= bytes1( bytes(_elements[i]) );
            // Can Mint only Basic Elements
            require(elements[elementId].parents.length==0,   " Not a basic Element" );
            // Check Basic Elements Supply Cap : [ if parents is null, its a basic element]
             require(basicElementMintedCount[elementId]  + _mass[i] <= basicElementSupplyCap, "supply cap" );
            //changed to 
           // require(basicElementMintedCount[elementId]  + _mass[i] <= elements[elementId].totalSupply, "supply cap" );
            totalWeight+=_mass[i];
        }
        require( totalWeight >0, "No elements selected" );
        if(mintingStage==1){ // Is freemint
            //Check Whitelist
            require( totalWeight <= preMintAddresses[msg.sender], "WL Alloc Cap" );
        }else {
            if(mintingStage==2){ //Is Pre Mint
                
                require( totalWeight <= preMintAddresses[msg.sender], "WL Alloc Cap" );
            
            }else if(mintingStage==3){ //Is public Mint
                // do nothing
            }
            // Check payable amount
            require( totalWeight * mintPrice <= msg.value, "amount low" );
        }

        // Check max mint per transaction
        require(totalWeight<=basicElementPreMintCap, "user mint cap" );

        // --------- START MINTING -------------------
        if(mintingStage<=2){ // Is premint
            preMintAddresses[msg.sender] -= totalWeight;
        }else if(mintingStage==3){ // Is public Mint
            
        }
        for (uint256 i = 0; i < _elements.length; i++) {
            bytes1   elementId= bytes1( bytes(_elements[i]) );
            // For basic element mint Count
            basicElementMintedCount[elementId]+=_mass[i];
             addElementSupply(elementId,1,_mass[i], false, false);
            _mintWithoutValidation(msg.sender,elementId,_mass[i],_randomRarity(uint(_mass[i])),_randomRarity(uint(_mass[i])),0);
        }
       
     }

    
    function _randomRarity(uint checks) private returns (uint32){
        uint totalR=0;
        for(uint i=0;i<checks;i++){
            totalR+=uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, randNonce++))) %  (raritykeys.length);
        }
        if(checks>1){
            totalR=totalR/checks;
        }
        return raritykeys[totalR]  ;
    }
    
    function _getArtWeight(  uint32 mass, uint32 power,  uint32 immunity) private view  returns (uint256){
       uint256 totalWeight= (mass+power+immunity)/artLevelWeight;
       if(totalWeight<maxLevelWeight){
           return totalWeight;
       }else{
           return maxLevelWeight;
       }
    }

    function _burnToken(uint256 tokenId  ) internal {
        delete tokenInfo[tokenId] ;
        _burn(tokenId );
    }

    function _mintWithoutValidation(address to, bytes1 elementId, uint32 mass, uint32 power,  uint32 immunity,  uint32 experience) internal {
        // Element Should Exist
        require(elementExists(elementId), "Element Not Exists");
        // Add token Count
        lastTokenId++;
        // Add token metadata
        tokenInfo[lastTokenId]=NFTDetails({elementId:elementId, mass: mass, power:power, immunity:immunity, experience:experience});
        // Mint
        _safeMint(to, lastTokenId);
        emit Mint(to, lastTokenId);
    }
 

    function tokenURI(uint256 tokenId) public view  virtual  override  returns (string memory)
    {
        require( _exists(tokenId), "nonexistent token" );
        require( bytes(baseURI).length >0,"baseuri error");
        return  Meta.getMeta(tokenId,_getArtWeight( tokenInfo[tokenId].mass, tokenInfo[tokenId].power, tokenInfo[tokenId].immunity) , tokenInfo[tokenId],elements[tokenInfo[tokenId].elementId],externalURI,baseURI);
    }


  

    // Update Elements Master error
    function addNftElement(
        string memory _elementId,
        string memory _elementName,
        string[] memory _parents,
        uint8 tier
    ) external onlyOwner {
        bytes1   elementId= bytes1( bytes(_elementId) );
        require( !elementExists(elementId), "Exist" );
        bytes1[]  memory parents =new  bytes1[](_parents.length);
        for(uint i=0;i<_parents.length;i++){
            parents[0]= (bytes1( bytes(_parents[i]) ));
        }
        elements[elementId] = Element({name: bytes(_elementName), parents: parents, supply:0, supplyMass:0, tier:tier});
        elementIds.push(elementId);
    }
    function updateNftElement(
        string memory _elementId,
        string memory _elementName,
        string[] memory _parents,
        uint8 tier
    ) external onlyOwner {
         bytes1   elementId= bytes1( bytes(_elementId) );
        require( elementExists(elementId), "Not Exist" );
        bytes1[] memory parents=new  bytes1[](_parents.length);
        for(uint i=0;i<_parents.length;i++){
            bytes1   parentId=bytes1( bytes(_parents[i]) );
            require( elementExists(parentId), "Not Exist" );
            parents[i]=parentId;
        }
        elements[elementId].name =bytes(_elementName);
        elements[elementId].parents =parents; 
        elements[elementId].tier =tier; 
    }
    // Other basic Utilities
    function walletOfOwner(address _owner) public view returns (uint256[] memory) {
        uint256 ownerTokenCount = balanceOf(_owner);
        uint256[] memory tokenIds = new uint256[](ownerTokenCount);
        for (uint256 i; i < ownerTokenCount; i++) {
            tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokenIds;
    }
    function setBaseURI(string memory _newURI,bool  isExternal) public onlyOwner {
        if(isExternal){
            externalURI=_newURI;
        }else{
            baseURI = _newURI;
        }
        
    }
    function setCost(uint256   _newCost) public onlyOwner {
        mintPrice = _newCost;
    }
    function setLevelWeight( uint32 _artLevelWeight,uint32 _maxLevelWeight) public onlyOwner {
        if(_artLevelWeight>0){
            artLevelWeight = _artLevelWeight;
        }
        if(_maxLevelWeight>0){
            maxLevelWeight = _maxLevelWeight;
        }
    }
    function setSupplyCap(uint32 _basicElementSupplyCap ) public onlyOwner {
          basicElementSupplyCap =_basicElementSupplyCap;
    }
    function setMintCap(  uint32 _basicElementPreMintCap) public onlyOwner {  
      basicElementPreMintCap = _basicElementPreMintCap;
    }
    function setMintingStage(uint8   _stage) public onlyOwner {
        mintingStage = _stage;
    }
    function elementExists(bytes1  _elementId) internal view returns (bool ){
        bool doesListContainElement = false;
        for (uint i=0; i < elementIds.length; i++) {
            if (_elementId == elementIds[i]) {
                doesListContainElement = true;
            }
        }
        return doesListContainElement;
    }

 

    function withdraw() public payable onlyOwner {
        require(payable(msg.sender).send(address(this).balance));
    }

    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override{
        super._beforeTokenTransfer(from, to, tokenId);
        if(to!=address(0) && from!=address(0)){
             tokenInfo[tokenId].experience+=1;
        }
    }
 
}



IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

    /**
     * @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);
}
meta.sol 141 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

import {Base64} from "./base64.sol";
struct NFTDetails {
        bytes1 elementId;
        uint32 mass;
        uint32 immunity;
        uint32 power;
        uint32 experience;
    }

struct Element {
        bytes name;
     
        bytes1[] parents;
        uint32 supply;
        uint32 supplyMass;
        uint8 tier;
    }

library Meta {

    string public constant description= "The Game of Building, Fighting and Owning Powerful Creatures on 'Planet EO'.";

    function getMeta(uint256 tokenId,uint256 artWeight, NFTDetails memory metadata, Element memory element, string memory external_url, string memory meta_url) public pure returns (string memory) {
        bytes memory byteString  = abi.encodePacked("{");
        
        byteString = abi.encodePacked(
          byteString,
          _pushJsonStringAttribute("name", string(abi.encodePacked(string(element.name),' [',toString(metadata.mass),'] #', toString(tokenId)))  , true));
        byteString = abi.encodePacked(
          byteString,
          _pushJsonStringAttribute("description",string( description)  , true));
        byteString = abi.encodePacked(
          byteString,
          _pushJsonStringAttribute("external_url",string(external_url)  , true));

        // Image URls
        bytes memory elementFileName=isLowerCase(metadata.elementId)?abi.encodePacked("_",metadata.elementId):abi.encodePacked(metadata.elementId);
        string memory parameters=string(abi.encodePacked(
                "element=",elementFileName,
                "&experience=",toString(metadata.experience),
                "&mass=",toString(metadata.mass),
                "&immunity=",toString(metadata.immunity),
                "&power=",toString(metadata.power),
                "&level=",toString(artWeight),
                "&tier=",toString(element.tier)));
          byteString = abi.encodePacked(
          byteString,
          _pushJsonStringAttribute("animation_url",string(abi.encodePacked(meta_url,"html/",elementFileName,".html?",  parameters))  , true));

         
       // elementFileName=abi.encodePacked( elementFileName,"-", toString(artWeight));
         
        byteString = abi.encodePacked(
          byteString,
          _pushJsonStringAttribute("image",string(abi.encodePacked(meta_url,"images/",elementFileName,"-", toString(artWeight),".png"))  , true));
              
        // Attributes
        byteString = abi.encodePacked(byteString,'"attributes": [' );
        byteString = abi.encodePacked(
            byteString,
            _pushJsonTraitNumber("Mass", toString(metadata.mass) , true));
        byteString = abi.encodePacked(
            byteString,
            _pushJsonTraitNumber("Immunity", toString(metadata.immunity) , true));
        byteString = abi.encodePacked(
            byteString,
            _pushJsonTraitNumber("Power", toString(metadata.power) , true));
        byteString = abi.encodePacked(
            byteString,
            _pushJsonTraitNumber("Experience", toString(metadata.experience) , true));
        byteString = abi.encodePacked(
            byteString,
            '{"trait_type":"Tier", "value":', toString(element.tier),  ', "display_type":"number"},');
        byteString = abi.encodePacked(
            byteString,
            _pushJsonTraitString("Tier Name",string( abi.encodePacked("Tier ",toString(element.tier)) ), false));
         byteString = abi.encodePacked(byteString,']}' );

         string memory base64Json = Base64.encode(byteString);
        return string(abi.encodePacked('data:application/json;base64,', base64Json));
        // return string(byteString);
    }

     

    function _getString(string memory _str) private pure returns (string memory){
        return string(abi.encodePacked(_str));
    }
    function _getField(string memory _str) private pure returns (string memory){
        return string(abi.encodePacked(_str));
    }
    function _pushJsonStringAttribute(string memory key, string memory value, bool insertComma) private pure returns (string memory) {
        return string(abi.encodePacked('"', key, '": "', value, '"', insertComma ? ',' : ''));
    }
    function _pushJsonTraitNumber(string memory trait_type, string memory trait_value, bool insertComma) private pure returns (string memory) {
        return string(abi.encodePacked(
            '{"trait_type":"', trait_type, '", "value":', trait_value,   insertComma ? '},' : '}'
            ));
    }
    function _pushJsonTraitString(string memory trait_type, string memory trait_value, bool insertComma) private pure returns (string memory) {
        return string(abi.encodePacked(
            '{"trait_type":"', trait_type, '", "value":"', trait_value, '"' , insertComma ? '},' : '}'
            ));
    }

    function isLowerCase(bytes1 _id) public pure returns(bool){
        bytes memory allowed = bytes("abcdefghijklmnopqrstuvwxyz"); 
        for(uint j=0; j<allowed.length; j++){
            if(_id==allowed[j] ){
                return true;
            }
        }
        return false;
    }

    function toString(uint256 value) internal pure returns (string memory) {

        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);
    }

 

}
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);
}
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);
            }
        }
    }
}
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;
    }
}

Read Contract

balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
basicElementMintedCount 0xb9599aa1 → uint32
elements 0x528bc6db → bytes, uint32, uint32, uint8
externalURI 0x5ecf091f → string
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
mintPrice 0x6817c76c → uint256
mintingStage 0x4fddc979 → uint8
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
preMintAddresses 0x073f0116 → uint256
stringToBytes1 0x66fe08a4 → bytes1
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenInfo 0xcc33c875 → bytes1, uint32, uint32, uint32, uint32
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]

Write Contract 22 functions

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

addNftElement 0xf1a311a9
string _elementId
string _elementName
string[] _parents
uint8 tier
addToWhitelist 0x7f649783
address[] toAdd
approve 0x095ea7b3
address to
uint256 tokenId
combine 0x234c0ae5
uint256[] _tokenIds
uint256 _burnTokenId
fision 0x894cfe69
uint256 _tokenId
fusion 0x8f2239f8
uint256[] _tokenIds
string __resultId
uint32 _resultMass
uint256 _burnTokenId
mint 0xcec10b80
string[] _elements
uint8[] _mass
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 0xb64b21ca
string _newURI
bool isExternal
setCost 0x44a0d68a
uint256 _newCost
setLevelWeight 0x17ea01e9
uint32 _artLevelWeight
uint32 _maxLevelWeight
setMintCap 0x3dae1a3a
uint32 _basicElementPreMintCap
setMintingStage 0x338e8d88
uint8 _stage
setSupplyCap 0x60a02e1d
uint32 _basicElementSupplyCap
split 0xdbceb005
uint256 _tokenId
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateNftElement 0xe657e723
string _elementId
string _elementName
string[] _parents
uint8 tier
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address