Address Contract Verified
Address
0xFfBC81170340Cc12444615E14A39Cc4240244a9C
Balance
0 ETH
Nonce
1
Code Size
24448 bytes
Creator
0x7e6A7400...2bF9 at tx 0x98b5cdd3...6a785c
Indexed Transactions
0
Contract Bytecode
24448 bytes
0x6080604052600436106102385760003560e01c8062fdd58e1461023d57806301ffc9a71461027057806302fe5305146102a0578063065eb117146102c257806306fdde03146102e25780630e89341c1461030457806313af40351461032457806319b88edb14610344578063227f951c14610364578063248a9ca3146103845780632eb2c2d6146103a45780632f2ff15d146103c457806336568abe146103e45780633a4da729146104045780633aeca210146104245780633f4ba83a146104445780634044556d1461045957806345301760146104795780634e1273f4146104995780634f558e79146104c65780634f64b2be146104e6578063522f68151461051a578063589b21621461053a5780635c975abb1461054f5780636b20c454146105675780637076574614610587578063715018a61461059a5780637d737203146105af5780638456cb59146105cf5780638da5cb5b146105e457806391d1485414610606578063938e3d7b1461062657806395d89b4114610646578063a217fddf1461065b578063a22cb46514610670578063a8afbca114610690578063af17dea6146106b0578063bd85b039146106c5578063c0e72740146106e5578063d547741f146106fa578063d5ebd7881461071a578063d6b15c4c1461073a578063d81d0a151461075a578063dd66489e1461077a578063e2b9e1861461079a578063e8a3d485146107af578063e985e9c5146107c4578063f242432a1461080d578063f2fde38b1461082d578063f5298aca1461084d575b600080fd5b34801561024957600080fd5b5061025d610258366004614deb565b61086d565b6040519081526020015b60405180910390f35b34801561027c57600080fd5b5061029061028b36600461500c565b610909565b6040519015158152602001610267565b3480156102ac57600080fd5b506102c06102bb366004615044565b610914565b005b3480156102ce57600080fd5b506102c06102dd366004615172565b61094f565b3480156102ee57600080fd5b506102f761097f565b6040516102679190615782565b34801561031057600080fd5b506102f761031f366004614fd0565b610a11565b34801561033057600080fd5b506102c061033f366004614a7c565b610b68565b34801561035057600080fd5b5061025d61035f366004614fd0565b610ba0565b34801561037057600080fd5b5061025d61037f366004614d2f565b610bd5565b34801561039057600080fd5b5061025d61039f366004614fd0565b610d02565b3480156103b057600080fd5b506102c06103bf366004614afb565b610d17565b3480156103d057600080fd5b506102c06103df366004614fe8565b610dae565b3480156103f057600080fd5b506102c06103ff366004614fe8565b610dd0565b34801561041057600080fd5b506102c061041f366004615194565b610e4e565b34801561043057600080fd5b506102c061043f366004614dfd565b610ee1565b34801561045057600080fd5b506102c0610f82565b34801561046557600080fd5b50610290610474366004614fd0565b610fbb565b34801561048557600080fd5b506102c0610494366004615076565b61100e565b3480156104a557600080fd5b506104b96104b4366004614eb2565b611052565b6040516102679190615741565b3480156104d257600080fd5b506102906104e1366004614fd0565b6111b3565b3480156104f257600080fd5b50610506610501366004614fd0565b6111c6565b604051610267989796959493929190615795565b34801561052657600080fd5b506102c0610535366004614a98565b611458565b34801561054657600080fd5b506102f76114bd565b34801561055b57600080fd5b5060045460ff16610290565b34801561057357600080fd5b506102c0610582366004614c89565b611547565b6102c0610595366004614f12565b61158a565b3480156105a657600080fd5b506102c0611fae565b3480156105bb57600080fd5b506102c06105ca3660046153c6565b611fe7565b3480156105db57600080fd5b506102c061201e565b3480156105f057600080fd5b506105f9612055565b6040516102679190615695565b34801561061257600080fd5b50610290610621366004614fe8565b612064565b34801561063257600080fd5b506102c0610641366004615044565b61208d565b34801561065257600080fd5b506102f76120ac565b34801561066757600080fd5b5061025d600081565b34801561067c57600080fd5b506102c061068b366004614cfb565b6120bb565b34801561069c57600080fd5b506102c06106ab3660046152ca565b612192565b3480156106bc57600080fd5b506102f76122db565b3480156106d157600080fd5b5061025d6106e0366004614fd0565b612369565b3480156106f157600080fd5b506102f761237b565b34801561070657600080fd5b506102c0610715366004614fe8565b612388565b34801561072657600080fd5b506102c061073536600461522e565b6123a5565b34801561074657600080fd5b5061025d610755366004614e31565b6123e6565b34801561076657600080fd5b506102c0610775366004614c0a565b612921565b34801561078657600080fd5b506102c0610795366004615262565b6129b1565b3480156107a657600080fd5b506102f7612a66565b3480156107bb57600080fd5b506102f7612a73565b3480156107d057600080fd5b506102906107df366004614ac3565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205460ff1690565b34801561081957600080fd5b506102c0610828366004614ba4565b612a82565b34801561083957600080fd5b506102c0610848366004614a7c565b612ac7565b34801561085957600080fd5b506102c0610868366004614dfd565b612b64565b60006001600160a01b0383166108de5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b60648201526084015b60405180910390fd5b5060008181526001602090815260408083206001600160a01b03861684529091529020545b92915050565b600061090382612ba7565b3361091d612055565b6001600160a01b0316146109435760405162461bcd60e51b81526004016108d590615a25565b61094c81612be7565b50565b600061095b8133612bfa565b506000918252600a6020526040909120600701805460ff1916911515919091179055565b60606007805461098e90615d27565b80601f01602080910402602001604051908101604052809291908181526020018280546109ba90615d27565b8015610a075780601f106109dc57610100808354040283529160200191610a07565b820191906000526020600020905b8154815290600101906020018083116109ea57829003601f168201915b5050505050905090565b60606000610a1e83610ba0565b11610a555760405162461bcd60e51b81526020600482015260076024820152665552493a206e6160c81b60448201526064016108d5565b6000828152600a602052604090208054610b069190610a7390615d27565b80601f0160208091040260200160405190810160405280929190818152602001828054610a9f90615d27565b8015610aec5780601f10610ac157610100808354040283529160200191610aec565b820191906000526020600020905b815481529060010190602001808311610acf57829003601f168201915b505050505060405180602001604052806000815250612c5e565b15610b4457610b1482612cb7565b610b1d83612d4b565b604051602001610b2e9291906154c2565b6040516020818303038152906040529050919050565b6000828152600a60209081526040918290209151610b2e929101615568565b919050565b33610b71612055565b6001600160a01b031614610b975760405162461bcd60e51b81526004016108d590615a25565b61094c81612ac7565b6000818152600a60205260408120601181015460ff16610bc857610bc383612369565b610bce565b600e8101545b9392505050565b6000610c0382600001516040518060400160405280600681526020016545524337323160d01b815250612c5e565b15610c915760208201516040516370a0823160e01b81526001600160a01b038216906370a0823190610c39908790600401615695565b60206040518083038186803b158015610c5157600080fd5b505afa158015610c65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c89919061515a565b915050610903565b610cbe8260000151604051806040016040528060078152602001664552433131353560c81b815250612c5e565b156109035760208201516060830151604051627eeac760e11b81526001600160a01b03868116600483015260248201929092529082169062fdd58e90604401610c39565b60009081526020819052604090206001015490565b6001600160a01b038516331480610d335750610d3385336107df565b610d9a5760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b60648201526084016108d5565b610da78585858585612e6c565b5050505050565b610db782610d02565b610dc18133612bfa565b610dcb838361301b565b505050565b6001600160a01b0381163314610e405760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016108d5565b610e4a828261309f565b5050565b6000610e5a8133612bfa565b6000898152600a6020908152604090912060118101805460ff19168b15151790558851601290910191610e919183918b01906147c4565b5060018101805460ff19169715159790971790965550600285019390935560038401919091556004909201805461ffff191692151561ff0019169290921761010091151591909102179055505050565b6000828152600a60205260408120600481015490919015610f455760005b8260040154811015610f435760008181526003840160205260409020546001600160a01b0316331415610f3157600191505b80610f3b81615dad565b915050610eff565b505b80610f775760405162461bcd60e51b8152602060048201526002602482015261623160f01b60448201526064016108d5565b610da7858585613104565b33610f8b612055565b6001600160a01b031614610fb15760405162461bcd60e51b81526004016108d590615a25565b610fb961310f565b565b6000818152600a6020526040812060045460ff1615610fdd5750600092915050565b600881015442118015610ff35750600981015442105b15611005576007015460ff1692915050565b50600092915050565b600061101a8133612bfa565b61103661102660095490565b8d8d8d8d8d8d8d8d8d8d8d612192565b611044600980546001019055565b505050505050505050505050565b606081518351146110b75760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016108d5565b600083516001600160401b038111156110e057634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611109578160200160208202803683370190505b50905060005b84518110156111ab5761117085828151811061113b57634e487b7160e01b600052603260045260246000fd5b602002602001015185838151811061116357634e487b7160e01b600052603260045260246000fd5b602002602001015161086d565b82828151811061119057634e487b7160e01b600052603260045260246000fd5b60209081029190910101526111a481615dad565b905061110f565b509392505050565b6000806111bf83612369565b1192915050565b600a602052600090815260409020805481906111e190615d27565b80601f016020809104026020016040519081016040528092919081815260200182805461120d90615d27565b801561125a5780601f1061122f5761010080835404028352916020019161125a565b820191906000526020600020905b81548152906001019060200180831161123d57829003601f168201915b50505050509080600101805461126f90615d27565b80601f016020809104026020016040519081016040528092919081815260200182805461129b90615d27565b80156112e85780601f106112bd576101008083540402835291602001916112e8565b820191906000526020600020905b8154815290600101906020018083116112cb57829003601f168201915b5050505060048301546006840154604080516101008082018352600788015460ff90811615158352600889015460208085019190915260098a015484860152600a8a0154606080860191909152600b8b0154608080870191909152600c8c015460a0870152600d8c015460c080880191909152600e8d015460e08089019190915288519283018952600f8e015480871615158452968704861615158386015262010000909604851615158289015260108d01549282019290925260118c0154875160128e018054958602820188019099529283018481529b9c999b989a50959890979590931695929490938492849184018282801561140657602002820191906000526020600020905b8154815260200190600101908083116113f2575b5050509183525050600182015460ff908116151560208301526002830154604083015260038301546060830152600490920154808316151560808301526101009004909116151560a090910152905088565b33611461612055565b6001600160a01b0316146114875760405162461bcd60e51b81526004016108d590615a25565b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610dcb573d6000803e3d6000fd5b60408051602081019091526000808252606091905b6000818152600a6020526040902080546114f09190610a7390615d27565b611541576114fd81610fbb565b1561152f578161150c82612d4b565b60405160200161151d9291906154f1565b60405160208183030381529060405291505b8061153981615dad565b9150506114d2565b50919050565b6001600160a01b038316331480611563575061156383336107df565b61157f5760405162461bcd60e51b81526004016108d59061590a565b610dcb83838361319c565b60045460ff16156115c25760405162461bcd60e51b8152602060048201526002602482015261070360f41b60448201526064016108d5565b6000805b8681101561166457611650611649600a60008b8b868181106115f857634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020600701600301548c8c8581811061163457634e487b7160e01b600052603260045260246000fd5b905060200201356131a790919063ffffffff16565b83906131b3565b91508061165c81615dad565b9150506115c6565b508034101561169a5760405162461bcd60e51b8152602060048201526002602482015261703160f01b60448201526064016108d5565b60005b86811015611fa2576000611759338a8a858181106116cb57634e487b7160e01b600052603260045260246000fd5b905060200201358d8d868181106116f257634e487b7160e01b600052603260045260246000fd5b905060200201358a8a8781811061171957634e487b7160e01b600052603260045260246000fd5b9050602002013589898881811061174057634e487b7160e01b600052603260045260246000fd5b90506020028101906117529190615aa2565b60016123e6565b905060008111801561179157508a8a8381811061178657634e487b7160e01b600052603260045260246000fd5b905060200201358110155b6117c25760405162461bcd60e51b8152602060048201526002602482015261381960f11b60448201526064016108d5565b606080600a60008c8c878181106117e957634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000206011015460ff1615611d89576118c0338c8c8781811061183257634e487b7160e01b600052603260045260246000fd5b905060200201358f8f8881811061185957634e487b7160e01b600052603260045260246000fd5b905060200201358c8c8981811061188057634e487b7160e01b600052603260045260246000fd5b905060200201358b8b8a8181106118a757634e487b7160e01b600052603260045260246000fd5b90506020028101906118b99190615aa2565b60006123e6565b925060005b8d8d868181106118e557634e487b7160e01b600052603260045260246000fd5b90506020020135811015611d835760006119e1600a60008f8f8a81811061191c57634e487b7160e01b600052603260045260246000fd5b9050602002013581526020019081526020016000206012016040518060c00160405290816000820180548060200260200160405190810160405280929190818152602001828054801561198e57602002820191906000526020600020905b81548152602001906001019080831161197a575b5050509183525050600182015460ff908116151560208301526002830154604083015260038301546060830152600490920154808316151560808301526101009004909116151560a090910152836131bf565b9050600a60008e8e89818110611a0757634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508101919091526040016000206013015460ff1615611ba357846001600160401b03811115611a5257634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611a7b578160200160208202803683370190505b509350846001600160401b03811115611aa457634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611acd578160200160208202803683370190505b5092506000805b86811015611b9c57828281518110611afc57634e487b7160e01b600052603260045260246000fd5b6020026020010151868281518110611b2457634e487b7160e01b600052603260045260246000fd5b6020026020010181815250506001858281518110611b5257634e487b7160e01b600052603260045260246000fd5b60200260200101818152505060018351611b6c9190615caa565b821015611b8557611b7e826001615b0c565b9150611b8a565b600091505b611b95816001615b0c565b9050611ad4565b5050611c97565b80516001600160401b03811115611bca57634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611bf3578160200160208202803683370190505b50935060005b8151811015611c9557818181518110611c2257634e487b7160e01b600052603260045260246000fd5b6020026020010151858281518110611c4a57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250506001848281518110611c7857634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611c8d81615dad565b915050611bf9565b505b611cb2338585604051806020016040528060008152506133d5565b336001600160a01b0316600080516020615f2b8339815191528585604051611cdb929190615754565b60405180910390a2600a60008e8e89818110611d0757634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020600701600701546001611d2f9190615b0c565b600a60008f8f8a818110611d5357634e487b7160e01b600052603260045260246000fd5b60209081029290920135835250810191909152604001600020600e01555080611d7b81615dad565b9150506118c5565b50611ebf565b60408051600180825281830190925290602080830190803683370190505091508a8a85818110611dc957634e487b7160e01b600052603260045260246000fd5b9050602002013582600081518110611df157634e487b7160e01b600052603260045260246000fd5b6020908102919091010152604080516001808252818301909252908160200160208202803683370190505090508c8c85818110611e3e57634e487b7160e01b600052603260045260246000fd5b9050602002013581600081518110611e6657634e487b7160e01b600052603260045260246000fd5b602002602001018181525050611e8d338383604051806020016040528060008152506133d5565b336001600160a01b0316600080516020615f2b8339815191528383604051611eb6929190615754565b60405180910390a25b611f3d8d8d86818110611ee257634e487b7160e01b600052603260045260246000fd5b90506020020135600a60008e8e89818110611f0d57634e487b7160e01b600052603260045260246000fd5b602090810292909201358352508181019290925260409081016000908120338252600201909252902054906131b3565b600a60008d8d88818110611f6157634e487b7160e01b600052603260045260246000fd5b60209081029290920135835250818101929092526040908101600090812033825260020190925290205550829150611f9a905081615dad565b91505061169d565b50505050505050505050565b33611fb7612055565b6001600160a01b031614611fdd5760405162461bcd60e51b81526004016108d590615a25565b610fb960006133e7565b6000611ff38133612bfa565b506000918252600a60209081526040808420928452600590920190529020600401805460ff19169055565b33612027612055565b6001600160a01b03161461204d5760405162461bcd60e51b81526004016108d590615a25565b610fb9613439565b6006546001600160a01b031690565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b60006120998133612bfa565b8151610dcb90600b90602085019061480f565b60606008805461098e90615d27565b336001600160a01b03831614156121265760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016108d5565b3360008181526002602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b600061219e8133612bfa565b6000600a60008f815260200190815260200160002090508a81600701600101819055508981600701600201819055508881600701600301819055508781600701600401819055508681600701600601819055508581600701600501819055508c81600001908051906020019061221592919061480f565b508b5161222b90600183019060208f019061480f565b5060005b83518110156122a45783818151811061225857634e487b7160e01b600052603260045260246000fd5b602090810291909101810151600083815260038501909252604090912080546001600160a01b0319166001600160a01b039092169190911790558061229c81615dad565b91505061222f565b509151600483015550600f01805461ffff191692151561ff0019169290921761010091151591909102179055505050505050505050565b600880546122e890615d27565b80601f016020809104026020016040519081016040528092919081815260200182805461231490615d27565b80156123615780601f1061233657610100808354040283529160200191612361565b820191906000526020600020905b81548152906001019060200180831161234457829003601f168201915b505050505081565b60009081526005602052604090205490565b600b80546122e890615d27565b61239182610d02565b61239b8133612bfa565b610dcb838361309f565b60006123b18133612bfa565b506000928352600a60205260409092206010810191909155600f018054911515620100000262ff000019909216919091179055565b6000868152600a602052604081208261262357600781015460ff166124325760405162461bcd60e51b8152602060048201526002602482015261763160f01b60448201526064016108d5565b60045460ff161561246a5760405162461bcd60e51b81526020600482015260026024820152613b1960f11b60448201526064016108d5565b60088101546124a05760405162461bcd60e51b8152602060048201526002602482015261763360f01b60448201526064016108d5565b6008810154421180156124b65750600981015442105b6124e75760405162461bcd60e51b81526020600482015260026024820152611d8d60f21b60448201526064016108d5565b6001600160a01b0389166000908152600282016020526040902054869061250e90896131b3565b11156125415760405162461bcd60e51b8152602060048201526002602482015261763560f01b60448201526064016108d5565b600c8101546001600160a01b038a16600090815260028301602052604090205461256b90896131b3565b111561259e5760405162461bcd60e51b81526020600482015260026024820152613b1b60f11b60448201526064016108d5565b600d8101548711156125d75760405162461bcd60e51b8152602060048201526002602482015261763760f01b60448201526064016108d5565b600b810154876125e68a610ba0565b6125f09190615b0c565b11156126235760405162461bcd60e51b81526020600482015260026024820152610ec760f31b60448201526064016108d5565b600c810154600f82015460ff1615612639575060005b6006820154600090156128005760008060005b85600601548110156127f857600081815260058701602052604090206004015460ff16156127e6576126808e8e838b6134b4565b600f870154909250610100900460ff16156126d55760006126a38f8f848c6134b4565b116126d55760405162461bcd60e51b8152602060048201526002602482015261763960f01b60448201526064016108d5565b600f86015460ff16156127e2576126ea614882565b60008281526005880160205260409020805461270590615d27565b80601f016020809104026020016040519081016040528092919081815260200182805461273190615d27565b801561277e5780601f106127535761010080835404028352916020019161277e565b820191906000526020600020905b81548152906001019060200180831161276157829003601f168201915b505050918352505060008281526005880160208181526040832060018101546001600160a01b03168286015292859052526003015460608201526127c28f82610bd5565b93506127ce8487615b0c565b95506127da8486615b0c565b9450506127e6565b8193505b806127f081615dad565b91505061264c565b505050612807565b50600d8201545b846128aa57600081116128425760405162461bcd60e51b815260206004820152600360248201526207631360ec1b60448201526064016108d5565b600f83015460ff16156128aa576001600160a01b038b1660009081526002840160205260409020548290612876908b6131b3565b11156128aa5760405162461bcd60e51b815260206004820152600360248201526276313160e81b60448201526064016108d5565b600f83015462010000900460ff16156128fb576128c987878c8b6136ce565b6128fb5760405162461bcd60e51b81526020600482015260036024820152623b189960e91b60448201526064016108d5565b841561290e5788811061290e5788612910565b805b93505050505b979650505050505050565b600061292d8133612bfa565b6129a98684848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808c0282810182019093528b82529093508b92508a9182918501908490808284376000920182905250604080516020810190915290815292506133d5915050565b505050505050565b60006129bd8133612bfa565b6000868152600a60209081526040808320600681015484526005018252909120865190916129ef91839189019061480f565b5060038101849055600481018054600160ff19909116811790915580820180546001600160a01b0319166001600160a01b038816179055600282018490556000888152600a6020526040902060060154612a4891615b0c565b6000978852600a602052604090972060060196909655505050505050565b600780546122e890615d27565b6060600b805461098e90615d27565b6001600160a01b038516331480612a9e5750612a9e85336107df565b612aba5760405162461bcd60e51b81526004016108d59061590a565b610da7858585858561377c565b33612ad0612055565b6001600160a01b031614612af65760405162461bcd60e51b81526004016108d590615a25565b6001600160a01b038116612b5b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108d5565b61094c816133e7565b6001600160a01b038316331480612b805750612b8083336107df565b612b9c5760405162461bcd60e51b81526004016108d59061590a565b610dcb838383613104565b60006001600160e01b03198216636cdb3d1360e11b1480612bd857506001600160e01b031982166303a24d0760e21b145b8061090357506109038261389a565b8051610e4a90600390602084019061480f565b612c048282612064565b610e4a57612c1c816001600160a01b031660146138cf565b612c278360206138cf565b604051602001612c38929190615603565b60408051601f198184030181529082905262461bcd60e51b82526108d591600401615782565b600081604051602001612c7191906154a6565b6040516020818303038152906040528051906020012083604051602001612c9891906154a6565b6040516020818303038152906040528051906020012014905092915050565b606060038054612cc690615d27565b80601f0160208091040260200160405190810160405280929190818152602001828054612cf290615d27565b8015612d3f5780601f10612d1457610100808354040283529160200191612d3f565b820191906000526020600020905b815481529060010190602001808311612d2257829003601f168201915b50505050509050919050565b606081612d6f5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612d995780612d8381615dad565b9150612d929050600a83615b49565b9150612d73565b6000816001600160401b03811115612dc157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612deb576020820181803683370190505b5090505b8415612e6457612e00600183615caa565b9150612e0d600a86615dc8565b612e18906030615b0c565b60f81b818381518110612e3b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612e5d600a86615b49565b9450612def565b949350505050565b8151835114612e8d5760405162461bcd60e51b81526004016108d590615a5a565b6001600160a01b038416612eb35760405162461bcd60e51b81526004016108d590615953565b33612ec2818787878787613ab0565b60005b8451811015612fc7576000858281518110612ef057634e487b7160e01b600052603260045260246000fd5b602002602001015190506000858381518110612f1c57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526001835260408082206001600160a01b038e168352909352919091205490915081811015612f6d5760405162461bcd60e51b81526004016108d5906159db565b60008381526001602090815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612fac908490615b0c565b9250508190555050505080612fc090615dad565b9050612ec5565b50846001600160a01b0316866001600160a01b0316826001600160a01b0316600080516020615eeb8339815191528787604051613005929190615754565b60405180910390a46129a9818787878787613abe565b6130258282612064565b610e4a576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561305b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6130a98282612064565b15610e4a576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b610dcb838383613c29565b60045460ff166131585760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108d5565b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516131929190615695565b60405180910390a1565b610dcb838383613c5c565b6000610bce8284615c6a565b6000610bce8284615b0c565b60606131d18360000151600084613cfa565b835260606000805b85515181101561328257600a60008760000151838151811061320b57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206007016004015461325c8760000151838151811061324f57634e487b7160e01b600052603260045260246000fd5b6020026020010151610ba0565b1015613270578161326c81615dad565b9250505b8061327a81615dad565b9150506131d9565b50806001600160401b038111156132a957634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156132d2578160200160208202803683370190505b5091506000805b8651518110156133ca57600a60008860000151838151811061330b57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206007016004015461334f8860000151838151811061324f57634e487b7160e01b600052603260045260246000fd5b10156133b857865180518290811061337757634e487b7160e01b600052603260045260246000fd5b602002602001015184838151811061339f57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152816133b481615dad565b9250505b806133c281615dad565b9150506132d9565b509195945050505050565b6133e184848484613eea565b50505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60045460ff161561347f5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108d5565b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586131853390565b6000838152600a60205260408120819081906134ce614882565b6000878152600583016020526040902080546134e990615d27565b80601f016020809104026020016040519081016040528092919081815260200182805461351590615d27565b80156135625780601f1061353757610100808354040283529160200191613562565b820191906000526020600020905b81548152906001019060200180831161354557829003601f168201915b505050918352505060008781526005830160208181526040832060018101546001600160a01b031682860152928a9052526003015460608201526135a68982610bd5565b600088815260058401602052604090206002015460118401549194508410159060ff1680156135d3575086155b1561363957601383015460ff16156135fb5760148301546135f49086615b0c565b945061360d565b601283015461360a9086615b0c565b94505b60158301541580159061361d5750805b156136345760158301546136319086615b0c565b94505b61369b565b601183015460ff1680156136515750601683015460ff165b801561365a5750805b156136675783945061369b565b601183015460ff161580156136805750600f83015460ff165b1561368d5783945061369b565b801561369b57600d83015494505b841580156136b35750600f830154610100900460ff16155b156136c057600d83015494505b509298975050505050505050565b6000828152600a60205260408120600f015462010000900460ff166136f557506001612e64565b60006137013384613f89565b90506000816040516020016137169190615782565b60405160208183030381529060405280519060200120905061291687878080602002602001604051908101604052809392919081815260200183836020028082843760009201829052508a8152600a602052604090206010015492508591506141199050565b6001600160a01b0384166137a25760405162461bcd60e51b81526004016108d590615953565b336137c18187876137b2886141d6565b6137bb886141d6565b87613ab0565b60008481526001602090815260408083206001600160a01b038a168452909152902054838110156138045760405162461bcd60e51b81526004016108d5906159db565b60008581526001602090815260408083206001600160a01b038b8116855292528083208785039055908816825281208054869290613843908490615b0c565b909155505060408051868152602081018690526001600160a01b03808916928a82169291861691600080516020615f0b833981519152910160405180910390a461389182888888888861422f565b50505050505050565b60006001600160e01b03198216637965db0b60e01b148061090357506301ffc9a760e01b6001600160e01b0319831614610903565b606060006138de836002615c6a565b6138e9906002615b0c565b6001600160401b0381111561390e57634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015613938576020820181803683370190505b509050600360fc1b8160008151811061396157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061399e57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060006139c2846002615c6a565b6139cd906001615b0c565b90505b6001811115613a61576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613a0f57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110613a3357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93613a5a81615d10565b90506139d0565b508315610bce5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016108d5565b6129a98686868686866142f9565b6001600160a01b0384163b156129a95760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190613b0290899089908890889088906004016156a9565b602060405180830381600087803b158015613b1c57600080fd5b505af1925050508015613b4c575060408051601f3d908101601f19168201909252613b4991810190615028565b60015b613bf957613b58615e1e565b806308c379a01415613b925750613b6d615e36565b80613b785750613b94565b8060405162461bcd60e51b81526004016108d59190615782565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016108d5565b6001600160e01b0319811663bc197c8160e01b146138915760405162461bcd60e51b81526004016108d59061587e565b613c34838383614361565b60008281526005602052604081208054839290613c52908490615caa565b9091555050505050565b613c67838383614454565b60005b82518110156133e157818181518110613c9357634e487b7160e01b600052603260045260246000fd5b602002602001015160056000858481518110613cbf57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254613ce49190615caa565b90915550613cf3905081615dad565b9050613c6a565b606082613e285760005b8451811015613e22576000818651613d1c9190615caa565b423386604051602001613d3193929190615672565b6040516020818303038152906040528051906020012060001c613d549190615dc8565b613d5e9083615b0c565b90506000868281518110613d8257634e487b7160e01b600052603260045260246000fd5b60200260200101519050868381518110613dac57634e487b7160e01b600052603260045260246000fd5b6020026020010151878381518110613dd457634e487b7160e01b600052603260045260246000fd5b60200260200101818152505080878481518110613e0157634e487b7160e01b600052603260045260246000fd5b60200260200101818152505050508080613e1a90615dad565b915050613d04565b50613ee2565b60008451423385604051602001613e4193929190615672565b6040516020818303038152906040528051906020012060001c613e649190615dc8565b6040805160018082528183019092529192506000919060208083019080368337019050509050858281518110613eaa57634e487b7160e01b600052603260045260246000fd5b602002602001015181600081518110613ed357634e487b7160e01b600052603260045260246000fd5b60209081029190910101529450505b509192915050565b613ef6848484846145ef565b60005b8351811015610da757828181518110613f2257634e487b7160e01b600052603260045260246000fd5b602002602001015160056000868481518110613f4e57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000828254613f739190615b0c565b90915550613f82905081615dad565b9050613ef9565b60408051602880825260608281019093526000919060208201818036833701905050905060005b60148110156140e5576000613fc6826013615caa565b613fd1906008615c6a565b613fdc906002615bc2565b613fef906001600160a01b038816615b49565b60f81b9050600060108260f81c6140069190615b5d565b60f81b905060008160f81c601061401d9190615c89565b8360f81c61402b9190615cc1565b60f81b90506140398261478e565b85614045866002615c6a565b8151811061406357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506140838161478e565b8561408f866002615c6a565b61409a906001615b0c565b815181106140b857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535050505080806140dd90615dad565b915050613fb0565b50806140f084612d4b565b60405160200161410192919061552c565b60405160208183030381529060405291505092915050565b600081815b85518110156141cb57600086828151811061414957634e487b7160e01b600052603260045260246000fd5b6020026020010151905080831161418b5760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506141b8565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806141c381615dad565b91505061411e565b509092149392505050565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061421e57634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0384163b156129a95760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906142739089908990889088908890600401615707565b602060405180830381600087803b15801561428d57600080fd5b505af19250505080156142bd575060408051601f3d908101601f191682019092526142ba91810190615028565b60015b6142c957613b58615e1e565b6001600160e01b0319811663f23a6e6160e01b146138915760405162461bcd60e51b81526004016108d59061587e565b60045460ff16156129a95760405162461bcd60e51b815260206004820152602c60248201527f455243313135355061757361626c653a20746f6b656e207472616e736665722060448201526b1dda1a5b19481c185d5cd95960a21b60648201526084016108d5565b6001600160a01b0383166143875760405162461bcd60e51b81526004016108d590615998565b336143b681856000614398876141d6565b6143a1876141d6565b60405180602001604052806000815250613ab0565b60008381526001602090815260408083206001600160a01b0388168452909152902054828110156143f95760405162461bcd60e51b81526004016108d5906158c6565b60008481526001602090815260408083206001600160a01b0389811680865291845282852088870390558251898152938401889052909290861691600080516020615f0b833981519152910160405180910390a45050505050565b6001600160a01b03831661447a5760405162461bcd60e51b81526004016108d590615998565b805182511461449b5760405162461bcd60e51b81526004016108d590615a5a565b60003390506144be81856000868660405180602001604052806000815250613ab0565b60005b83518110156145a25760008482815181106144ec57634e487b7160e01b600052603260045260246000fd5b60200260200101519050600084838151811061451857634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526001835260408082206001600160a01b038c1683529093529190912054909150818110156145695760405162461bcd60e51b81526004016108d5906158c6565b60009283526001602090815260408085206001600160a01b038b168652909152909220910390558061459a81615dad565b9150506144c1565b5060006001600160a01b0316846001600160a01b0316826001600160a01b0316600080516020615eeb83398151915286866040516145e1929190615754565b60405180910390a450505050565b6001600160a01b03841661464f5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016108d5565b81518351146146705760405162461bcd60e51b81526004016108d590615a5a565b3361468081600087878787613ab0565b60005b8451811015614738578381815181106146ac57634e487b7160e01b600052603260045260246000fd5b6020026020010151600160008784815181106146d857634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546147209190615b0c565b9091555081905061473081615dad565b915050614683565b50846001600160a01b031660006001600160a01b0316826001600160a01b0316600080516020615eeb8339815191528787604051614777929190615754565b60405180910390a4610da781600087878787613abe565b6000600a60f883901c10156147b5576147ac60f883901c6030615b24565b60f81b92915050565b6147ac60f883901c6057615b24565b8280548282559060005260206000209081019282156147ff579160200282015b828111156147ff5782518255916020019190600101906147e4565b5061480b9291506148bc565b5090565b82805461481b90615d27565b90600052602060002090601f01602090048101928261483d57600085556147ff565b82601f1061485657805160ff19168380011785556147ff565b828001600101855582156147ff57918201828111156147ff5782518255916020019190600101906147e4565b6040518060a001604052806060815260200160006001600160a01b0316815260200160008152602001600081526020016000151581525090565b5b8082111561480b57600081556001016148bd565b600082601f8301126148e1578081fd5b813560206148ee82615ae9565b6040516148fb8282615d81565b8381528281019150858301600585901b8701840188101561491a578586fd5b855b8581101561494157813561492f81615ebf565b8452928401929084019060010161491c565b5090979650505050505050565b60008083601f84011261495f578182fd5b5081356001600160401b03811115614975578182fd5b6020830191508360208260051b850101111561499057600080fd5b9250929050565b600082601f8301126149a7578081fd5b813560206149b482615ae9565b6040516149c18282615d81565b8381528281019150858301600585901b870184018810156149e0578586fd5b855b85811015614941578135845292840192908401906001016149e2565b80358015158114610b6357600080fd5b600082601f830112614a1e578081fd5b81356001600160401b03811115614a3757614a37615e08565b604051614a4e601f8301601f191660200182615d81565b818152846020838601011115614a62578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215614a8d578081fd5b8135610bce81615ebf565b60008060408385031215614aaa578081fd5b8235614ab581615ebf565b946020939093013593505050565b60008060408385031215614ad5578182fd5b8235614ae081615ebf565b91506020830135614af081615ebf565b809150509250929050565b600080600080600060a08688031215614b12578081fd5b8535614b1d81615ebf565b94506020860135614b2d81615ebf565b935060408601356001600160401b0380821115614b48578283fd5b614b5489838a01614997565b94506060880135915080821115614b69578283fd5b614b7589838a01614997565b93506080880135915080821115614b8a578283fd5b50614b9788828901614a0e565b9150509295509295909350565b600080600080600060a08688031215614bbb578283fd5b8535614bc681615ebf565b94506020860135614bd681615ebf565b9350604086013592506060860135915060808601356001600160401b03811115614bfe578182fd5b614b9788828901614a0e565b600080600080600060608688031215614c21578283fd5b8535614c2c81615ebf565b945060208601356001600160401b0380821115614c47578485fd5b614c5389838a0161494e565b90965094506040880135915080821115614c6b578283fd5b50614c788882890161494e565b969995985093965092949392505050565b600080600060608486031215614c9d578081fd5b8335614ca881615ebf565b925060208401356001600160401b0380821115614cc3578283fd5b614ccf87838801614997565b93506040860135915080821115614ce4578283fd5b50614cf186828701614997565b9150509250925092565b60008060408385031215614d0d578182fd5b8235614d1881615ebf565b9150614d26602084016149fe565b90509250929050565b60008060408385031215614d41578182fd5b8235614d4c81615ebf565b915060208301356001600160401b0380821115614d67578283fd5b9084019060a08287031215614d7a578283fd5b604051614d8681615d5c565b823582811115614d94578485fd5b614da088828601614a0e565b82525060208301359150614db382615ebf565b8160208201526040830135604082015260608301356060820152614dd9608084016149fe565b60808201528093505050509250929050565b60008060408385031215614aaa578182fd5b600080600060608486031215614e11578081fd5b8335614e1c81615ebf565b95602085013595506040909401359392505050565b600080600080600080600060c0888a031215614e4b578485fd5b8735614e5681615ebf565b965060208801359550604088013594506060880135935060808801356001600160401b03811115614e85578283fd5b614e918a828b0161494e565b9094509250614ea4905060a089016149fe565b905092959891949750929550565b60008060408385031215614ec4578182fd5b82356001600160401b0380821115614eda578384fd5b614ee6868387016148d1565b93506020850135915080821115614efb578283fd5b50614f0885828601614997565b9150509250929050565b6000806000806000806000806080898b031215614f2d578182fd5b88356001600160401b0380821115614f43578384fd5b614f4f8c838d0161494e565b909a50985060208b0135915080821115614f67578384fd5b614f738c838d0161494e565b909850965060408b0135915080821115614f8b578384fd5b614f978c838d0161494e565b909650945060608b0135915080821115614faf578384fd5b50614fbc8b828c0161494e565b999c989b5096995094979396929594505050565b600060208284031215614fe1578081fd5b5035919050565b60008060408385031215614ffa578182fd5b823591506020830135614af081615ebf565b60006020828403121561501d578081fd5b8135610bce81615ed4565b600060208284031215615039578081fd5b8151610bce81615ed4565b600060208284031215615055578081fd5b81356001600160401b0381111561506a578182fd5b612e6484828501614a0e565b60008060008060008060008060008060006101608c8e031215615097578485fd5b6001600160401b038c358110156150ac578586fd5b6150b98e8e358f01614a0e565b9b508060208e013511156150cb578586fd5b6150db8e60208f01358f01614a0e565b9a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506151146101008e016149fe565b93506151236101208e016149fe565b9250806101408e01351115615136578182fd5b506151488d6101408e01358e016148d1565b90509295989b509295989b9093969950565b60006020828403121561516b578081fd5b5051919050565b60008060408385031215615184578182fd5b82359150614d26602084016149fe565b600080600080600080600080610100898b0312156151b0578182fd5b883597506151c060208a016149fe565b965060408901356001600160401b038111156151da578283fd5b6151e68b828c01614997565b9650506151f560608a016149fe565b94506080890135935060a0890135925061521160c08a016149fe565b915061521f60e08a016149fe565b90509295985092959890939650565b600080600060608486031215615242578081fd5b8335925060208401359150615259604085016149fe565b90509250925092565b600080600080600060a08688031215615279578283fd5b8535945060208601356001600160401b03811115615295578384fd5b6152a188828901614a0e565b94505060408601356152b281615ebf565b94979396509394606081013594506080013592915050565b6000806000806000806000806000806000806101808d8f0312156152ec578586fd5b8c359b506001600160401b0360208e01351115615307578586fd5b6153178e60208f01358f01614a0e565b9a506001600160401b0360408e01351115615330578586fd5b6153408e60408f01358f01614a0e565b995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506101008d0135935061537a6101208e016149fe565b92506153896101408e016149fe565b91506001600160401b036101608e013511156153a3578081fd5b6153b48e6101608f01358f016148d1565b90509295989b509295989b509295989b565b600080604083850312156153d8578182fd5b50508035926020909101359150565b6000815180845260208085019450808401835b83811015615416578151875295820195908201906001016153fa565b509495945050505050565b60008151808452615439816020860160208601615ce4565b601f01601f19169290920160200192915050565b6000815160c0845261546260c08501826153e7565b9050602083015115156020850152604083015160408501526060830151606085015260808301511515608085015260a0830151151560a08501528091505092915050565b600082516154b8818460208701615ce4565b9190910192915050565b600083516154d4818460208801615ce4565b8351908301906154e8818360208801615ce4565b01949350505050565b60008351615503818460208801615ce4565b835190830190615517818360208801615ce4565b600b60fa1b9101908152600101949350505050565b6000835161553e818460208801615ce4565b605f60f81b908301908152835161555c816001840160208801615ce4565b01600101949350505050565b600080835482600182811c91508083168061558457607f831692505b60208084108214156155a457634e487b7160e01b87526022600452602487fd5b8180156155b857600181146155c9576155f5565b60ff198616895284890196506155f5565b60008a815260209020885b868110156155ed5781548b8201529085019083016155d4565b505084890196505b509498975050505050505050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351615635816017850160208801615ce4565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615666816028840160208801615ce4565b01602801949350505050565b92835260609190911b6001600160601b0319166020830152603482015260540190565b6001600160a01b0391909116815260200190565b6001600160a01b0386811682528516602082015260a0604082018190526000906156d5908301866153e7565b82810360608401526156e781866153e7565b905082810360808401526156fb8185615421565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a06080820181905260009061291690830184615421565b602081526000610bce60208301846153e7565b60408152600061576760408301856153e7565b828103602084015261577981856153e7565b95945050505050565b602081526000610bce6020830184615421565b60006102408083526157a98184018c615421565b905082810360208401526157bd818b615421565b9050886040840152876060840152865115156080840152602087015160a0840152604087015160c0840152606087015160e0840152608087015161010084015260a087015161012084015260c087015161014084015260e0870151610160840152615853610180840187805115158252602081015115156020830152604081015115156040830152606081015160608301525050565b84151561020084015282810361022084015261586f818561544d565b9b9a5050505050505050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b60208082526029908201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260408201526808185c1c1c9bdd995960ba1b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b6000808335601e19843603018112615ab8578283fd5b8301803591506001600160401b03821115615ad1578283fd5b6020019150600581901b360382131561499057600080fd5b60006001600160401b03821115615b0257615b02615e08565b5060051b60200190565b60008219821115615b1f57615b1f615ddc565b500190565b600060ff821660ff84168060ff03821115615b4157615b41615ddc565b019392505050565b600082615b5857615b58615df2565b500490565b600060ff831680615b7057615b70615df2565b8060ff84160491505092915050565b600181815b80851115615bba578160001904821115615ba057615ba0615ddc565b80851615615bad57918102915b93841c9390800290615b84565b509250929050565b6000610bce8383600082615bd857506001610903565b81615be557506000610903565b8160018114615bfb5760028114615c0557615c21565b6001915050610903565b60ff841115615c1657615c16615ddc565b50506001821b610903565b5060208310610133831016604e8410600b8410161715615c44575081810a610903565b615c4e8383615b7f565b8060001904821115615c6257615c62615ddc565b029392505050565b6000816000190483118215151615615c8457615c84615ddc565b500290565b600060ff821660ff84168160ff0481118215151615615c6257615c62615ddc565b600082821015615cbc57615cbc615ddc565b500390565b600060ff821660ff841680821015615cdb57615cdb615ddc565b90039392505050565b60005b83811015615cff578181015183820152602001615ce7565b838111156133e15750506000910152565b600081615d1f57615d1f615ddc565b506000190190565b600181811c90821680615d3b57607f821691505b6020821081141561154157634e487b7160e01b600052602260045260246000fd5b60a081016001600160401b0381118282101715615d7b57615d7b615e08565b60405250565b601f8201601f191681016001600160401b0381118282101715615da657615da6615e08565b6040525050565b6000600019821415615dc157615dc1615ddc565b5060010190565b600082615dd757615dd7615df2565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d1115615e3357600481823e5160e01c5b90565b600060443d1015615e445790565b6040516003193d81016004833e81513d6001600160401b038083116024840183101715615e7357505050505090565b8285019150815181811115615e8b5750505050505090565b843d8701016020828501011115615ea55750505050505090565b615eb460208286010187615d81565b509095945050505050565b6001600160a01b038116811461094c57600080fd5b6001600160e01b03198116811461094c57600080fdfe4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fbc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62b19a0e54a0d12c649f962287d12e0573df3d188f5fcad44083dd0a11e759bcc5a2646970667358221220e4e7deb5bf12b4c2ecda48bff02b52bd72ce17922708ac4172ac1a1ba7ed2ae064736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: Yes (1 runs)
Commerce.sol 556 lines
// SPDX-License-Identifier: MIT
// @bitcoinski & @calvinhoenes
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import './Abstract1155Factory.sol';
contract Commerce is Abstract1155Factory {
using SafeMath for uint256;
using Counters for Counters.Counter;
Counters.Counter private tokenCounter;
mapping(uint256 => Token) public tokens;
event Purchased(uint[] index, address indexed account, uint[] amount);
struct Token {
string ipfsMetadataHash;
string extraDataUri;
mapping(address => uint256) claimedTokens;
mapping(uint => address) redeemableContracts;
uint256 numRedeemableContracts;
mapping(uint => Whitelist) whitelistData;
uint256 numTokenWhitelists;
MintingConfig mintingConfig;
WhiteListConfig whiteListConfig;
bool isTokenPack;
TokenPackConfig tokenPackConfig;
}
struct MintingConfig {
bool saleIsOpen;
uint256 windowOpens;
uint256 windowCloses;
uint256 mintPrice;
uint256 maxSupply;
uint256 maxPerWallet;
uint256 maxMintPerTxn;
uint256 numMinted;
}
struct WhiteListConfig {
bool maxQuantityMappedByWhitelistHoldings;
bool requireAllWhiteLists;
bool hasMerkleRoot;
bytes32 merkleRoot;
}
struct TokenPackConfig {
uint256[] packTokens;
bool isRandomPack;
uint numRandom;
uint numWhiteListBonus;
bool allotOwnedTokenQuantity;
bool isWhiteListBonusAggregatedAcrossAllWhiteLists;
}
struct Whitelist {
string tokenType;
address tokenAddress;
uint mustOwnQuantity;
uint256 tokenId;
bool active;
}
string public _contractURI;
constructor(
string memory _name,
string memory _symbol,
address[] memory _admins,
string memory _contract_URI
) ERC1155("ipfs://") {
name_ = _name;
symbol_ = _symbol;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
for (uint i=0; i< _admins.length; i++) {
_setupRole(DEFAULT_ADMIN_ROLE, _admins[i]);
}
_contractURI = _contract_URI;
}
function getOpenSaleTokens() public view returns (string memory){
string memory open = "";
uint256 numTokens = 0;
while(!compareStrings(tokens[numTokens].ipfsMetadataHash, "")) {
if(isSaleOpen(numTokens)){
open = string(abi.encodePacked(open, Strings.toString(numTokens), ","));
}
numTokens++;
}
return open;
}
function addToken(
string memory _ipfsMetadataHash,
string memory _extraDataUri,
uint256 _windowOpens,
uint256 _windowCloses,
uint256 _mintPrice,
uint256 _maxSupply,
uint256 _maxMintPerTxn,
uint256 _maxPerWallet,
bool _maxQuantityMappedByWhitelistHoldings,
bool _requireAllWhiteLists,
address[] memory _redeemableContracts
) external onlyRole(DEFAULT_ADMIN_ROLE) {
editToken(tokenCounter.current(), _ipfsMetadataHash, _extraDataUri, _windowOpens, _windowCloses, _mintPrice, _maxSupply, _maxMintPerTxn, _maxPerWallet, _maxQuantityMappedByWhitelistHoldings, _requireAllWhiteLists, _redeemableContracts);
tokenCounter.increment();
}
function editToken(
uint256 _tokenIndex,
string memory _ipfsMetadataHash,
string memory _extraDataUri,
uint256 _windowOpens,
uint256 _windowCloses,
uint256 _mintPrice,
uint256 _maxSupply,
uint256 _maxMintPerTxn,
uint256 _maxPerWallet,
bool _maxQuantityMappedByWhitelistHoldings,
bool _requireAllWhiteLists,
address[] memory _redeemableContracts
) public onlyRole(DEFAULT_ADMIN_ROLE) {
Token storage token = tokens[_tokenIndex];
token.mintingConfig.windowOpens = _windowOpens;
token.mintingConfig.windowCloses = _windowCloses;
token.mintingConfig.mintPrice = _mintPrice;
token.mintingConfig.maxSupply = _maxSupply;
token.mintingConfig.maxMintPerTxn = _maxMintPerTxn;
token.mintingConfig.maxPerWallet = _maxPerWallet;
token.ipfsMetadataHash = _ipfsMetadataHash;
token.extraDataUri = _extraDataUri;
for (uint i=0; i<_redeemableContracts.length; i++) {
token.redeemableContracts[i] = _redeemableContracts[i];
}
token.numRedeemableContracts = _redeemableContracts.length;
token.whiteListConfig.maxQuantityMappedByWhitelistHoldings = _maxQuantityMappedByWhitelistHoldings;
token.whiteListConfig.requireAllWhiteLists = _requireAllWhiteLists;
}
function configTokenPack(
uint256 _tokenIndex,
bool _isTokenPack,
uint256[] memory _packTokens,
bool _isRandomPack,
uint _numRandom,
uint _numWhiteListBonus,
bool _allotOwnedTokenQuantity,
bool _isWhiteListBonusAggregatedAcrossAllWhiteLists
)external onlyRole(DEFAULT_ADMIN_ROLE) {
TokenPackConfig storage tokenPackConfig = tokens[_tokenIndex].tokenPackConfig;
tokens[_tokenIndex].isTokenPack = _isTokenPack;
tokenPackConfig.packTokens = _packTokens;
tokenPackConfig.isRandomPack = _isRandomPack;
tokenPackConfig.numRandom = _numRandom;
tokenPackConfig.numWhiteListBonus = _numWhiteListBonus;
tokenPackConfig.allotOwnedTokenQuantity = _allotOwnedTokenQuantity;
tokenPackConfig.isWhiteListBonusAggregatedAcrossAllWhiteLists = _isWhiteListBonusAggregatedAcrossAllWhiteLists;
}
function addWhiteList(
uint256 _tokenIndex,
string memory _tokenType,
address _tokenAddress,
uint _tokenId,
uint _mustOwnQuantity
)external onlyRole(DEFAULT_ADMIN_ROLE) {
Whitelist storage whitelist = tokens[_tokenIndex].whitelistData[tokens[_tokenIndex].numTokenWhitelists];
whitelist.tokenType = _tokenType;
whitelist.tokenId = _tokenId;
whitelist.active = true;
whitelist.tokenAddress = _tokenAddress;
whitelist.mustOwnQuantity = _mustOwnQuantity;
tokens[_tokenIndex].numTokenWhitelists = tokens[_tokenIndex].numTokenWhitelists + 1;
}
function disableWhiteList(
uint256 _tokenIndex,
uint _whiteListIndexToRemove
)external onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[_tokenIndex].whitelistData[_whiteListIndexToRemove].active = false;
}
function editTokenWhiteListMerkleRoot(
uint256 _tokenIndex,
bytes32 _merkleRoot,
bool enabled
) external onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[_tokenIndex].whiteListConfig.merkleRoot = _merkleRoot;
tokens[_tokenIndex].whiteListConfig.hasMerkleRoot = enabled;
}
function burnFromRedeem(
address account,
uint256 tokenIndex,
uint256 amount
) external {
Token storage token = tokens[tokenIndex];
bool hasValidRedemptionContract = false;
if(token.numRedeemableContracts > 0){
for (uint i=0; i < token.numRedeemableContracts; i++) {
if(token.redeemableContracts[i] == msg.sender){
hasValidRedemptionContract = true;
}
}
}
require(hasValidRedemptionContract, "b1");
_burn(account, tokenIndex, amount);
}
function purchase(
uint256[] calldata _quantities,
uint256[] calldata _tokenIndexes,
uint256[] calldata _merkleAmounts,
bytes32[][] calldata _merkleProofs
) external payable {
require(!paused(), "p0");
uint256 totalPrice = 0;
for (uint i=0; i< _tokenIndexes.length; i++) {
totalPrice = totalPrice.add(_quantities[i].mul(tokens[_tokenIndexes[i]].mintingConfig.mintPrice));
}
require(msg.value >= totalPrice, "p1");
for (uint i=0; i< _tokenIndexes.length; i++) {
uint256 quantityToMint = getQualifiedAllocation(msg.sender,_tokenIndexes[i], _quantities[i],_merkleAmounts[i],_merkleProofs[i], true);
require(quantityToMint > 0 && quantityToMint >= _quantities[i], "p2");
uint256[] memory idsToMint;
uint256[] memory quantitiesToMint;
if(tokens[_tokenIndexes[i]].isTokenPack){
quantityToMint = getQualifiedAllocation(msg.sender,_tokenIndexes[i], _quantities[i],_merkleAmounts[i],_merkleProofs[i], false);
for (uint j=0; j < _quantities[i]; j++) {
uint256[] memory inStockTokens = filterInStockTokensFromPack(tokens[_tokenIndexes[i]].tokenPackConfig, j);
if(tokens[_tokenIndexes[i]].tokenPackConfig.isRandomPack){
idsToMint = new uint256[](quantityToMint);
quantitiesToMint = new uint256[](quantityToMint);
uint startingIndex = 0;
uint q = 0;
while(q < quantityToMint) {
idsToMint[q] = inStockTokens[startingIndex];
quantitiesToMint[q] = 1;
if(startingIndex < inStockTokens.length - 1){
startingIndex = startingIndex + 1;
}
else{
startingIndex = 0;
}
q = q + 1;
}
}
else{
idsToMint = new uint256[](inStockTokens.length);
for (uint q=0; q < inStockTokens.length; q++) {
idsToMint[q] = inStockTokens[q];
quantitiesToMint[q] = 1;
}
}
_mintBatch(msg.sender, idsToMint, quantitiesToMint, "");
emit Purchased(idsToMint, msg.sender, quantitiesToMint);
tokens[_tokenIndexes[i]].mintingConfig.numMinted = tokens[_tokenIndexes[i]].mintingConfig.numMinted + 1;
}
}
else{
idsToMint = new uint256[](1);
idsToMint[0] = _tokenIndexes[i];
quantitiesToMint = new uint256[](1);
quantitiesToMint[0] = _quantities[i];
_mintBatch(msg.sender, idsToMint, quantitiesToMint, "");
emit Purchased(idsToMint, msg.sender, quantitiesToMint);
}
tokens[_tokenIndexes[i]].claimedTokens[msg.sender] = tokens[_tokenIndexes[i]].claimedTokens[msg.sender].add(_quantities[i]);
}
}
function filterInStockTokensFromPack(TokenPackConfig memory tokenPackConfig, uint seed) internal view returns(uint256[] memory){
tokenPackConfig.packTokens = shuffle(tokenPackConfig.packTokens, false, seed);
uint256[] memory inStockTokens;
uint totalInStock = 0;
for (uint i=0; i < tokenPackConfig.packTokens.length; i++) {
if(getTokenSupply(tokenPackConfig.packTokens[i]) < tokens[tokenPackConfig.packTokens[i]].mintingConfig.maxSupply){
totalInStock++;
}
}
inStockTokens = new uint256[](totalInStock);
uint startingIndex = 0;
for (uint i=0; i < tokenPackConfig.packTokens.length; i++) {
if(getTokenSupply(tokenPackConfig.packTokens[i]) < tokens[tokenPackConfig.packTokens[i]].mintingConfig.maxSupply){
inStockTokens[startingIndex] = tokenPackConfig.packTokens[i];
startingIndex++;
}
}
return inStockTokens;
}
function shuffle(uint256[] memory numberArr, bool returnRandomIndex, uint seed) internal view returns(uint256[] memory){
if(!returnRandomIndex){
for (uint256 i = 0; i < numberArr.length; i++) {
uint256 n = i + uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % (numberArr.length - i);
uint256 temp = numberArr[n];
numberArr[n] = numberArr[i];
numberArr[i] = temp;
}
}
else{
uint randomHash = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % numberArr.length;
uint256[] memory retNumberArr = new uint256[](1);
retNumberArr[0] = numberArr[randomHash];
numberArr = retNumberArr;
}
return numberArr;
}
function mintBatch(
address to,
uint256[] calldata qty,
uint256[] calldata _tokens) public onlyRole(DEFAULT_ADMIN_ROLE)
{
_mintBatch(to, _tokens, qty, "");
}
function getQualifiedAllocation(address sender,
uint256 tokenIndex,
uint256 quantity,
uint256 amount,
bytes32[] calldata merkleProof,
bool returnAllocationOnly) public view returns (uint256) {
Token storage token = tokens[tokenIndex];
if(!returnAllocationOnly){
require(token.mintingConfig.saleIsOpen, "v1");
require(!paused(), "v2");
require(token.mintingConfig.windowOpens > 0, "v3");
require (block.timestamp > token.mintingConfig.windowOpens && block.timestamp < token.mintingConfig.windowCloses, "v4");
require(token.claimedTokens[sender].add(quantity) <= amount, "v5");
require(token.claimedTokens[sender].add(quantity) <= token.mintingConfig.maxPerWallet, "v6");
require(quantity <= token.mintingConfig.maxMintPerTxn, "v7");
require(getTokenSupply(tokenIndex) + quantity <= token.mintingConfig.maxSupply, "v8");
}
uint256 totalAllowed = token.mintingConfig.maxPerWallet;
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
totalAllowed = 0;
}
uint256 whiteListsValidAmounts = 0;
if(token.numTokenWhitelists > 0){
uint256 balance = 0;
uint256 _wl_amount = 0;
for (uint i=0; i < token.numTokenWhitelists; i++) {
if(token.whitelistData[i].active){
_wl_amount = verifyWhitelist(sender, tokenIndex, i, returnAllocationOnly);
if(token.whiteListConfig.requireAllWhiteLists){
require( verifyWhitelist(sender, tokenIndex, i, returnAllocationOnly) > 0, "v9");
}
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
Whitelist memory balanceRequest;
balanceRequest.tokenType = token.whitelistData[i].tokenType;
balanceRequest.tokenAddress = token.whitelistData[i].tokenAddress;
balanceRequest.tokenId = token.whitelistData[i].tokenId;
balance = getExternalTokenBalance(sender, balanceRequest);
totalAllowed += balance;
whiteListsValidAmounts += balance;
}
else{
whiteListsValidAmounts = _wl_amount;
}
}
}
}
else{
whiteListsValidAmounts = token.mintingConfig.maxMintPerTxn;
}
if(!returnAllocationOnly){
require(whiteListsValidAmounts > 0, "v10");
if(token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
require(token.claimedTokens[sender].add(quantity) <= totalAllowed, "v11");
}
}
if(token.whiteListConfig.hasMerkleRoot){
require(
verifyMerkleProof(merkleProof, tokenIndex, amount),
"v12"
);
}
if(returnAllocationOnly){
return whiteListsValidAmounts < quantity ? whiteListsValidAmounts : quantity;
}
else{
return whiteListsValidAmounts;
}
}
function verifyWhitelist(address sender, uint256 tokenIndex, uint whitelistIndex, bool returnAllocationOnly) internal view returns (uint256) {
uint256 isValid = 0;
uint256 balanceOf = 0;
Token storage token = tokens[tokenIndex];
Whitelist memory balanceRequest;
balanceRequest.tokenType = token.whitelistData[whitelistIndex].tokenType;
balanceRequest.tokenAddress = token.whitelistData[whitelistIndex].tokenAddress;
balanceRequest.tokenId = token.whitelistData[whitelistIndex].tokenId;
balanceOf = getExternalTokenBalance(sender, balanceRequest);
bool meetsWhiteListReqs = (balanceOf >= token.whitelistData[whitelistIndex].mustOwnQuantity);
if(token.isTokenPack && !returnAllocationOnly){
if(token.tokenPackConfig.isRandomPack){
isValid = isValid + token.tokenPackConfig.numRandom;
}
else{
isValid = isValid + token.tokenPackConfig.packTokens.length;
}
if(token.tokenPackConfig.numWhiteListBonus > 0 && meetsWhiteListReqs){
isValid = isValid + token.tokenPackConfig.numWhiteListBonus;
}
}
else if(token.isTokenPack && token.tokenPackConfig.allotOwnedTokenQuantity && meetsWhiteListReqs){
isValid = balanceOf;
}
else if(!token.isTokenPack && token.whiteListConfig.maxQuantityMappedByWhitelistHoldings){
isValid = balanceOf;
}
else if( meetsWhiteListReqs){
isValid = token.mintingConfig.maxMintPerTxn;
}
if(isValid == 0 && !token.whiteListConfig.requireAllWhiteLists){
isValid = token.mintingConfig.maxMintPerTxn;
}
return isValid;
}
function getExternalTokenBalance (address sender, Whitelist memory balanceRequest) public view returns (uint256) {
if(compareStrings(balanceRequest.tokenType, "ERC721")){
WhitelistContract721 _contract = WhitelistContract721(balanceRequest.tokenAddress);
return _contract.balanceOf(sender);
}
else if(compareStrings(balanceRequest.tokenType, "ERC1155")){
WhitelistContract1155 _contract = WhitelistContract1155(balanceRequest.tokenAddress);
return _contract.balanceOf(sender, balanceRequest.tokenId);
}
}
function isSaleOpen(uint256 tokenIndex) public view returns (bool) {
Token storage token = tokens[tokenIndex];
if(paused()){
return false;
}
if(block.timestamp > token.mintingConfig.windowOpens && block.timestamp < token.mintingConfig.windowCloses){
return token.mintingConfig.saleIsOpen;
}
return false;
}
function toggleSale(uint256 mpIndex, bool on) public onlyRole(DEFAULT_ADMIN_ROLE) {
tokens[mpIndex].mintingConfig.saleIsOpen = on;
}
function makeLeaf(address _addr, uint amount) internal view returns (string memory) {
bytes memory s = new bytes(40);
for (uint i = 0; i < 20; i++) {
bytes1 b = bytes1(uint8(uint(uint160(_addr)) / (2**(8*(19 - i)))));
bytes1 hi = bytes1(uint8(b) / 16);
bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));
s[2*i] = char(hi);
s[2*i+1] = char(lo);
}
return string(abi.encodePacked(string(s), "_", Strings.toString(amount)));
}
function verifyMerkleProof(bytes32[] calldata merkleProof, uint256 mpIndex, uint amount) internal view returns (bool) {
if(!tokens[mpIndex].whiteListConfig.hasMerkleRoot){
return true;
}
string memory leaf = makeLeaf(msg.sender, amount);
bytes32 node = keccak256(abi.encode(leaf));
return MerkleProof.verify(merkleProof, tokens[mpIndex].whiteListConfig.merkleRoot, node);
}
function compareStrings(string memory a, string memory b) internal view returns (bool) {
return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
}
function char(bytes1 b) internal view returns (bytes1 c) {
if (uint8(b) < 10) return bytes1(uint8(b) + 0x30);
else return bytes1(uint8(b) + 0x57);
}
function withdrawEther(address payable _to, uint256 _amount) public onlyOwner
{
_to.transfer(_amount);
}
function uri(uint256 _id) public view override returns (string memory) {
require(getTokenSupply(_id) > 0, "URI: na");
if(compareStrings(tokens[_id].ipfsMetadataHash, "")){
return string(abi.encodePacked(super.uri(_id), Strings.toString(_id)));
}
else{
return string(abi.encodePacked(tokens[_id].ipfsMetadataHash));
}
}
function setContractURI(string memory uri) external onlyRole(DEFAULT_ADMIN_ROLE){
_contractURI = uri;
}
function contractURI() public view returns (string memory) {
return _contractURI;
}
function getTokenSupply(uint256 tokenIndex) public view returns (uint256) {
Token storage token = tokens[tokenIndex];
return token.isTokenPack ? token.mintingConfig.numMinted : totalSupply(tokenIndex);
}
}
contract WhitelistContract1155 {
function balanceOf(address account, uint256 id) external view returns (uint256) {}
}
contract WhitelistContract721 {
function balanceOf(address account) external view returns (uint256) {}
}
Abstract1155Factory.sol 94 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/access/AccessControl.sol";
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol';
import '@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol';
abstract contract Abstract1155Factory is AccessControl, ERC1155Pausable, ERC1155Supply, ERC1155Burnable, Ownable {
string public name_;
string public symbol_;
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function setURI(string memory baseURI) external onlyOwner {
_setURI(baseURI);
}
function name() public view returns (string memory) {
return name_;
}
function symbol() public view returns (string memory) {
return symbol_;
}
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual override(ERC1155, ERC1155Supply) {
super._mint(account, id, amount, data);
}
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155, ERC1155Supply) {
super._mintBatch(to, ids, amounts, data);
}
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual override(ERC1155, ERC1155Supply) {
super._burn(account, id, amount);
}
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual override(ERC1155, ERC1155Supply) {
super._burnBatch(account, ids, amounts);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override(ERC1155Pausable, ERC1155) {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function setOwner(address _addr) public onlyOwner {
transferOwnership(_addr);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
Address.sol 216 lines
// SPDX-License-Identifier: MIT
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 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT
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 71 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Counters.sol 42 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
Pausable.sol 90 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
SafeMath.sol 226 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
AccessControl.sol 210 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IAccessControl.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
ERC1155.sol 451 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
require(account != address(0), "ERC1155: balance query for the zero address");
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(_msgSender() != operator, "ERC1155: setting approval status for self");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `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 memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - 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[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
unchecked {
_balances[id][from] = fromBalance - amount;
}
_balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `account`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(account != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data);
_balances[id][account] += amount;
emit TransferSingle(operator, address(0), account, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
_balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `account`
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");
uint256 accountBalance = _balances[id][account];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][account] = accountBalance - amount;
}
emit TransferSingle(operator, account, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 accountBalance = _balances[id][account];
require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][account] = accountBalance - amount;
}
}
emit TransferBatch(operator, account, address(0), ids, amounts);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
IERC1155.sol 124 lines
// SPDX-License-Identifier: MIT
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 28 lines
// SPDX-License-Identifier: MIT
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 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC1155Receiver.sol 52 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 43 lines
// SPDX-License-Identifier: MIT
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) {
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));
}
}
// Check if the computed hash (root) is equal to the provided root
return computedHash == root;
}
}
ERC1155Supply.sol 85 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of ERC1155 that adds tracking of total supply per id.
*
* Useful for scenarios where Fungible and Non-fungible tokens have to be
* clearly identified. Note: While a totalSupply of 1 might mean the
* corresponding is an NFT, there is no guarantees that no other token with the
* same id are not going to be minted.
*/
abstract contract ERC1155Supply is ERC1155 {
mapping(uint256 => uint256) private _totalSupply;
/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply[id];
}
/**
* @dev Indicates weither any token exist with a given id, or not.
*/
function exists(uint256 id) public view virtual returns (bool) {
return ERC1155Supply.totalSupply(id) > 0;
}
/**
* @dev See {ERC1155-_mint}.
*/
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual override {
super._mint(account, id, amount, data);
_totalSupply[id] += amount;
}
/**
* @dev See {ERC1155-_mintBatch}.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._mintBatch(to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
/**
* @dev See {ERC1155-_burn}.
*/
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual override {
super._burn(account, id, amount);
_totalSupply[id] -= amount;
}
/**
* @dev See {ERC1155-_burnBatch}.
*/
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual override {
super._burnBatch(account, ids, amounts);
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] -= amounts[i];
}
}
}
ERC1155Burnable.sol 39 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of {ERC1155} that allows token holders to destroy both their
* own tokens and those that they have been approved to use.
*
* _Available since v3.1._
*/
abstract contract ERC1155Burnable is ERC1155 {
function burn(
address account,
uint256 id,
uint256 value
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burn(account, id, value);
}
function burnBatch(
address account,
uint256[] memory ids,
uint256[] memory values
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_burnBatch(account, ids, values);
}
}
ERC1155Pausable.sol 37 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC1155.sol";
import "../../../security/Pausable.sol";
/**
* @dev ERC1155 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*
* _Available since v3.1._
*/
abstract contract ERC1155Pausable is ERC1155, Pausable {
/**
* @dev See {ERC1155-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
require(!paused(), "ERC1155Pausable: token transfer while paused");
}
}
IERC1155MetadataURI.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
_contractURI 0xc0e72740 → string
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
contractURI 0xe8a3d485 → string
exists 0x4f558e79 → bool
getExternalTokenBalance 0x8e1688eb → uint256
getOpenSaleTokens 0x589b2162 → string
getQualifiedAllocation 0xd6b15c4c → uint256
getRoleAdmin 0x248a9ca3 → bytes32
getTokenSupply 0x19b88edb → uint256
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
isSaleOpen 0x4044556d → bool
name 0x06fdde03 → string
name_ 0xe2b9e186 → string
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
symbol_ 0xaf17dea6 → string
tokens 0x4f64b2be → string, string, uint256, uint256, tuple, tuple, bool, tuple
totalSupply 0xbd85b039 → uint256
uri 0x0e89341c → string
Write Contract 26 functions
These functions modify contract state and require a wallet transaction to execute.
addToken 0x45301760
string _ipfsMetadataHash
string _extraDataUri
uint256 _windowOpens
uint256 _windowCloses
uint256 _mintPrice
uint256 _maxSupply
uint256 _maxMintPerTxn
uint256 _maxPerWallet
bool _maxQuantityMappedByWhitelistHoldings
bool _requireAllWhiteLists
address[] _redeemableContracts
addWhiteList 0xdd66489e
uint256 _tokenIndex
string _tokenType
address _tokenAddress
uint256 _tokenId
uint256 _mustOwnQuantity
burn 0xf5298aca
address account
uint256 id
uint256 value
burnBatch 0x6b20c454
address account
uint256[] ids
uint256[] values
burnFromRedeem 0x3aeca210
address account
uint256 tokenIndex
uint256 amount
configTokenPack 0x3a4da729
uint256 _tokenIndex
bool _isTokenPack
uint256[] _packTokens
bool _isRandomPack
uint256 _numRandom
uint256 _numWhiteListBonus
bool _allotOwnedTokenQuantity
bool _isWhiteListBonusAggregatedAcrossAllWhiteLists
disableWhiteList 0x7d737203
uint256 _tokenIndex
uint256 _whiteListIndexToRemove
editToken 0xa8afbca1
uint256 _tokenIndex
string _ipfsMetadataHash
string _extraDataUri
uint256 _windowOpens
uint256 _windowCloses
uint256 _mintPrice
uint256 _maxSupply
uint256 _maxMintPerTxn
uint256 _maxPerWallet
bool _maxQuantityMappedByWhitelistHoldings
bool _requireAllWhiteLists
address[] _redeemableContracts
editTokenWhiteListMerkleRoot 0xd5ebd788
uint256 _tokenIndex
bytes32 _merkleRoot
bool enabled
grantRole 0x2f2ff15d
bytes32 role
address account
mintBatch 0xd81d0a15
address to
uint256[] qty
uint256[] _tokens
pause 0x8456cb59
No parameters
purchase 0x70765746
uint256[] _quantities
uint256[] _tokenIndexes
uint256[] _merkleAmounts
bytes32[][] _merkleProofs
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 id
uint256 amount
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setContractURI 0x938e3d7b
string uri
setOwner 0x13af4035
address _addr
setURI 0x02fe5305
string baseURI
toggleSale 0x065eb117
uint256 mpIndex
bool on
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
withdrawEther 0x522f6815
address _to
uint256 _amount
Recent Transactions
No transactions found for this address