Address Contract Verified
Address
0xb336AE11e840E8D38D1453fD3D876cf4797F6716
Balance
2.2278 ETH
Nonce
1
Code Size
15016 bytes
Creator
0x017a906c...2102 at tx 0x63255eb5...3c9a30
Indexed Transactions
0
Contract Bytecode
15016 bytes
0x6080604052600436106102465760003560e01c8063715018a611610139578063a8fef4a7116100b6578063d0c4e7fb1161007a578063d0c4e7fb14610714578063d7f3d6af14610727578063e43082f714610747578063e858ad0314610767578063e985e9c514610787578063f2fde38b146107a757600080fd5b8063a8fef4a714610649578063ae5303dd1461069f578063b88d4fde146106bf578063c1aef4f2146106df578063c87b56dd146106f457600080fd5b80639246149b116100fd5780639246149b146105ce57806395d89b41146105e157806397254e55146105f657806399ac9afa14610609578063a22cb4651461062957600080fd5b8063715018a6146104e75780637b6dbcd0146104fc578063872f78071461051c5780638d92becd146105905780638da5cb5b146105b057600080fd5b80633ccfd60b116101c75780634f9ec9961161018b5780634f9ec9961461046c57806359242b6a146104745780636352211e146104875780636e569bee146104a757806370a08231146104c757600080fd5b80633ccfd60b146103a45780634128929b146103b957806342842e0e146103d95780634898fe8a146103f95780634f6ccce71461044c57600080fd5b806318160ddd1161020e57806318160ddd1461030f57806323b872dd1461032e57806329f021031461034e5780632eb4a7ab1461036e5780632f745c591461038457600080fd5b806301ffc9a71461024b57806306fdde0314610280578063081812fc146102a2578063095ea7b3146102da5780630f574ba7146102fc575b600080fd5b34801561025757600080fd5b5061026b610266366004612f87565b6107c7565b60405190151581526020015b60405180910390f35b34801561028c57600080fd5b506102956107d8565b6040516102779190613003565b3480156102ae57600080fd5b506102c26102bd366004613016565b61086a565b6040516001600160a01b039091168152602001610277565b3480156102e657600080fd5b506102fa6102f5366004613044565b610904565b005b6102fa61030a366004613016565b610a1a565b34801561031b57600080fd5b506008545b604051908152602001610277565b34801561033a57600080fd5b506102fa610349366004613070565b610beb565b34801561035a57600080fd5b506103206103693660046130b1565b610c1c565b34801561037a57600080fd5b5061032060105481565b34801561039057600080fd5b5061032061039f366004613044565b610c90565b3480156103b057600080fd5b506102fa610d26565b3480156103c557600080fd5b506103206103d4366004613044565b610d83565b3480156103e557600080fd5b506102fa6103f4366004613070565b610e14565b34801561040557600080fd5b50610419610414366004613016565b610e2f565b60405161027791908151815260208083015190820152604080830151908201526060918201519181019190915260800190565b34801561045857600080fd5b50610320610467366004613016565b610ee7565b6102fa610f7a565b6102fa610482366004613016565b611238565b34801561049357600080fd5b506102c26104a2366004613016565b611303565b3480156104b357600080fd5b506102fa6104c23660046130ce565b61137a565b3480156104d357600080fd5b506103206104e23660046130b1565b611455565b3480156104f357600080fd5b506102fa6114dc565b34801561050857600080fd5b506102fa6105173660046130b1565b611512565b34801561052857600080fd5b50610575610537366004613016565b6040805180820190915260008082526020820152506000908152600c6020908152604091829020825180840190935280548352600101549082015290565b60408051825181526020928301519281019290925201610277565b34801561059c57600080fd5b506102fa6105ab366004613119565b61155e565b3480156105bc57600080fd5b50600a546001600160a01b03166102c2565b6102fa6105dc36600461317b565b6115a6565b3480156105ed57600080fd5b5061029561176f565b6102fa61060436600461323d565b61177e565b34801561061557600080fd5b506102fa61062436600461330a565b6119e1565b34801561063557600080fd5b506102fa610644366004613353565b611a1e565b34801561065557600080fd5b5061026b610664366004613016565b60408051808201825260008082526020918201819052928352600c815291819020815180830190925280548252600101549101819052421090565b3480156106ab57600080fd5b506102fa6106ba3660046130ce565b611a29565b3480156106cb57600080fd5b506102fa6106da366004613388565b611af3565b3480156106eb57600080fd5b50610295611b25565b34801561070057600080fd5b5061029561070f366004613016565b611bb3565b6102fa610722366004613016565b611c92565b34801561073357600080fd5b506102fa610742366004613119565b611e42565b34801561075357600080fd5b506102fa610762366004613119565b611e8a565b34801561077357600080fd5b506102fa610782366004613016565b611ed2565b34801561079357600080fd5b5061026b6107a2366004613408565b611f01565b3480156107b357600080fd5b506102fa6107c23660046130b1565b611fde565b60006107d282612079565b92915050565b6060600080546107e790613441565b80601f016020809104026020016040519081016040528092919081815260200182805461081390613441565b80156108605780601f1061083557610100808354040283529160200191610860565b820191906000526020600020905b81548152906001019060200180831161084357829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166108e85760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061090f82611303565b9050806001600160a01b0316836001600160a01b0316141561097d5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084016108df565b336001600160a01b038216148061099957506109998133611f01565b610a0b5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016108df565b610a15838361209e565b505050565b6000818152600c6020908152604080832054808452600b8352928190208151608081018352815481526001820154938101939093526002810154918301829052600301546060830152610a7f5760405162461bcd60e51b81526004016108df9061347c565b8060200151341015610ad35760405162461bcd60e51b815260206004820181905260248201527f496e636f72726563742076616c75652073656e7420666f722072656e6577616c60448201526064016108df565b33610add84611303565b6001600160a01b031614610b335760405162461bcd60e51b815260206004820152601a60248201527f596f7520646f206e6f74206f776e207468697320746f6b656e2e00000000000060448201526064016108df565b6000838152600c60205260409020600101544290811115610b94576000826040015182610b6091906134bf565b60408051808201825286815260208082019384526000898152600c9091529190912090518155905160019091015550610be5565b6040808301516000868152600c60205291822060010154610bb591906134bf565b60408051808201825286815260208082019384526000898152600c90915291909120905181559051600190910155505b50505050565b610bf5338261210c565b610c115760405162461bcd60e51b81526004016108df906134d7565b610a158383836121db565b601254604051627eeac760e11b81526001600160a01b03838116600483015260006024830181905292169062fdd58e90604401602060405180830381865afa158015610c6c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d29190613528565b6000610c9b83611455565b8210610cfd5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016108df565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610d505760405162461bcd60e51b81526004016108df90613541565b6040514790339082156108fc029083906000818181858888f19350505050158015610d7f573d6000803e3d6000fd5b5050565b6000805b610d9084611455565b811015610e0a57610da46106648583610c90565b15610df85782600c6000610db88785610c90565b8152602001908152602001600020600001541415610df857600c6000610dde8684610c90565b8152602001908152602001600020600101549150506107d2565b80610e0281613576565b915050610d87565b5060009392505050565b610a1583838360405180602001604052806000815250611af3565b610e5a6040518060800160405280600081526020016000815260200160008152602001600081525090565b600a546001600160a01b03163314610e845760405162461bcd60e51b81526004016108df90613541565b6000828152600b6020908152604091829020825160808101845281548152600182015492810192909252600281015492820183905260030154606082015290610edf5760405162461bcd60e51b81526004016108df9061347c565b90505b919050565b6000610ef260085490565b8210610f555760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016108df565b60088281548110610f6857610f68613591565b90600052602060002001549050919050565b604080516080810182527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf5481527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d0546020808301919091527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d154928201929092527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d25460608201526001600052600d9091526000805160206139ec83398151915254601254600160a01b900460ff166110875760405162461bcd60e51b815260206004820152600e60248201526d2132ba309036b4b73a1037bb32b960911b60448201526064016108df565b600061109233610c1c565b116110cf5760405162461bcd60e51b815260206004820152600d60248201526c2737ba103132ba30903ab9b2b960991b60448201526064016108df565b808260600151116110f25760405162461bcd60e51b81526004016108df906135a7565b81513410156111135760405162461bcd60e51b81526004016108df906135cd565b336000908152600e602052604090205460ff16156111735760405162461bcd60e51b815260206004820152601b60248201527f416c726561647920636c61696d6564204265746120626f6e75732e000000000060448201526064016108df565b620f4240600061118383836134bf565b61118e9060016134bf565b90506000846040015160036111a39190613604565b6111ad90426134bf565b604080518082018252600180825260208083018581526000888152600c83528581209451855590519383019390935533808452600e90915292909120805460ff191690911790559091506112019083612386565b60016000818152600d6020526000805160206139ec833981519152805490919061122c9084906134bf565b90915550505050505050565b6000818152600c6020908152604080832054808452600b835292819020815160808101835281548152600182015493810193909352600281015491830182905260030154606083015261129d5760405162461bcd60e51b81526004016108df9061347c565b600a546001600160a01b03163314610b33578060200151341015610b335760405162461bcd60e51b815260206004820181905260248201527f496e636f72726563742076616c75652073656e7420666f722072656e6577616c60448201526064016108df565b6000818152600260205260408120546001600160a01b031680610edf5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b60648201526084016108df565b600a546001600160a01b031633146113a45760405162461bcd60e51b81526004016108df90613541565b6000858152600b6020526040902060028101546113d35760405162461bcd60e51b81526004016108df9061347c565b805485146113ed576000868152600b602052604090208590555b8060010154841461140d576000868152600b602052604090206001018490555b8060020154831461142d576000868152600b602052604090206002018390555b8060030154821461144d576000868152600b602052604090206003018290555b505050505050565b60006001600160a01b0382166114c05760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b60648201526084016108df565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b031633146115065760405162461bcd60e51b81526004016108df90613541565b61151060006123a0565b565b600a546001600160a01b0316331461153c5760405162461bcd60e51b81526004016108df90613541565b601180546001600160a01b0319166001600160a01b0392909216919091179055565b600a546001600160a01b031633146115885760405162461bcd60e51b81526004016108df90613541565b60128054911515600160a81b0260ff60a81b19909216919091179055565b600a546001600160a01b031633146115d05760405162461bcd60e51b81526004016108df90613541565b6000828152600b602090815260408083208151608081018352815481526001820154818501526002820154818401526003909101546060820152858452600d909252822054909150600082604001511161163c5760405162461bcd60e51b81526004016108df9061347c565b845161164890826134bf565b8260600151101561166b5760405162461bcd60e51b81526004016108df906135a7565b60005b855181101561144d57600061168686620f4240613604565b9050600061169484836134bf565b61169f9060016134bf565b905060008686604001516116b39190613604565b6116bd90426134bf565b9050604051806040016040528089815260200182815250600c600086856116e491906134bf565b8152602080820192909252604001600020825181559101516001909101558851611733908a908690811061171a5761171a613591565b6020026020010151858461172e91906134bf565b612386565b6000888152600d602052604081208054600192906117529084906134bf565b92505081905550505050808061176790613576565b91505061166e565b6060600180546107e790613441565b604080516080810182527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5cf5481527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d0546020808301919091527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d154828401527f72c6bfb7988af3a1efa6568f02a999bc52252641c659d85961ca3d372b57d5d2546060808401919091526001600052600d82526000805160206139ec8339815191525484513390921b6bffffffffffffffffffffffff19168284015284516014818403018152603483018087528151918501919091206054948802808501860190975287825294959194936118b59391928992899283929101908490808284376000920191909152505060105491508490506123f2565b6118f15760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b210383937b7b360991b60448201526064016108df565b818360600151116119145760405162461bcd60e51b81526004016108df906135a7565b82513410156119355760405162461bcd60e51b81526004016108df906135cd565b620f4240600061194584836134bf565b6119509060016134bf565b90506000856040015160026119659190613604565b61196f90426134bf565b604080518082018252600180825260208083018581526000888152600c90925293902091518255915191015590506119a73383612386565b60016000818152600d6020526000805160206139ec83398151915280549091906119d29084906134bf565b90915550505050505050505050565b600a546001600160a01b03163314611a0b5760405162461bcd60e51b81526004016108df90613541565b8051610d7f90600f906020840190612eb1565b610d7f338383612408565b600a546001600160a01b03163314611a535760405162461bcd60e51b81526004016108df90613541565b6000858152600b6020526040902060020154600111611aaa5760405162461bcd60e51b8152602060048201526013602482015272506c616e20616c72656164792065786973747360681b60448201526064016108df565b604080516080810182529485526020808601948552858201938452606086019283526000968752600b905290942092518355905160018301555160028201559051600390910155565b611afd338361210c565b611b195760405162461bcd60e51b81526004016108df906134d7565b610be5848484846124d7565b600f8054611b3290613441565b80601f0160208091040260200160405190810160405280929190818152602001828054611b5e90613441565b8015611bab5780601f10611b8057610100808354040283529160200191611bab565b820191906000526020600020905b815481529060010190602001808311611b8e57829003601f168201915b505050505081565b6000818152600260205260409020546060906001600160a01b0316611c335760405162461bcd60e51b815260206004820152603060248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526f3732bc34b9ba32b73a103a37b5b2b71760811b60648201526084016108df565b6000611c68611c418461250a565b600f604051602001611c54929190613623565b60405160208183030381529060405261267f565b905080604051602001611c7b9190613785565b60408051601f198184030181529190529392505050565b6000818152600b602090815260408083208151608081018352815481526001820154818501526002820154818401526003909101546060820152848452600d9092528220549091506000826040015111611cfe5760405162461bcd60e51b81526004016108df9061347c565b80826060015111611d215760405162461bcd60e51b81526004016108df906135a7565b600a546001600160a01b03163314611d54578151341015611d545760405162461bcd60e51b81526004016108df906135cd565b601254600160a81b900460ff1615611da15760405162461bcd60e51b815260206004820152601060248201526f14d85b195cc8185c99481c185d5cd95960821b60448201526064016108df565b6000611db084620f4240613604565b90506000611dbe83836134bf565b611dc99060016134bf565b90506000846040015142611ddd91906134bf565b60408051808201825288815260208082018481526000878152600c9092529290209051815590516001909101559050611e163383612386565b6000868152600d60205260408120805460019290611e359084906134bf565b9091555050505050505050565b600a546001600160a01b03163314611e6c5760405162461bcd60e51b81526004016108df90613541565b60128054911515600160a01b0260ff60a01b19909216919091179055565b600a546001600160a01b03163314611eb45760405162461bcd60e51b81526004016108df90613541565b60118054911515600160a01b0260ff60a01b19909216919091179055565b600a546001600160a01b03163314611efc5760405162461bcd60e51b81526004016108df90613541565b601055565b6011546000906001600160a01b03811690600160a01b900460ff168015611f9d575060405163c455279160e01b81526001600160a01b038581166004830152808516919083169063c455279190602401602060405180830381865afa158015611f6e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9291906137ca565b6001600160a01b0316145b15611fac5760019150506107d2565b6001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b949350505050565b600a546001600160a01b031633146120085760405162461bcd60e51b81526004016108df90613541565b6001600160a01b03811661206d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108df565b612076816123a0565b50565b60006001600160e01b0319821663780e9d6360e01b14806107d257506107d2826127e5565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906120d382611303565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166121855760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084016108df565b600061219083611303565b9050806001600160a01b0316846001600160a01b031614806121cb5750836001600160a01b03166121c08461086a565b6001600160a01b0316145b80611fd65750611fd68185611f01565b826001600160a01b03166121ee82611303565b6001600160a01b0316146122565760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b60648201526084016108df565b6001600160a01b0382166122b85760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016108df565b6122c3838383612835565b6122ce60008261209e565b6001600160a01b03831660009081526003602052604081208054600192906122f79084906137e7565b90915550506001600160a01b03821660009081526003602052604081208054600192906123259084906134bf565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b610d7f828260405180602001604052806000815250612840565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000826123ff8584612873565b14949350505050565b816001600160a01b0316836001600160a01b0316141561246a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016108df565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6124e28484846121db565b6124ee8484848461291f565b610be55760405162461bcd60e51b81526004016108df906137fe565b6000818152600c6020908152604091829020825180840190935280548352600101549082015260609061253b612f35565b604051806060016040528060318152602001613991603191398152815161256190612a1d565b81600160200201819052506040518060600160405280602a81526020016139c2602a91396040820152602082015161259890612a1d565b6060808301919091526040805191820190526027808252613a4c60208301396080820152602082015142116125ea576040518060400160405280600581526020016466616c736560d81b815250612608565b604051806040016040528060048152602001637472756560e01b8152505b60a0820190815260408051808201825260058152640113eae96160dd1b60208083019190915260c085018290528451818601518487015160608801516080890151975196516000986126669895979496939592949093909101613850565b60408051601f1981840301815291905295945050505050565b80516060908061269f575050604080516020810190915260008152919050565b600060036126ae8360026134bf565b6126b891906138f8565b6126c3906004613604565b905060006126d28260206134bf565b67ffffffffffffffff8111156126ea576126ea613134565b6040519080825280601f01601f191660200182016040528015612714576020820181803683370190505b5090506000604051806060016040528060408152602001613a0c604091399050600181016020830160005b868110156127a0576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b83526004909201910161273f565b5060038606600181146127ba57600281146127cb576127d7565b613d3d60f01b6001198301526127d7565b603d60f81b6000198301525b505050918152949350505050565b60006001600160e01b031982166380ac58cd60e01b148061281657506001600160e01b03198216635b5e139f60e01b145b806107d257506301ffc9a760e01b6001600160e01b03198316146107d2565b610a15838383612b1b565b61284a8383612bd3565b612857600084848461291f565b610a155760405162461bcd60e51b81526004016108df906137fe565b600081815b845181101561291757600085828151811061289557612895613591565b602002602001015190508083116128d7576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250612904565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b508061290f81613576565b915050612878565b509392505050565b60006001600160a01b0384163b15612a1257604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061296390339089908890889060040161390c565b6020604051808303816000875af192505050801561299e575060408051601f3d908101601f1916820190925261299b91810190613949565b60015b6129f8573d8080156129cc576040519150601f19603f3d011682016040523d82523d6000602084013e6129d1565b606091505b5080516129f05760405162461bcd60e51b81526004016108df906137fe565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611fd6565b506001949350505050565b606081612a415750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612a6b5780612a5581613576565b9150612a649050600a836138f8565b9150612a45565b60008167ffffffffffffffff811115612a8657612a86613134565b6040519080825280601f01601f191660200182016040528015612ab0576020820181803683370190505b5090505b8415611fd657612ac56001836137e7565b9150612ad2600a86613966565b612add9060306134bf565b60f81b818381518110612af257612af2613591565b60200101906001600160f81b031916908160001a905350612b14600a866138f8565b9450612ab4565b6001600160a01b038316612b7657612b7181600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612b99565b816001600160a01b0316836001600160a01b031614612b9957612b998382612d21565b6001600160a01b038216612bb057610a1581612dbe565b826001600160a01b0316826001600160a01b031614610a1557610a158282612e6d565b6001600160a01b038216612c295760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016108df565b6000818152600260205260409020546001600160a01b031615612c8e5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016108df565b612c9a60008383612835565b6001600160a01b0382166000908152600360205260408120805460019290612cc39084906134bf565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001612d2e84611455565b612d3891906137e7565b600083815260076020526040902054909150808214612d8b576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612dd0906001906137e7565b60008381526009602052604081205460088054939450909284908110612df857612df8613591565b906000526020600020015490508060088381548110612e1957612e19613591565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480612e5157612e5161397a565b6001900381819060005260206000200160009055905550505050565b6000612e7883611455565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b828054612ebd90613441565b90600052602060002090601f016020900481019282612edf5760008555612f25565b82601f10612ef857805160ff1916838001178555612f25565b82800160010185558215612f25579182015b82811115612f25578251825591602001919060010190612f0a565b50612f31929150612f5c565b5090565b6040518060e001604052806007905b6060815260200190600190039081612f445790505090565b5b80821115612f315760008155600101612f5d565b6001600160e01b03198116811461207657600080fd5b600060208284031215612f9957600080fd5b8135612fa481612f71565b9392505050565b60005b83811015612fc6578181015183820152602001612fae565b83811115610be55750506000910152565b60008151808452612fef816020860160208601612fab565b601f01601f19169290920160200192915050565b602081526000612fa46020830184612fd7565b60006020828403121561302857600080fd5b5035919050565b6001600160a01b038116811461207657600080fd5b6000806040838503121561305757600080fd5b82356130628161302f565b946020939093013593505050565b60008060006060848603121561308557600080fd5b83356130908161302f565b925060208401356130a08161302f565b929592945050506040919091013590565b6000602082840312156130c357600080fd5b8135612fa48161302f565b600080600080600060a086880312156130e657600080fd5b505083359560208501359550604085013594606081013594506080013592509050565b80358015158114610ee257600080fd5b60006020828403121561312b57600080fd5b612fa482613109565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561317357613173613134565b604052919050565b60008060006060848603121561319057600080fd5b833567ffffffffffffffff808211156131a857600080fd5b818601915086601f8301126131bc57600080fd5b81356020828211156131d0576131d0613134565b8160051b92506131e181840161314a565b828152928401810192818101908a8511156131fb57600080fd5b948201945b8486101561322557853593506132158461302f565b8382529482019490820190613200565b9a918901359950506040909701359695505050505050565b6000806020838503121561325057600080fd5b823567ffffffffffffffff8082111561326857600080fd5b818501915085601f83011261327c57600080fd5b81358181111561328b57600080fd5b8660208260051b85010111156132a057600080fd5b60209290920196919550909350505050565b600067ffffffffffffffff8311156132cc576132cc613134565b6132df601f8401601f191660200161314a565b90508281528383830111156132f357600080fd5b828260208301376000602084830101529392505050565b60006020828403121561331c57600080fd5b813567ffffffffffffffff81111561333357600080fd5b8201601f8101841361334457600080fd5b611fd6848235602084016132b2565b6000806040838503121561336657600080fd5b82356133718161302f565b915061337f60208401613109565b90509250929050565b6000806000806080858703121561339e57600080fd5b84356133a98161302f565b935060208501356133b98161302f565b925060408501359150606085013567ffffffffffffffff8111156133dc57600080fd5b8501601f810187136133ed57600080fd5b6133fc878235602084016132b2565b91505092959194509250565b6000806040838503121561341b57600080fd5b82356134268161302f565b915060208301356134368161302f565b809150509250929050565b600181811c9082168061345557607f821691505b6020821081141561347657634e487b7160e01b600052602260045260246000fd5b50919050565b602080825260139082015272141b185b88191bd95cc81b9bdd08195e1a5cdd606a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082198211156134d2576134d26134a9565b500190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60006020828403121561353a57600080fd5b5051919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060001982141561358a5761358a6134a9565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6020808252600c908201526b4f7574206f662073746f636b60a01b604082015260600190565b6020808252601d908201527f496e636f72726563742076616c75652073656e7420666f72206d696e74000000604082015260600190565b600081600019048311821515161561361e5761361e6134a9565b500290565b7f7b226e616d65223a20224d657461736e697065722041636365737320546f6b658152600060207f6e222c20226465736372697074696f6e223a202241636365737320746f204d65818401527f7461736e69706572207072697661746520636f6d6d756e69747920616e64207460408401526537b7b639971160d11b606084015284516136b68160668601848901612fab565b691134b6b0b3b2911d101160b11b6066918501918201528454607090600090600181811c90808316806136ea57607f831692505b87831081141561370857634e487b7160e01b85526022600452602485fd5b80801561371c576001811461373157613762565b60ff1985168888015283880187019550613762565b60008c81526020902060005b858110156137585781548a82018a0152908401908a0161373d565b5050868489010195505b50505050506137798161227d60f01b815260020190565b98975050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516137bd81601d850160208701612fab565b91909101601d0192915050565b6000602082840312156137dc57600080fd5b8151612fa48161302f565b6000828210156137f9576137f96134a9565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000885160206138638285838e01612fab565b8951918401916138768184848e01612fab565b89519201916138888184848d01612fab565b885192019161389a8184848c01612fab565b87519201916138ac8184848b01612fab565b86519201916138be8184848a01612fab565b85519201916138d08184848901612fab565b919091019a9950505050505050505050565b634e487b7160e01b600052601260045260246000fd5b600082613907576139076138e2565b500490565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061393f90830184612fd7565b9695505050505050565b60006020828403121561395b57600080fd5b8151612fa481612f71565b600082613975576139756138e2565b500690565b634e487b7160e01b600052603160045260246000fdfe2c202261747472696275746573223a205b7b2274726169745f74797065223a202254696572222c2276616c7565223a2022227d2c207b2274726169745f74797065223a202245787069726174696f6e222c2276616c7565223a2022fd54ff1ed53f34a900b24c5ba64f85761163b5d82d98a47b9bd80e45466993c54142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f227d2c207b2274726169745f74797065223a202245787069726564222c2276616c7565223a2022a2646970667358221220bfbd1ecbc644dbb1c2adacba580acd7cdebceceb9108fdcef36a19fc0c4d01f564736f6c634300080b0033
Verified Source Code Full Match
Compiler: v0.8.11+commit.d7f03943
EVM: london
Optimization: Yes (200 runs)
MetaSniper.sol 487 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
interface IAccessToken {
function balanceOf(address account, uint256 id) external view returns (uint256);
}
// These contract definitions are used to create a reference to the OpenSea
// ProxyRegistry contract by using the registry's address (see isApprovedForAll).
contract OwnableDelegateProxy {
}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
contract Metasniper is ERC721, ERC721Enumerable, Ownable {
struct SubscriptionPlan {
uint256 price;
uint256 renewalFee;
uint256 duration;
uint256 maxSubscribers;
}
struct ActiveSubscriptions {
uint256 tier;
uint256 Expiration;
}
mapping(uint256 => SubscriptionPlan) subscriptionPlans; // tier => plan
mapping(uint256 => ActiveSubscriptions) subscriptionExpiration; //token => subscription
mapping(uint256 => uint256) mintedTokens; //token index
mapping(address => bool) betaBonusClaimed;
string public tokenImage = "https://ipfs.io/ipfs/QmeLdHLV4g77MtqFgGAf9XC3E9qewqkhkg3s3BbePyMHD4";
bytes32 public merkleRoot = 0x33fea67cf00c8c26877d7a9a4e31aa3e33a8d9b47c2346dbc6c4fea8ad288a0e;
address private openSeaProxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1;
bool private isOpenSeaProxyActive = true;
address betaAccessToken = 0xD060910aDa4e41e74920901FbEc6e4E19EF37F9c;
bool BETA_MINT = false;
bool SALES_PAUSED = true;
constructor(string memory name, string memory symbol) ERC721(name, symbol) {
subscriptionPlans[0] = SubscriptionPlan(
0.01 ether,
0.01 ether,
100,
1
);
subscriptionPlans[1] = SubscriptionPlan(
0.25 ether,
0.0888 ether,
30 days,
300
);
}
function getBetaTokenCount (address _address) public view returns (uint256) {
return IERC1155(betaAccessToken).balanceOf(_address, 0);
}
// Create a new plan
function newSubscriptionPlan(
uint256 _tier,
uint256 _price,
uint256 _renewalFee,
uint256 _duration,
uint256 _maxSubscribers
) public onlyOwner {
require(subscriptionPlans[_tier].duration < 1, "Plan already exists");
subscriptionPlans[_tier] = SubscriptionPlan(
_price,
_renewalFee,
_duration,
_maxSubscribers
);
}
// Edit a existing plan
function editSubscriptionPlan(
uint256 _tier,
uint256 _price,
uint256 _renewalFee,
uint256 _duration,
uint256 _maxSubscribers
) public onlyOwner {
SubscriptionPlan storage plan = subscriptionPlans[_tier];
require(plan.duration > 0, "Plan does not exist");
if (_price != plan.price) {
subscriptionPlans[_tier].price = _price;
}
if (_renewalFee != plan.renewalFee) {
subscriptionPlans[_tier].renewalFee = _renewalFee;
}
if (_duration != plan.duration) {
subscriptionPlans[_tier].duration = _duration;
}
if (_maxSubscribers != plan.maxSubscribers) {
subscriptionPlans[_tier].maxSubscribers = _maxSubscribers;
}
}
function getSubscriptionExpiration(uint256 _tokenId)
public
view
returns (ActiveSubscriptions memory)
{
ActiveSubscriptions memory plan = subscriptionExpiration[_tokenId];
return plan;
}
function checkUserSub(address _user, uint256 _tier) public view returns (uint256){
for (uint256 i = 0; i < balanceOf(_user); i++) {
if (checkSubscription(tokenOfOwnerByIndex(_user, i))){
if (subscriptionExpiration[tokenOfOwnerByIndex(_user, i)].tier == _tier){
return subscriptionExpiration[tokenOfOwnerByIndex(_user, i)].Expiration;
}
}
}
return 0;
}
function getSubscriptionPlan(uint256 _tier)
public
view
onlyOwner
returns (SubscriptionPlan memory)
{
SubscriptionPlan memory plan = subscriptionPlans[_tier];
require(plan.duration > 0, "Plan does not exist");
return plan;
}
function subscribe(uint256 _tokenId) public payable {
uint256 _tier = subscriptionExpiration[_tokenId].tier;
SubscriptionPlan memory plan = subscriptionPlans[_tier];
require(plan.duration > 0, "Plan does not exist");
require(
msg.value >= plan.renewalFee,
"Incorrect value sent for renewal"
);
require(ownerOf(_tokenId) == msg.sender, "You do not own this token.");
uint256 startTimestamp = block.timestamp;
if (subscriptionExpiration[_tokenId].Expiration < startTimestamp) {
uint256 expiresTimestamp = startTimestamp + plan.duration;
subscriptionExpiration[_tokenId] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
} else {
uint256 expiresTimestamp = subscriptionExpiration[_tokenId]
.Expiration + plan.duration;
subscriptionExpiration[_tokenId] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
}
}
function giftSubscribe(uint256 _tokenId) public payable {
uint256 _tier = subscriptionExpiration[_tokenId].tier;
SubscriptionPlan memory plan = subscriptionPlans[_tier];
require(plan.duration > 0, "Plan does not exist");
if (msg.sender != owner()) {
require(
msg.value >= plan.renewalFee,
"Incorrect value sent for renewal"
);
}
uint256 startTimestamp = block.timestamp;
if (subscriptionExpiration[_tokenId].Expiration < startTimestamp) {
uint256 expiresTimestamp = startTimestamp + plan.duration;
subscriptionExpiration[_tokenId] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
} else {
uint256 expiresTimestamp = subscriptionExpiration[_tokenId]
.Expiration + plan.duration;
subscriptionExpiration[_tokenId] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
}
}
// Check if token is expired
function checkSubscription(uint256 _tokenId) public view returns (bool) {
ActiveSubscriptions memory plan = getSubscriptionExpiration(_tokenId);
return plan.Expiration > block.timestamp;
}
function getMintedCount(uint256 _tier) internal view returns (uint256) {
return mintedTokens[_tier];
}
function setSalePaused(bool _state) public onlyOwner {
SALES_PAUSED = _state;
}
function setBetaMint(bool _state) public onlyOwner {
BETA_MINT = _state;
}
function betaTokenMint() public payable {
SubscriptionPlan memory plan = subscriptionPlans[1];
uint256 mintedCount = getMintedCount(1);
require(BETA_MINT, "Beta mint over");
require(getBetaTokenCount(msg.sender) > 0, "Not beta user");
require(plan.maxSubscribers > mintedCount, "Out of stock");
require(msg.value >= plan.price, "Incorrect value sent for mint");
require(!betaBonusClaimed[msg.sender], "Already claimed Beta bonus.");
uint256 offset = 1000000;
uint256 tokenId = offset + mintedCount + 1;
uint256 expiresTimestamp = block.timestamp + (plan.duration * 3);
subscriptionExpiration[tokenId] = ActiveSubscriptions(
1,
expiresTimestamp
);
betaBonusClaimed[msg.sender] = true;
_safeMint(msg.sender, tokenId);
mintedTokens[1] += 1;
}
function whiteListMint(bytes32[] calldata _proof) public payable {
SubscriptionPlan memory plan = subscriptionPlans[1];
uint256 mintedCount = getMintedCount(1);
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
require(MerkleProof.verify(_proof, merkleRoot, leaf), "Invalid proof");
require(plan.maxSubscribers > mintedCount, "Out of stock");
require(msg.value >= plan.price, "Incorrect value sent for mint");
uint256 offset = 1000000;
uint256 tokenId = offset + mintedCount + 1;
uint256 expiresTimestamp = block.timestamp + (plan.duration * 2);
subscriptionExpiration[tokenId] = ActiveSubscriptions(
1,
expiresTimestamp
);
_safeMint(msg.sender, tokenId);
mintedTokens[1] += 1;
}
function mintNewToken(uint256 _tier) public payable {
SubscriptionPlan memory plan = subscriptionPlans[_tier];
uint256 mintedCount = getMintedCount(_tier);
require(plan.duration > 0, "Plan does not exist");
require(plan.maxSubscribers > mintedCount, "Out of stock");
if (msg.sender != owner()) {
require(msg.value >= plan.price, "Incorrect value sent for mint");
}
require(!SALES_PAUSED, "Sales are paused");
uint256 offset = 1000000 * _tier;
uint256 tokenId = offset + mintedCount + 1;
uint256 expiresTimestamp = block.timestamp + plan.duration;
subscriptionExpiration[tokenId] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
_safeMint(msg.sender, tokenId);
mintedTokens[_tier] += 1;
}
function adminMint(address[] memory tos_, uint256 _tier, uint256 _bonusTime) public payable onlyOwner{
SubscriptionPlan memory plan = subscriptionPlans[_tier];
uint256 mintedCount = getMintedCount(_tier);
require(plan.duration > 0, "Plan does not exist");
require(plan.maxSubscribers >= mintedCount + tos_.length, "Out of stock");
for (uint256 i = 0; i < tos_.length; i++) {
uint256 offset = 1000000 * _tier;
uint256 tokenId = offset + mintedCount + 1;
uint256 expiresTimestamp = block.timestamp + (plan.duration * _bonusTime);
subscriptionExpiration[tokenId + i] = ActiveSubscriptions(
_tier,
expiresTimestamp
);
_safeMint(tos_[i], tokenId + i);
mintedTokens[_tier] += 1;
}
}
function setmerkleRoot(bytes32 _root) external onlyOwner {
merkleRoot = _root;
}
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function updateTokenImage(string memory _url) public onlyOwner {
tokenImage = _url;
}
function updateOSReg(address _address) public onlyOwner {
openSeaProxyRegistryAddress = _address;
}
function getMetadata(uint256 _tokenId) internal view returns (string memory) {
ActiveSubscriptions memory plan = subscriptionExpiration[_tokenId];
string[7] memory parts;
parts[0] = ', "attributes": [{"trait_type": "Tier","value": "';
parts[1] = toString(plan.tier);
parts[2] = '"}, {"trait_type": "Expiration","value": "';
parts[3] = toString(plan.Expiration);
parts[4] = '"}, {"trait_type": "Expired","value": "';
parts[5] = plan.Expiration < block.timestamp ? "true" : "false";
parts[6] = '"}], ';
string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6]));
return output;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token."
);
string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Metasniper Access Token", "description": "Access to Metasniper private community and tools."', getMetadata(tokenId), '"image": "',tokenImage,'"}'))));
json = string(abi.encodePacked('data:application/json;base64,', json));
return json;
}
//required by Solidity
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, tokenId);
}
//required by Solidity
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721, ERC721Enumerable)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
/**
* @dev Override isApprovedForAll to allowlist user's OpenSea proxy accounts to enable gas-less listings.
*/
function isApprovedForAll(address owner, address operator)
public
view
override
returns (bool)
{
// Get a reference to OpenSea's proxy registry contract by instantiating
// the contract using the already existing address.
ProxyRegistry proxyRegistry = ProxyRegistry(
openSeaProxyRegistryAddress
);
if (
isOpenSeaProxyActive &&
address(proxyRegistry.proxies(owner)) == operator
) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
// function to disable gasless listings for security in case
// opensea ever shuts down or is compromised
function setIsOpenSeaProxyActive(bool _isOpenSeaProxyActive)
external
onlyOwner
{
isOpenSeaProxyActive = _isOpenSeaProxyActive;
}
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);
}
}
library Base64 {
bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return "";
// multiply by 4/3 rounded up
uint256 encodedLen = 4 * ((len + 2) / 3);
// Add some extra buffer at the end
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC721.sol 424 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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);
}
/**
* @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);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev 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 {}
}
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;
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
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);
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
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);
}
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();
}
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
balanceOf 0x70a08231 → uint256
checkSubscription 0xa8fef4a7 → bool
checkUserSub 0x4128929b → uint256
getApproved 0x081812fc → address
getBetaTokenCount 0x29f02103 → uint256
getSubscriptionExpiration 0x872f7807 → tuple
getSubscriptionPlan 0x4898fe8a → tuple
isApprovedForAll 0xe985e9c5 → bool
merkleRoot 0x2eb4a7ab → bytes32
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenImage 0xc1aef4f2 → string
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 22 functions
These functions modify contract state and require a wallet transaction to execute.
adminMint 0x9246149b
address[] tos_
uint256 _tier
uint256 _bonusTime
approve 0x095ea7b3
address to
uint256 tokenId
betaTokenMint 0x4f9ec996
No parameters
editSubscriptionPlan 0x6e569bee
uint256 _tier
uint256 _price
uint256 _renewalFee
uint256 _duration
uint256 _maxSubscribers
giftSubscribe 0x59242b6a
uint256 _tokenId
mintNewToken 0xd0c4e7fb
uint256 _tier
newSubscriptionPlan 0xae5303dd
uint256 _tier
uint256 _price
uint256 _renewalFee
uint256 _duration
uint256 _maxSubscribers
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
setBetaMint 0xd7f3d6af
bool _state
setIsOpenSeaProxyActive 0xe43082f7
bool _isOpenSeaProxyActive
setSalePaused 0x8d92becd
bool _state
setmerkleRoot 0xe858ad03
bytes32 _root
subscribe 0x0f574ba7
uint256 _tokenId
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateOSReg 0x7b6dbcd0
address _address
updateTokenImage 0x99ac9afa
string _url
whiteListMint 0x97254e55
bytes32[] _proof
withdraw 0x3ccfd60b
No parameters
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address