Address Contract Verified
Address
0xe1F336d20e1875B4D6807589eD25d9b497bb67d1
Balance
0 ETH
Nonce
9
Code Size
24552 bytes
Creator
0x6e25cFa7...4dF0 at tx 0xcef17b96...91c7e0
Indexed Transactions
0
Contract Bytecode
24552 bytes
0x60806040523480156200001157600080fd5b5060043610620000b25760003560e01c806306609bbe14620000b75780630e025c87146200010057806331f5ae8414620001195780633b4244e614620001305780635543192814620001445780635ee7d9a21462000158578063715018a6146200016c5780637796ff3714620001765780638da5cb5b14620001a0578063b6d9138714620001aa578063c5f956af14620001be578063f2fde38b14620001d2575b600080fd5b620000e3620000c8366004620005cb565b6001602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001176200011136600462000613565b620001e9565b005b620001176200012a36600462000a33565b62000270565b600654620000e3906001600160a01b031681565b600454620000e3906001600160a01b031681565b600354620000e3906001600160a01b031681565b6200011762000460565b6003546200018c90600160a01b900461ffff1681565b60405161ffff9091168152602001620000f7565b620000e362000478565b600554620000e3906001600160a01b031681565b600254620000e3906001600160a01b031681565b62000117620001e336600462000b61565b62000487565b620001f36200050a565b600380546001600160a01b039687166001600160a01b031961ffff909716600160a01b0287166001600160b01b031990921691909117179055600280549686169685169690961790955560058054918516918416919091179055600680549484169483169490941790935560048054939092169216919091179055565b82518451146200027f57600080fd5b6003546040516331a9108f60e11b815261ffff8716600482015233916001600160a01b031690636352211e90602401602060405180830381865afa158015620002cc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002f2919062000b88565b6001600160a01b0316146200030657600080fd5b6040805160038082526080820190925260009160208201606080368337505060055482519293506001600160a01b0316918391506000906200034c576200034c62000ba8565b6001600160a01b03928316602091820292909201015260065482519116908290600190811062000380576200038062000ba8565b6001600160a01b039283166020918202929092010152600454825191169082906002908110620003b457620003b462000ba8565b60200260200101906001600160a01b031690816001600160a01b03168152505060008a8a8a8a898933888b8b604051620003ee90620005bd565b620004039a9998979695949392919062000d36565b604051809103906000f08015801562000420573d6000803e3d6000fd5b5061ffff97909716600090815260016020526040902080546001600160a01b0319166001600160a01b039098169790971790965550505050505050505050565b6200046a6200050a565b6200047660006200056d565b565b6000546001600160a01b031690565b620004916200050a565b6001600160a01b038116620004fc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b62000507816200056d565b50565b336200051562000478565b6001600160a01b031614620004765760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620004f3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6151788062000e3b83390190565b600060208284031215620005de57600080fd5b5035919050565b6001600160a01b03811681146200050757600080fd5b803561ffff811681146200060e57600080fd5b919050565b60008060008060008060c087890312156200062d57600080fd5b86356200063a81620005e5565b955060208701356200064c81620005e5565b94506200065c60408801620005fb565b935060608701356200066e81620005e5565b925060808701356200068081620005e5565b915060a08701356200069281620005e5565b809150509295509295509295565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b0381118282101715620006dc57620006dc620006a0565b60405290565b604051601f8201601f191681016001600160401b03811182821017156200070d576200070d620006a0565b604052919050565b600082601f8301126200072757600080fd5b81356001600160401b03811115620007435762000743620006a0565b62000758601f8201601f1916602001620006e2565b8181528460208386010111156200076e57600080fd5b816020850160208301376000918101602001919091529392505050565b60006001600160401b03821115620007a757620007a7620006a0565b5060051b60200190565b600082601f830112620007c357600080fd5b81356020620007dc620007d6836200078b565b620006e2565b82815260059290921b84018101918181019086841115620007fc57600080fd5b8286015b84811015620008245780356200081681620005e5565b835291830191830162000800565b509695505050505050565b600082601f8301126200084157600080fd5b8135602062000854620007d6836200078b565b82815260059290921b840181019181810190868411156200087457600080fd5b8286015b8481101562000824578035835291830191830162000878565b803580151581146200060e57600080fd5b80356001600160481b03811681146200060e57600080fd5b60006101808284031215620008ce57600080fd5b620008d8620006b6565b9050620008e582620005fb565b8152620008f56020830162000891565b60208201526200090860408301620005fb565b60408201526200091b60608301620008a2565b60608201526200092e60808301620008a2565b60808201526200094160a0830162000891565b60a08201526200095460c0830162000891565b60c08201526200096760e0830162000891565b60e08201526101006200097c81840162000891565b908201526101206200099083820162000891565b90820152610140620009a4838201620005fb565b90820152610160620009b883820162000891565b9082015292915050565b600060408284031215620009d557600080fd5b604080519081016001600160401b0381118282101715620009fa57620009fa620006a0565b604052905080823562000a0d81620005e5565b8152602083013562ffffff8116811462000a2657600080fd5b6020919091015292915050565b60008060008060008060008060006102a08a8c03121562000a5357600080fd5b62000a5e8a620005fb565b985060208a01356001600160401b038082111562000a7b57600080fd5b62000a898d838e0162000715565b995060408c013591508082111562000aa057600080fd5b62000aae8d838e0162000715565b985060608c013591508082111562000ac557600080fd5b62000ad38d838e0162000715565b975062000ae360808d01620005fb565b965060a08c013591508082111562000afa57600080fd5b62000b088d838e01620007b1565b955060c08c013591508082111562000b1f57600080fd5b5062000b2e8c828d016200082f565b93505062000b408b60e08c01620008ba565b915062000b528b6102608c01620009c2565b90509295985092959850929598565b60006020828403121562000b7457600080fd5b813562000b8181620005e5565b9392505050565b60006020828403121562000b9b57600080fd5b815162000b8181620005e5565b634e487b7160e01b600052603260045260246000fd5b6000815180845260005b8181101562000be65760208185018101518683018201520162000bc8565b8181111562000bf9576000602083870101525b50601f01601f19169290920160200192915050565b600081518084526020808501945080840160005b8381101562000c495781516001600160a01b03168752958201959082019060010162000c22565b509495945050505050565b805161ffff168252602081015162000c70602084018215159052565b50604081015162000c87604084018261ffff169052565b50606081015162000ca360608401826001600160481b03169052565b50608081015162000cbf60808401826001600160481b03169052565b5060a081015162000cd460a084018215159052565b5060c081015162000ce960c084018215159052565b5060e081015162000cfe60e084018215159052565b5061010081810151151590830152610120808201511515908301526101408082015161ffff1690830152610160908101511515910152565b60006102c061ffff8d1683526020818185015262000d578285018e62000bbe565b9150838203604085015262000d6d828d62000bbe565b9150838203606085015262000d83828c62000bbe565b9150838203608085015262000d99828b62000c0e565b84810360a08601528951808252828b0193509082019060005b8181101562000dd05784518352938301939183019160010162000db2565b50506001600160a01b03891660c086015284810360e086015262000df5818962000c0e565b935050505062000e0a61010083018562000c54565b82516001600160a01b0316610280830152602083015162ffffff166102a08301529b9a505050505050505050505056fe60a06040523480156200001157600080fd5b506040516200517838038062005178833981016040819052620000349162000de1565b826000815181106200004a576200004a62000f39565b6020026020010151733cc6cdda760b79bafa08df41ecfa224f810dceb6600188888b6200007d816200062760201b60201c565b50620000893362000640565b8051825114620000fb5760405162461bcd60e51b815260206004820152603260248201527f5061796d656e7453706c69747465723a2070617965657320616e6420736861726044820152710cae640d8cadccee8d040dad2e6dac2e8c6d60731b60648201526084015b60405180910390fd5b60008251116200014e5760405162461bcd60e51b815260206004820152601a60248201527f5061796d656e7453706c69747465723a206e6f207061796565730000000000006044820152606401620000f2565b60005b8251811015620001ba57620001a583828151811062000174576200017462000f39565b602002602001015183838151811062000191576200019162000f39565b60200260200101516200069260201b60201c565b80620001b18162000f65565b91505062000151565b50506001600b55506daaeb6d7670e522a718067333cd4e3b15620002f45780156200024e57604051633e9f1edf60e11b81526daaeb6d7670e522a718067333cd4e90637d3e3dbe9062000214903090869060040162000f81565b600060405180830381600087803b1580156200022f57600080fd5b505af115801562000244573d6000803e3d6000fd5b50505050620002f4565b6001600160a01b03821615620002935760405163a0af290360e01b81526daaeb6d7670e522a718067333cd4e9063a0af29039062000214903090869060040162000f81565b604051632210724360e11b81523060048201526daaeb6d7670e522a718067333cd4e90634420e48690602401600060405180830381600087803b158015620002da57600080fd5b505af1158015620002ef573d6000803e3d6000fd5b505050505b5050600c80546001600160a01b0319166001600160a01b039290921691909117905588516200032b9060129060208c01906200095d565b508751620003419060139060208b01906200095d565b508651620003579060149060208a01906200095d565b5081600e60008c61ffff16815260200190815260200160002060008201518160000160006101000a81548161ffff021916908361ffff16021790555060208201518160000160026101000a81548160ff02191690831515021790555060408201518160000160036101000a81548161ffff021916908361ffff16021790555060608201518160000160056101000a8154816001600160481b0302191690836001600160481b03160217905550608082015181600001600e6101000a8154816001600160481b0302191690836001600160481b0316021790555060a08201518160000160176101000a81548160ff02191690831515021790555060c08201518160000160186101000a81548160ff02191690831515021790555060e08201518160000160196101000a81548160ff02191690831515021790555061010082015181600001601a6101000a81548160ff02191690831515021790555061012082015181600001601b6101000a81548160ff02191690831515021790555061014082015181600001601c6101000a81548161ffff021916908361ffff16021790555061016082015181600001601e6101000a81548160ff02191690831515021790555090505080600d60008c61ffff16815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160000160146101000a81548162ffffff021916908362ffffff160217905550905050826001815181106200059d576200059d62000f39565b60200260200101516001600160a01b03166080816001600160a01b03168152505060016011600085600281518110620005da57620005da62000f39565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055620006178462000880565b5050505050505050505062000ff2565b80516200063c9060029060208401906200095d565b5050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216620006ff5760405162461bcd60e51b815260206004820152602c60248201527f5061796d656e7453706c69747465723a206163636f756e74206973207468652060448201526b7a65726f206164647265737360a01b6064820152608401620000f2565b60008111620007515760405162461bcd60e51b815260206004820152601d60248201527f5061796d656e7453706c69747465723a207368617265732061726520300000006044820152606401620000f2565b6001600160a01b03821660009081526006602052604090205415620007cd5760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e7420616c726561647960448201526a206861732073686172657360a81b6064820152608401620000f2565b60088054600181019091557ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30180546001600160a01b0319166001600160a01b03841690811790915560009081526006602052604090208190556004546200083790829062000f9b565b600455604080516001600160a01b0384168152602081018390527f40c340f65e17194d14ddddb073d3c9f888e3cb52b5aae0c6c7706b4fbc905fac910160405180910390a15050565b6200088a620008ff565b6001600160a01b038116620008f15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401620000f2565b620008fc8162000640565b50565b6003546001600160a01b031633146200095b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401620000f2565b565b8280546200096b9062000fb6565b90600052602060002090601f0160209004810192826200098f5760008555620009da565b82601f10620009aa57805160ff1916838001178555620009da565b82800160010185558215620009da579182015b82811115620009da578251825591602001919060010190620009bd565b50620009e8929150620009ec565b5090565b5b80821115620009e85760008155600101620009ed565b805161ffff8116811462000a1657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60405161018081016001600160401b038111828210171562000a575762000a5762000a1b565b60405290565b604051601f8201601f191681016001600160401b038111828210171562000a885762000a8862000a1b565b604052919050565b600082601f83011262000aa257600080fd5b81516001600160401b0381111562000abe5762000abe62000a1b565b602062000ad4601f8301601f1916820162000a5d565b828152858284870101111562000ae957600080fd5b60005b8381101562000b0957858101830151828201840152820162000aec565b8381111562000b1b5760008385840101525b5095945050505050565b60006001600160401b0382111562000b415762000b4162000a1b565b5060051b60200190565b80516001600160a01b038116811462000a1657600080fd5b600082601f83011262000b7557600080fd5b8151602062000b8e62000b888362000b25565b62000a5d565b82815260059290921b8401810191818101908684111562000bae57600080fd5b8286015b8481101562000bd45762000bc68162000b4b565b835291830191830162000bb2565b509695505050505050565b600082601f83011262000bf157600080fd5b8151602062000c0462000b888362000b25565b82815260059290921b8401810191818101908684111562000c2457600080fd5b8286015b8481101562000bd4578051835291830191830162000c28565b8051801515811462000a1657600080fd5b80516001600160481b038116811462000a1657600080fd5b6000610180828403121562000c7e57600080fd5b62000c8862000a31565b905062000c958262000a03565b815262000ca56020830162000c41565b602082015262000cb86040830162000a03565b604082015262000ccb6060830162000c52565b606082015262000cde6080830162000c52565b608082015262000cf160a0830162000c41565b60a082015262000d0460c0830162000c41565b60c082015262000d1760e0830162000c41565b60e082015261010062000d2c81840162000c41565b9082015261012062000d4083820162000c41565b9082015261014062000d5483820162000a03565b9082015261016062000d6883820162000c41565b9082015292915050565b60006040828403121562000d8557600080fd5b604080519081016001600160401b038111828210171562000daa5762000daa62000a1b565b60405290508062000dbb8362000b4b565b8152602083015162ffffff8116811462000dd457600080fd5b6020919091015292915050565b6000806000806000806000806000806102c08b8d03121562000e0257600080fd5b62000e0d8b62000a03565b60208c0151909a506001600160401b038082111562000e2b57600080fd5b62000e398e838f0162000a90565b9a5060408d015191508082111562000e5057600080fd5b62000e5e8e838f0162000a90565b995060608d015191508082111562000e7557600080fd5b62000e838e838f0162000a90565b985060808d015191508082111562000e9a57600080fd5b62000ea88e838f0162000b63565b975060a08d015191508082111562000ebf57600080fd5b62000ecd8e838f0162000bdf565b965062000edd60c08e0162000b4b565b955060e08d015191508082111562000ef457600080fd5b5062000f038d828e0162000b63565b93505062000f168c6101008d0162000c6a565b915062000f288c6102808d0162000d72565b90509295989b9194979a5092959850565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000f7a5762000f7a62000f4f565b5060010190565b6001600160a01b0392831681529116602082015260400190565b6000821982111562000fb15762000fb162000f4f565b500190565b600181811c9082168062000fcb57607f821691505b60208210810362000fec57634e487b7160e01b600052602260045260246000fd5b50919050565b60805161416a6200100e6000396000610d74015261416a6000f3fe6080604052600436106101ef5760003560e01c8062fdd58e1461023457806301ffc9a71461026757806302fe53051461029757806303780733146102b957806306fdde03146103085780630e89341c1461032a578063191655871461034a57806321b6e6311461036a57806321b97f201461037d5780632a55205a1461039d5780632eb2c2d6146103cb5780633a98ef39146103eb578063406072a91461040057806341f434341461042057806348b750441461044f5780634e1273f41461046f5780634f64b2be1461049c57806353f89b20146105c2578063715018a6146105e25780637e7351af146105f75780637f77f57414610617578063873f6f9e1461067e5780638b83209b146106ba5780638cb4a267146106da5780638da5cb5b146106fa57806395d89b411461070f5780639852595c146107245780639df806d614610744578063a22cb46514610764578063a3f8eace14610784578063b6d91387146107a4578063c45ac050146107c4578063ce7c2ac2146107e4578063d79779b21461081a578063da8f08541461083a578063dd6a40a41461085a578063e2c7f3381461087a578063e33b7de31461089a578063e6a5b9b2146108af578063e7975709146108cf578063e985e9c5146108ff578063f242432a14610948578063f2fde38b1461096857600080fd5b3661022f577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be770333460405161022592919061312a565b60405180910390a1005b600080fd5b34801561024057600080fd5b5061025461024f366004613158565b610988565b6040519081526020015b60405180910390f35b34801561027357600080fd5b5061028761028236600461319a565b610a1e565b604051901515815260200161025e565b3480156102a357600080fd5b506102b76102b2366004613256565b610a70565b005b3480156102c557600080fd5b506102f56102d436600461329e565b600f60209081526000928352604080842090915290825290205461ffff1681565b60405161ffff909116815260200161025e565b34801561031457600080fd5b5061031d610a8f565b60405161025e9190613326565b34801561033657600080fd5b5061031d610345366004613339565b610b1d565b34801561035657600080fd5b506102b7610365366004613362565b610bf6565b6102b76103783660046133a2565b610cd4565b34801561038957600080fd5b506102b7610398366004613339565b610f46565b3480156103a957600080fd5b506103bd6103b836600461347e565b610f53565b60405161025e92919061312a565b3480156103d757600080fd5b506102b76103e6366004613531565b610f9e565b3480156103f757600080fd5b50600454610254565b34801561040c57600080fd5b5061025461041b3660046135de565b61103e565b34801561042c57600080fd5b506104426daaeb6d7670e522a718067333cd4e81565b60405161025e919061360c565b34801561045b57600080fd5b506102b761046a3660046135de565b611069565b34801561047b57600080fd5b5061048f61048a36600461368f565b611177565b60405161025e919061372d565b3480156104a857600080fd5b506105486104b7366004613339565b600e6020526000908152604090205461ffff8082169160ff620100008204811692630100000083048116926001600160481b03600160281b8204811693600160701b830490911692600160b81b8304821692600160c01b8104831692600160c81b8204811692600160d01b8304821692600160d81b8104831692600160e01b820490921691600160f01b909104168c565b6040805161ffff9d8e1681529b151560208d0152998c16998b01999099526001600160481b0397881660608b015296909516608089015292151560a088015290151560c0870152151560e086015215156101008501521515610120840152929092166101408201529015156101608201526101800161025e565b3480156105ce57600080fd5b506102b76105dd366004613740565b6112a0565b3480156105ee57600080fd5b506102b7611320565b34801561060357600080fd5b506102b7610612366004613787565b611334565b34801561062357600080fd5b5061065b610632366004613339565b600d602052600090815260409020546001600160a01b03811690600160a01b900462ffffff1682565b604080516001600160a01b03909316835262ffffff90911660208301520161025e565b34801561068a57600080fd5b506102f561069936600461329e565b601060209081526000928352604080842090915290825290205461ffff1681565b3480156106c657600080fd5b506104426106d5366004613339565b6113e3565b3480156106e657600080fd5b506102b76106f5366004613339565b611413565b34801561070657600080fd5b50610442611420565b34801561071b57600080fd5b5061031d61142f565b34801561073057600080fd5b5061025461073f366004613362565b61143c565b34801561075057600080fd5b506102b761075f366004613362565b611457565b34801561077057600080fd5b506102b761077f3660046137da565b611481565b34801561079057600080fd5b5061025461079f366004613362565b61148c565b3480156107b057600080fd5b50600c54610442906001600160a01b031681565b3480156107d057600080fd5b506102546107df3660046135de565b6114be565b3480156107f057600080fd5b506102546107ff366004613362565b6001600160a01b031660009081526006602052604090205490565b34801561082657600080fd5b50610254610835366004613362565b61155a565b34801561084657600080fd5b506102b7610855366004613831565b611575565b34801561086657600080fd5b506102b76108753660046137da565b61172a565b34801561088657600080fd5b506102b76108953660046138dc565b611781565b3480156108a657600080fd5b50600554610254565b3480156108bb57600080fd5b506102b76108ca366004613981565b6117e0565b3480156108db57600080fd5b506102876108ea366004613362565b60116020526000908152604090205460ff1681565b34801561090b57600080fd5b5061028761091a3660046135de565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b34801561095457600080fd5b506102b7610963366004613a08565b611974565b34801561097457600080fd5b506102b7610983366004613362565b6119d1565b60006001600160a01b0383166109f85760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b1480610a4f57506001600160e01b031982166303a24d0760e21b145b80610a6a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b610a78611a4a565b8051610a8b906014906020840190613071565b5050565b60128054610a9c90613a70565b80601f0160208091040260200160405190810160405280929190818152602001828054610ac890613a70565b8015610b155780601f10610aea57610100808354040283529160200191610b15565b820191906000526020600020905b815481529060010190602001808311610af857829003601f168201915b505050505081565b6060600060148054610b2e90613a70565b905011610bc55760148054610b4290613a70565b80601f0160208091040260200160405190810160405280929190818152602001828054610b6e90613a70565b8015610bbb5780601f10610b9057610100808354040283529160200191610bbb565b820191906000526020600020905b815481529060010190602001808311610b9e57829003601f168201915b5050505050610a6a565b6014610bd083611aa9565b604051602001610be1929190613ac6565b60405160208183030381529060405292915050565b6001600160a01b038116600090815260066020526040902054610c2b5760405162461bcd60e51b81526004016109ef90613b6c565b6000610c368261148c565b905080600003610c585760405162461bcd60e51b81526004016109ef90613bb2565b8060056000828254610c6a9190613c13565b90915550506001600160a01b0382166000908152600760205260409020805482019055610c978282611b3b565b7fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b0568282604051610cc892919061312a565b60405180910390a15050565b610cdc611c51565b6001600160a01b038616610d205760405162461bcd60e51b815260206004820152600b60248201526a426164206164647265737360a81b60448201526064016109ef565b6001600160a01b0386163314610dfb573360009081526011602052604090205460ff1680610ddf575060405163090c9a2d60e41b81523360048201526001600160a01b0387811660248301523060448301527f000000000000000000000000000000000000000000000000000000000000000016906390c9a2d090606401602060405180830381865afa158015610dbb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ddf9190613c2b565b610dfb5760405162461bcd60e51b81526004016109ef90613c48565b6000858152600e602052604090205461ffff80821691610e24918791600160e01b900416613c13565b1115610e425760405162461bcd60e51b81526004016109ef90613c6e565b6000610e52878787878734611caa565b805190915080610e63575080602001515b80610e6f575080604001515b610ea85760405162461bcd60e51b815260206004820152600a602482015269496e656c696769626c6560b01b60448201526064016109ef565b6000868152600e602052604090208054869190601c90610ed4908490600160e01b900461ffff16613c91565b92506101000a81548161ffff021916908361ffff160217905550610f09878787604051806020016040528060008152506120c8565b6000868152600e6020526040902054600160d81b900460ff1615610f3357610f33878387346121ca565b50610f3e6001600b55565b505050505050565b610f4e611a4a565b601755565b6000828152600d602052604081205481906001600160a01b0381169061271090610f8990600160a01b900462ffffff1686613cb7565b610f939190613cd6565b915091509250929050565b846001600160a01b0381163314610fb857610fb8336122fa565b60005b845181101561103057600e6000868381518110610fda57610fda613cf8565b60200260200101518152602001908152602001600020600001601e9054906101000a900460ff161561101e5760405162461bcd60e51b81526004016109ef90613d0e565b8061102881613d2e565b915050610fbb565b50610f3e86868686866123aa565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b6001600160a01b03811660009081526006602052604090205461109e5760405162461bcd60e51b81526004016109ef90613b6c565b60006110aa83836114be565b9050806000036110cc5760405162461bcd60e51b81526004016109ef90613bb2565b6001600160a01b038316600090815260096020526040812080548392906110f4908490613c13565b90915550506001600160a01b038084166000908152600a6020908152604080832093861683529290522080548201905561112f8383836123f6565b826001600160a01b03167f3be5b7a71e84ed12875d241991c70855ac5817d847039e17a9d895c1ceb0f18a838360405161116a92919061312a565b60405180910390a2505050565b606081518351146111dc5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016109ef565b600083516001600160401b038111156111f7576111f76131b7565b604051908082528060200260200182016040528015611220578160200160208202803683370190505b50905060005b84518110156112985761126b85828151811061124457611244613cf8565b602002602001015185838151811061125e5761125e613cf8565b6020026020010151610988565b82828151811061127d5761127d613cf8565b602090810291909101015261129181613d2e565b9050611226565b509392505050565b6015546001600160a01b031633146112ca5760405162461bcd60e51b81526004016109ef90613c48565b6000838152600e602052604090208054839190601c906112f6908490600160e01b900461ffff16613d47565b92506101000a81548161ffff021916908361ffff16021790555061131b81848461244c565b505050565b611328611a4a565b61133260006125b6565b565b61133c611a4a565b8015611364576017546000036113645760405162461bcd60e51b81526004016109ef90613d6a565b821561138c5760165460000361138c5760405162461bcd60e51b81526004016109ef90613d6a565b6000938452600e60205260409093208054931515600160c81b0260ff60c81b19921515600160c01b0260ff60c01b19941515600160b81b029490941661ffff60b81b19909516949094179290921716919091179055565b6000600882815481106113f8576113f8613cf8565b6000918252602090912001546001600160a01b031692915050565b61141b611a4a565b601655565b6003546001600160a01b031690565b60138054610a9c90613a70565b6001600160a01b031660009081526007602052604090205490565b61145f611a4a565b601580546001600160a01b0319166001600160a01b0392909216919091179055565b610a8b338383612608565b60008061149860055490565b6114a29047613c13565b90506114b783826114b28661143c565b6126e8565b9392505050565b6000806114ca8461155a565b6040516370a0823160e01b81526001600160a01b038616906370a08231906114f690309060040161360c565b602060405180830381865afa158015611513573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115379190613d8c565b6115419190613c13565b905061155283826114b2878761103e565b949350505050565b6001600160a01b031660009081526009602052604090205490565b61157d611a4a565b6000898152600e6020526040902054600160f01b900460ff16151581151514806115be57506000898152600e6020526040902054600160e01b900461ffff16155b6115da5760405162461bcd60e51b81526004016109ef90613da5565b6000898152600e6020526040902054600160d01b900460ff161561162c576000898152600e602052604090205461ffff89811691161461162c5760405162461bcd60e51b81526004016109ef90613da5565b6000898152600e6020526040812054600160e01b900461ffff169003611670576000898152600e60205260409020805460ff60f01b1916600160f01b831515021790555b506000978852600e60205260409097208054971515600160d81b0260ff60d81b19921515600160d01b0260ff60d01b196001600160481b03958616600160701b0216600160701b63ff00000160b81b031995909616600160281b02600160281b600160701b031961ffff988916630100000002166301000000600160701b0319991515620100000262ffffff19909c1698909a16979097179990991796909616969096179390931716179390931792909216919091179055565b611732611a4a565b801561175f576001600160a01b0382166000908152601160205260409020805460ff191660011790555050565b506001600160a01b03166000908152601160205260409020805460ff19169055565b611789611a4a565b6040805180820182526001600160a01b03938416815262ffffff92831660208083019182526000968752600d905291909420935184549151909216600160a01b026001600160b81b03199091169190921617179055565b6117e8611a4a565b60005b835181101561196e57600083828151811061180857611808613cf8565b60209081029190910181015161ffff8082166000908152600e90935260409092205485519193509091169084908490811061184557611845613cf8565b60209081029190910181015161ffff8085166000908152600e90935260409092205461187992600160e01b90910416613c91565b61ffff16111561189b5760405162461bcd60e51b81526004016109ef90613c6e565b6118f08583815181106118b0576118b0613cf8565b60200260200101518261ffff168585815181106118cf576118cf613cf8565b602002602001015161ffff16604051806020016040528060008152506120c8565b82828151811061190257611902613cf8565b6020026020010151600e60008361ffff168152602001908152602001600020600001601c8282829054906101000a900461ffff166119409190613c91565b92506101000a81548161ffff021916908361ffff16021790555050808061196690613d2e565b9150506117eb565b50505050565b846001600160a01b038116331461198e5761198e336122fa565b6000848152600e6020526040902054600160f01b900460ff16156119c45760405162461bcd60e51b81526004016109ef90613d0e565b610f3e8686868686612726565b6119d9611a4a565b6001600160a01b038116611a3e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109ef565b611a47816125b6565b50565b33611a53611420565b6001600160a01b0316146113325760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109ef565b60606000611ab68361276b565b60010190506000816001600160401b03811115611ad557611ad56131b7565b6040519080825280601f01601f191660200182016040528015611aff576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611b0957509392505050565b80471015611b8b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016109ef565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611bd8576040519150601f19603f3d011682016040523d82523d6000602084013e611bdd565b606091505b505090508061131b5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c20726044820152791958da5c1a595b9d081b585e481a185d99481c995d995c9d195960321b60648201526084016109ef565b6002600b5403611ca35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016109ef565b6002600b55565b611cb26130f5565b611cba6130f5565b6000878152600e60209081526040808320815161018081018352905461ffff808216835260ff6201000083048116151584870152630100000083048216848601526001600160481b03600160281b840481166060860152600160701b8404166080850152600160b81b83048116151560a0850152600160c01b83048116151560c0850152600160c81b83048116151560e08501908152600160d01b840482161515610100860152600160d81b840482161515610120860152600160e01b84048316610140860152600160f01b9093041615156101608401528c8652600f85528386206001600160a01b038f16808852908652848720548e885260108752858820918852955292909420549351909392821692909116908015611ded5750611de18189613d47565b61ffff168961ffff1611155b8015611df7575085155b15611eb15760008b8b8a604051602001611e1393929190613dc5565b604051602081830303815290604052805190602001209050611e388860175483612841565b1580158652611eaf5789601060008d815260200190815260200160002060008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008282829054906101000a900461ffff16611e949190613c91565b92506101000a81548161ffff021916908361ffff1602179055505b505b8351158015611ec157508260a001515b8015611ede5750611ed28289613d47565b61ffff168961ffff1611155b8015611f0557508861ffff168360600151611ef99190613dea565b6001600160481b031686145b15611fc25760008b8b8a604051602001611f2193929190613dc5565b604051602081830303815290604052805190602001209050611f468860165483612841565b1580156020870152611fc05789600f60008d815260200190815260200160002060008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008282829054906101000a900461ffff16611fa59190613c91565b92506101000a81548161ffff021916908361ffff1602179055505b505b8351158015611fd357508360200151155b8015611fe057508260c001515b801561200757508861ffff168360800151611ffb9190613dea565b6001600160481b031686145b156120b95782602001511561203b578183604001516120269190613d47565b61ffff908116908a1611156040850152612051565b60408084015161ffff908116908b161115908501525b83604001518015612063575082602001515b156120b95760008a8152600f602090815260408083206001600160a01b038f168452909152812080548b929061209e90849061ffff16613c91565b92506101000a81548161ffff021916908361ffff1602179055505b50919998505050505050505050565b6001600160a01b0384166121285760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016109ef565b33600061213485612857565b9050600061214185612857565b90506000868152602081815260408083206001600160a01b038b16845290915281208054879290612173908490613c13565b909155505060408051878152602081018790526001600160a01b03808a169260009291871691600080516020614115833981519152910160405180910390a46121c1836000898989896128a2565b50505050505050565b600c5460405163f216ec8d60e01b81523060048201526001600160a01b038681166024830152858116604483015260648201849052600092839291169063f216ec8d906084016040805180830381865afa15801561222c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122509190613e19565b915091506000821180156122645750600081115b15610f3e57600c546001600160a01b03166337559c896122848385613c13565b6040516001600160e01b031960e084901b1681526001600160a01b03808b1660048301528916602482015260448101889052606481018790526084016000604051808303818588803b1580156122d957600080fd5b505af11580156122ed573d6000803e3d6000fd5b5050505050505050505050565b6daaeb6d7670e522a718067333cd4e3b15611a4757604051633185c44d60e21b81523060048201526001600160a01b03821660248201526daaeb6d7670e522a718067333cd4e9063c617113490604401602060405180830381865afa158015612367573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061238b9190613c2b565b611a475780604051633b79c77360e21b81526004016109ef919061360c565b6001600160a01b0385163314806123c657506123c6853361091a565b6123e25760405162461bcd60e51b81526004016109ef90613e3d565b6123ef8585858585612a04565b5050505050565b61131b8363a9059cbb60e01b848460405160240161241592919061312a565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612bd9565b6001600160a01b0383166124ae5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b60648201526084016109ef565b3360006124ba84612857565b905060006124c784612857565b60408051602080820183526000918290528882528181528282206001600160a01b038b16835290522054909150848110156125505760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b60648201526084016109ef565b6000868152602081815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a9052909290881691600080516020614115833981519152910160405180910390a46040805160208101909152600090526121c1565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361267b5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016109ef565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6004546001600160a01b038416600090815260066020526040812054909183916127129086613cb7565b61271c9190613cd6565b6115529190613e8b565b6001600160a01b0385163314806127425750612742853361091a565b61275e5760405162461bcd60e51b81526004016109ef90613e3d565b6123ef8585858585612cab565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106127aa5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b83106127d4576904ee2d6d415b85acef8160201b830492506020015b662386f26fc1000083106127f257662386f26fc10000830492506010015b6305f5e100831061280a576305f5e100830492506008015b612710831061281e57612710830492506004015b60648310612830576064830492506002015b600a8310610a6a5760010192915050565b60008261284e8584612dc3565b14949350505050565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061289157612891613cf8565b602090810291909101015292915050565b6128b4846001600160a01b0316612e08565b15610f3e5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e61906128ed9089908990889088908890600401613ea2565b6020604051808303816000875af1925050508015612928575060408051601f3d908101601f1916820190925261292591810190613edc565b60015b6129d457612934613ef9565b806308c379a00361296d5750612948613f15565b80612953575061296f565b8060405162461bcd60e51b81526004016109ef9190613326565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016109ef565b6001600160e01b0319811663f23a6e6160e01b146121c15760405162461bcd60e51b81526004016109ef90613f9e565b8151835114612a665760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b60648201526084016109ef565b6001600160a01b038416612a8c5760405162461bcd60e51b81526004016109ef90613fe6565b3360005b8451811015612b73576000858281518110612aad57612aad613cf8565b602002602001015190506000858381518110612acb57612acb613cf8565b602090810291909101810151600084815280835260408082206001600160a01b038e168352909352919091205490915081811015612b1b5760405162461bcd60e51b81526004016109ef9061402b565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290612b58908490613c13565b9250508190555050505080612b6c90613d2e565b9050612a90565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051612bc3929190614075565b60405180910390a4610f3e818787878787612e17565b6000612c2e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612ed99092919063ffffffff16565b80519091501561131b5780806020019051810190612c4c9190613c2b565b61131b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109ef565b6001600160a01b038416612cd15760405162461bcd60e51b81526004016109ef90613fe6565b336000612cdd85612857565b90506000612cea85612857565b90506000868152602081815260408083206001600160a01b038c16845290915290205485811015612d2d5760405162461bcd60e51b81526004016109ef9061402b565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a16825281208054889290612d6a908490613c13565b909155505060408051888152602081018890526001600160a01b03808b16928c82169291881691600080516020614115833981519152910160405180910390a4612db8848a8a8a8a8a6128a2565b505050505050505050565b600081815b845181101561129857612df482868381518110612de757612de7613cf8565b6020026020010151612ee8565b915080612e0081613d2e565b915050612dc8565b6001600160a01b03163b151590565b612e29846001600160a01b0316612e08565b15610f3e5760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612e62908990899088908890889060040161409a565b6020604051808303816000875af1925050508015612e9d575060408051601f3d908101601f19168201909252612e9a91810190613edc565b60015b612ea957612934613ef9565b6001600160e01b0319811663bc197c8160e01b146121c15760405162461bcd60e51b81526004016109ef90613f9e565b60606115528484600085612f14565b6000818310612f045760008281526020849052604090206114b7565b5060009182526020526040902090565b606082471015612f755760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109ef565b600080866001600160a01b03168587604051612f9191906140f8565b60006040518083038185875af1925050503d8060008114612fce576040519150601f19603f3d011682016040523d82523d6000602084013e612fd3565b606091505b5091509150612fe487838387612fef565b979650505050505050565b6060831561305c5782516000036130555761300985612e08565b6130555760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109ef565b5081611552565b61155283838151156129535781518083602001fd5b82805461307d90613a70565b90600052602060002090601f01602090048101928261309f57600085556130e5565b82601f106130b857805160ff19168380011785556130e5565b828001600101855582156130e5579182015b828111156130e55782518255916020019190600101906130ca565b506130f1929150613115565b5090565b604080516060810182526000808252602082018190529181019190915290565b5b808211156130f15760008155600101613116565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0381168114611a4757600080fd5b6000806040838503121561316b57600080fd5b823561317681613143565b946020939093013593505050565b6001600160e01b031981168114611a4757600080fd5b6000602082840312156131ac57600080fd5b81356114b781613184565b634e487b7160e01b600052604160045260246000fd5b601f8201601f191681016001600160401b03811182821017156131f2576131f26131b7565b6040525050565b60006001600160401b03831115613212576132126131b7565b604051613229601f8501601f1916602001826131cd565b80915083815284848401111561323e57600080fd5b83836020830137600060208583010152509392505050565b60006020828403121561326857600080fd5b81356001600160401b0381111561327e57600080fd5b8201601f8101841361328f57600080fd5b611552848235602084016131f9565b600080604083850312156132b157600080fd5b8235915060208301356132c381613143565b809150509250929050565b60005b838110156132e95781810151838201526020016132d1565b8381111561196e5750506000910152565b600081518084526133128160208601602086016132ce565b601f01601f19169290920160200192915050565b6020815260006114b760208301846132fa565b60006020828403121561334b57600080fd5b5035919050565b803561335d81613143565b919050565b60006020828403121561337457600080fd5b81356114b781613143565b60006001600160401b03821115613398576133986131b7565b5060051b60200190565b60008060008060008060c087890312156133bb57600080fd5b86356133c681613143565b95506020878101359550604088013594506060880135935060808801356001600160401b038111156133f757600080fd5b8801601f81018a1361340857600080fd5b80356134138161337f565b60405161342082826131cd565b82815260059290921b830184019184810191508c83111561344057600080fd5b928401925b8284101561345e57833582529284019290840190613445565b809650505050505061347260a08801613352565b90509295509295509295565b6000806040838503121561349157600080fd5b50508035926020909101359150565b600082601f8301126134b157600080fd5b813560206134be8261337f565b6040516134cb82826131cd565b83815260059390931b85018201928281019150868411156134eb57600080fd5b8286015b8481101561350657803583529183019183016134ef565b509695505050505050565b600082601f83011261352257600080fd5b6114b7838335602085016131f9565b600080600080600060a0868803121561354957600080fd5b853561355481613143565b9450602086013561356481613143565b935060408601356001600160401b038082111561358057600080fd5b61358c89838a016134a0565b945060608801359150808211156135a257600080fd5b6135ae89838a016134a0565b935060808801359150808211156135c457600080fd5b506135d188828901613511565b9150509295509295909350565b600080604083850312156135f157600080fd5b82356135fc81613143565b915060208301356132c381613143565b6001600160a01b0391909116815260200190565b600082601f83011261363157600080fd5b8135602061363e8261337f565b60405161364b82826131cd565b83815260059390931b850182019282810191508684111561366b57600080fd5b8286015b8481101561350657803561368281613143565b835291830191830161366f565b600080604083850312156136a257600080fd5b82356001600160401b03808211156136b957600080fd5b6136c586838701613620565b935060208501359150808211156136db57600080fd5b506136e8858286016134a0565b9150509250929050565b600081518084526020808501945080840160005b8381101561372257815187529582019590820190600101613706565b509495945050505050565b6020815260006114b760208301846136f2565b60008060006060848603121561375557600080fd5b8335925060208401359150604084013561376e81613143565b809150509250925092565b8015158114611a4757600080fd5b6000806000806080858703121561379d57600080fd5b8435935060208501356137af81613779565b925060408501356137bf81613779565b915060608501356137cf81613779565b939692955090935050565b600080604083850312156137ed57600080fd5b82356137f881613143565b915060208301356132c381613779565b803561ffff8116811461335d57600080fd5b80356001600160481b038116811461335d57600080fd5b60008060008060008060008060006101208a8c03121561385057600080fd5b8935985061386060208b01613808565b975060408a013561387081613779565b965061387e60608b01613808565b955061388c60808b0161381a565b945061389a60a08b0161381a565b935060c08a01356138aa81613779565b925060e08a01356138ba81613779565b91506101008a01356138cb81613779565b809150509295985092959850929598565b6000806000606084860312156138f157600080fd5b83359250602084013561390381613143565b929592945050506040919091013590565b600082601f83011261392557600080fd5b813560206139328261337f565b60405161393f82826131cd565b83815260059390931b850182019282810191508684111561395f57600080fd5b8286015b848110156135065761397481613808565b8352918301918301613963565b60008060006060848603121561399657600080fd5b83356001600160401b03808211156139ad57600080fd5b6139b987838801613620565b945060208601359150808211156139cf57600080fd5b6139db87838801613914565b935060408601359150808211156139f157600080fd5b506139fe86828701613914565b9150509250925092565b600080600080600060a08688031215613a2057600080fd5b8535613a2b81613143565b94506020860135613a3b81613143565b9350604086013592506060860135915060808601356001600160401b03811115613a6457600080fd5b6135d188828901613511565b600181811c90821680613a8457607f821691505b602082108103613aa457634e487b7160e01b600052602260045260246000fd5b50919050565b60008151613abc8185602086016132ce565b9290920192915050565b600080845481600182811c915080831680613ae257607f831692505b60208084108203613b0157634e487b7160e01b86526022600452602486fd5b818015613b155760018114613b2657613b53565b60ff19861689528489019650613b53565b60008b81526020902060005b86811015613b4b5781548b820152908501908301613b32565b505084890196505b505050505050613b638185613aaa565b95945050505050565b60208082526026908201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060408201526573686172657360d01b606082015260800190565b6020808252602b908201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060408201526a191d59481c185e5b595b9d60aa1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008219821115613c2657613c26613bfd565b500190565b600060208284031215613c3d57600080fd5b81516114b781613779565b6020808252600c908201526b155b985d5d1a1bdc9a5e995960a21b604082015260600190565b6020808252600990820152684e6f20737570706c7960b81b604082015260600190565b600061ffff808316818516808303821115613cae57613cae613bfd565b01949350505050565b6000816000190483118215151615613cd157613cd1613bfd565b500290565b600082613cf357634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b60208082526006908201526511985a5b195960d21b604082015260600190565b600060018201613d4057613d40613bfd565b5060010190565b600061ffff83811690831681811015613d6257613d62613bfd565b039392505050565b602080825260089082015267109859081c9bdbdd60c21b604082015260600190565b600060208284031215613d9e57600080fd5b5051919050565b602080825260069082015265131bd8dad95960d21b604082015260600190565b6001600160a01b03939093168352602083019190915261ffff16604082015260600190565b60006001600160481b0382811684821681151582840482111615613e1057613e10613bfd565b02949350505050565b60008060408385031215613e2c57600080fd5b505080516020909101519092909150565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b600082821015613e9d57613e9d613bfd565b500390565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090612fe4908301846132fa565b600060208284031215613eee57600080fd5b81516114b781613184565b600060033d1115613f125760046000803e5060005160e01c5b90565b600060443d1015613f235790565b6040516003193d81016004833e81513d6001600160401b038083116024840183101715613f5257505050505090565b8285019150815181811115613f6a5750505050505090565b843d8701016020828501011115613f845750505050505090565b613f93602082860101876131cd565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b60408152600061408860408301856136f2565b8281036020840152613b6381856136f2565b6001600160a01b0386811682528516602082015260a0604082018190526000906140c6908301866136f2565b82810360608401526140d881866136f2565b905082810360808401526140ec81856132fa565b98975050505050505050565b6000825161410a8184602087016132ce565b919091019291505056fec3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62a2646970667358221220fb66aca56ddeeed6ccaf392dd86c05b2010ea38d93b3b0dfe0dfcc1ec0b5b0da64736f6c634300080d0033a264697066735822122093907f7e925dcd1a4a071d6aae06532649d310c8479551d04e323570363c5dca64736f6c634300080d0033
Verified Source Code Full Match
Compiler: v0.8.13+commit.abaa5c0e
EVM: london
Optimization: Yes (5 runs)
IERC1155MetadataURI.sol 22 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
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);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or 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 {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
ERC1155Contract.sol 249 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "refer2earn/Referable.sol";
import "./opensea/DefaultOperatorFilterer.sol";
import "./IERC2981.sol";
import "./IDelegationRegistry.sol";
contract ERC1155Contract is ERC1155, Ownable, PaymentSplitter, ReentrancyGuard, DefaultOperatorFilterer, Referable, IERC2981 {
using Strings for uint256;
IDelegationRegistry immutable dc;
struct RoyaltyInfo {
address recipient;
uint24 basisPoints;
}
struct Token {
uint16 maxSupply;
bool pubPerWallet;
uint16 pubMaxMint;
uint72 preSalePrice;
uint72 pubSalePrice;
bool preSaleIsActive;
bool pubSaleIsActive;
bool claimIsActive;
bool supplyLock;
bool refer2earn;
uint16 totalSupply;
bool soulbound;
}
struct Eligible {
bool claim;
bool preSale;
bool pubSale;
}
mapping(uint256 => RoyaltyInfo) public royalties;
mapping(uint256 => Token) public tokens;
mapping (uint256 => mapping(address => uint16)) public hasMinted;
mapping (uint256 => mapping(address => uint16)) public hasClaimed;
mapping(address => bool) public fiatMinters;
string public name;
string public symbol;
string private baseURI;
address private burnerContract;
bytes32 private saleMerkleRoot;
bytes32 private claimMerkleRoot;
constructor(
uint16 _id,
string memory _name,
string memory _symbol,
string memory _uri,
address[] memory _payees,
uint256[] memory _shares,
address _owner,
address[] memory _interfaces, // 0 = refer2earn, 1 = delegate.cash, 2 = crossmint
Token memory _type,
RoyaltyInfo memory _royalties
) ERC1155(_uri)
Referable(_interfaces[0])
PaymentSplitter(_payees, _shares) {
name = _name;
symbol = _symbol;
baseURI = _uri;
tokens[_id] = _type;
royalties[_id] = _royalties;
dc = IDelegationRegistry(_interfaces[1]);
fiatMinters[_interfaces[2]] = true;
transferOwnership(_owner);
}
function safeTransferFrom(address from, address to, uint256 tokenId, uint256 amount, bytes memory data)
public
override
onlyAllowedOperator(from)
{
require(!tokens[tokenId].soulbound, "Failed");
super.safeTransferFrom(from, to, tokenId, amount, data);
}
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override onlyAllowedOperator(from) {
for (uint256 i; i < ids.length; i++) require(!tokens[ids[i]].soulbound, "Failed");
super.safeBatchTransferFrom(from, to, ids, amounts, data);
}
function uri(uint256 _id) public view override returns (string memory) {
return
bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, _id.toString()))
: baseURI;
}
function setFiatMinter(address _address, bool _allowed) external onlyOwner {
if (_allowed) {
fiatMinters[_address] = true;
} else {
delete fiatMinters[_address];
}
}
function setBurnerAddress(address _address) external onlyOwner {
burnerContract = _address;
}
function burnForAddress(uint256 _id, uint256 _quantity, address _address) external {
require(msg.sender == burnerContract, "Unauthorized");
tokens[_id].totalSupply -= uint16(_quantity);
_burn(_address, _id, _quantity);
}
function setURI(string memory _uri) external onlyOwner {
baseURI = _uri;
}
function setSaleRoot(bytes32 _root) external onlyOwner {
saleMerkleRoot = _root;
}
function setClaimRoot(bytes32 _root) external onlyOwner {
claimMerkleRoot = _root;
}
function updateSaleState(
uint256 _id,
bool _preSaleIsActive,
bool _pubSaleIsActive,
bool _claimIsActive
) external onlyOwner {
if (_claimIsActive) require(claimMerkleRoot != "", "Bad root");
if (_preSaleIsActive) require(saleMerkleRoot != "", "Bad root");
tokens[_id].preSaleIsActive = _preSaleIsActive;
tokens[_id].pubSaleIsActive = _pubSaleIsActive;
tokens[_id].claimIsActive = _claimIsActive;
}
function setType(
uint256 _id,
uint16 _maxSupply,
bool _pubPerWallet,
uint16 _pubMaxMint,
uint72 _preSalePrice,
uint72 _pubSalePrice,
bool _supplyLock,
bool _refer2earn,
bool _soulbound
) external onlyOwner {
require(_soulbound == tokens[_id].soulbound || tokens[_id].totalSupply == 0, "Locked");
if (tokens[_id].supplyLock) require(_maxSupply == tokens[_id].maxSupply, "Locked");
if (tokens[_id].totalSupply == 0) tokens[_id].soulbound = _soulbound;
tokens[_id].maxSupply = _maxSupply;
tokens[_id].pubPerWallet = _pubPerWallet;
tokens[_id].pubMaxMint = _pubMaxMint;
tokens[_id].preSalePrice = _preSalePrice;
tokens[_id].pubSalePrice = _pubSalePrice;
tokens[_id].supplyLock = _supplyLock;
tokens[_id].refer2earn = _refer2earn;
}
function isEligible(
address _address,
uint256 _id,
uint16 _quantity,
uint16 _maxMint,
bytes32[] memory _proof,
uint256 _value
) internal returns (Eligible memory) {
Eligible memory _isEligible;
Token memory _token = tokens[_id];
uint16 _hasMinted = hasMinted[_id][_address];
uint16 _hasClaimed = hasClaimed[_id][_address];
if(_token.claimIsActive && (_quantity <= (_maxMint - _hasClaimed)) && _value == 0) {
bytes32 _leaf = keccak256(abi.encode(_address, _id, _maxMint));
_isEligible.claim = MerkleProof.verify(_proof, claimMerkleRoot, _leaf);
if (_isEligible.claim) hasClaimed[_id][_address] += _quantity;
}
if(!_isEligible.claim && _token.preSaleIsActive && (_quantity <= _maxMint - _hasMinted) && (_value == _token.preSalePrice * _quantity)) {
bytes32 _leaf = keccak256(abi.encode(_address, _id, _maxMint));
_isEligible.preSale = MerkleProof.verify(_proof, saleMerkleRoot, _leaf);
if (_isEligible.preSale) hasMinted[_id][_address] += _quantity;
}
if (!_isEligible.claim && !_isEligible.preSale && _token.pubSaleIsActive && (_value == _token.pubSalePrice * _quantity)) {
if (_token.pubPerWallet) {
_isEligible.pubSale = (_quantity <= (_token.pubMaxMint - _hasMinted));
} else {
_isEligible.pubSale = (_quantity <= _token.pubMaxMint);
}
if (_isEligible.pubSale && (_token.pubPerWallet)) hasMinted[_id][_address] += _quantity;
}
return _isEligible;
}
function mint(
address _address,
uint256 _id,
uint256 _quantity,
uint256 _maxMint,
bytes32[] memory _proof,
address payable _referrer
) external payable nonReentrant {
require(_address != address(0), "Bad address");
if (_address != msg.sender) require((fiatMinters[msg.sender] || dc.checkDelegateForContract(msg.sender, _address, address(this))), "Unauthorized");
require(tokens[_id].totalSupply + _quantity <= tokens[_id].maxSupply, "No supply");
(Eligible memory _isEligible) = isEligible(_address, _id, uint16(_quantity), uint16(_maxMint), _proof, msg.value);
require(_isEligible.claim || _isEligible.preSale || _isEligible.pubSale, "Ineligible");
tokens[_id].totalSupply += uint16(_quantity);
_mint(_address, _id, _quantity, "");
if (tokens[_id].refer2earn) Referable.payReferral(_address, _referrer, _quantity, msg.value);
}
function setRoyalties(uint256 _id, address recipient, uint256 _basisPoints) external onlyOwner {
royalties[_id] = RoyaltyInfo(recipient, uint24(_basisPoints));
}
function royaltyInfo(uint256 _id, uint256 _salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
return (royalties[_id].recipient, (_salePrice * royalties[_id].basisPoints) / 10000);
}
function airdrop(address[] memory _addresses, uint16[] memory _ids, uint16[] memory _quantities) external onlyOwner {
for (uint256 i; i < _addresses.length; i++) {
uint16 _id = _ids[i];
require(tokens[_id].totalSupply + _quantities[i] <= tokens[_id].maxSupply, "No supply");
_mint(_addresses[i], _id, _quantities[i], "");
tokens[_id].totalSupply += uint16(_quantities[i]);
}
}
}
DefaultOperatorFilterer.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {OperatorFilterer} from "./OperatorFilterer.sol";
/**
* @title DefaultOperatorFilterer
* @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
*/
abstract contract DefaultOperatorFilterer is OperatorFilterer {
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
ERC1155.sol 517 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)
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: address zero is not a valid owner");
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 {
_setApprovalForAll(_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 token owner or 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: caller is not token owner or 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();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, 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);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_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);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_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 `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _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);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
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: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @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 `ids` and `amounts` 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 {}
/**
* @dev Hook that is called after 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 _afterTokenTransfer(
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;
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
IERC721.sol 145 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
MerkleProof.sol 223 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
IERC2981.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
interface IERC2981 {
function royaltyInfo(uint256 _tokenId, uint256 _value)
external
view
returns (address _receiver, uint256 _royaltyAmount);
}
OperatorFilterer.sol 60 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol";
/**
* @title OperatorFilterer
* @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
* registrant's entries in the OperatorFilterRegistry.
* @dev This smart contract is meant to be inherited by token contracts so they can use the following:
* - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.
* - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
*/
abstract contract OperatorFilterer {
error OperatorNotAllowed(address operator);
IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier
// will not revert, but the contract will need to be registered with the registry once it is deployed in
// order for the modifier to filter addresses.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy != address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
modifier onlyAllowedOperator(address from) virtual {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
modifier onlyAllowedOperatorApproval(address operator) virtual {
_checkFilterOperator(operator);
_;
}
function _checkFilterOperator(address operator) internal view virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
IOperatorFilterRegistry.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IOperatorFilterRegistry {
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
function register(address registrant) external;
function registerAndSubscribe(address registrant, address subscription) external;
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
function unregister(address addr) external;
function updateOperator(address registrant, address operator, bool filtered) external;
function updateOperators(address registrant, address[] calldata operators, bool filtered) external;
function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;
function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;
function subscribe(address registrant, address registrantToSubscribe) external;
function unsubscribe(address registrant, bool copyExistingEntries) external;
function subscriptionOf(address addr) external returns (address registrant);
function subscribers(address registrant) external returns (address[] memory);
function subscriberAt(address registrant, uint256 index) external returns (address);
function copyEntriesOf(address registrant, address registrantToCopy) external;
function isOperatorFiltered(address registrant, address operator) external returns (bool);
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
function filteredOperators(address addr) external returns (address[] memory);
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
function isRegistered(address addr) external returns (bool);
function codeHashOf(address addr) external returns (bytes32);
}
Referable.sol 36 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
abstract contract IReferable {
function getCommission(
address _contract,
address _recipient,
address _referrer,
uint256 _value
)
public
view
virtual
returns (uint256, uint256);
function payReferral(
address _recipient,
address payable _referrer,
uint256 _quantity,
uint256 _value
) public virtual payable;
}
contract Referable {
address public r2eAddress;
constructor(address _r2eAddress) {
r2eAddress = _r2eAddress;
}
function payReferral(address _recipient, address payable _referrer, uint256 _quantity, uint256 _value) internal {
(uint256 _commission, uint256 _fee) = IReferable(r2eAddress).getCommission(address(this), _recipient, _referrer, _value);
if (_commission > 0 && _fee > 0) IReferable(r2eAddress).payReferral{value: _commission + _fee}(_recipient, _referrer, _quantity, _value);
}
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must 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;
}
draft-IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC1155Receiver.sol 58 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
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.
*
* NOTE: 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.
*
* NOTE: 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);
}
SafeERC20.sol 116 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
ERC1155Factory.sol 48 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "./ERC1155Contract.sol";
contract ERC1155Factory is Ownable {
mapping(uint256 => address) public deployments;
address public treasuryAddress;
address public launchpassAddress;
uint16 public treasuryShare;
address public fiatMinter;
address public r2eAddress;
address public dcAddress;
function updateConfig(address _treasuryAddress, address _launchpassAddress, uint16 _treasuryShare, address _fiatMinter, address _r2eAddress, address _dcAddress) external onlyOwner {
treasuryShare = _treasuryShare;
launchpassAddress = _launchpassAddress;
treasuryAddress = _treasuryAddress;
r2eAddress = _r2eAddress;
dcAddress = _dcAddress;
fiatMinter = _fiatMinter;
}
function deploy(
uint16 _id,
string memory _name,
string memory _symbol,
string memory _uri,
uint16 _launchpassId,
address[] memory _payees,
uint256[] memory _shares,
ERC1155Contract.Token memory _token,
ERC1155Contract.RoyaltyInfo memory _royalties
) external {
require(_payees.length == _shares.length);
require(IERC721(launchpassAddress).ownerOf(_launchpassId) == msg.sender);
address[] memory _interfaces = new address[](3);
_interfaces[0] = r2eAddress;
_interfaces[1] = dcAddress;
_interfaces[2] = fiatMinter;
ERC1155Contract nft = new ERC1155Contract(_id, _name, _symbol, _uri, _payees, _shares, msg.sender, _interfaces, _token, _royalties);
deployments[_launchpassId] = address(nft);
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
PaymentSplitter.sol 214 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @title PaymentSplitter
* @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
* that the Ether will be split in this way, since it is handled transparently by the contract.
*
* The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
* account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
* an amount proportional to the percentage of total shares they were assigned. The distribution of shares is set at the
* time of contract deployment and can't be updated thereafter.
*
* `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account) public view returns (uint256) {
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Getter for the amount of payee's releasable Ether.
*/
function releasable(address account) public view returns (uint256) {
uint256 totalReceived = address(this).balance + totalReleased();
return _pendingPayment(account, totalReceived, released(account));
}
/**
* @dev Getter for the amount of payee's releasable `token` tokens. `token` should be the address of an
* IERC20 contract.
*/
function releasable(IERC20 token, address account) public view returns (uint256) {
uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token);
return _pendingPayment(account, totalReceived, released(token, account));
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 payment = releasable(account);
require(payment != 0, "PaymentSplitter: account is not due payment");
// _totalReleased is the sum of all values in _released.
// If "_totalReleased += payment" does not overflow, then "_released[account] += payment" cannot overflow.
_totalReleased += payment;
unchecked {
_released[account] += payment;
}
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 payment = releasable(token, account);
require(payment != 0, "PaymentSplitter: account is not due payment");
// _erc20TotalReleased[token] is the sum of all values in _erc20Released[token].
// If "_erc20TotalReleased[token] += payment" does not overflow, then "_erc20Released[token][account] += payment"
// cannot overflow.
_erc20TotalReleased[token] += payment;
unchecked {
_erc20Released[token][account] += payment;
}
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
ReentrancyGuard.sol 69 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
IDelegationRegistry.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
interface IDelegationRegistry {
function checkDelegateForContract(address delegate, address vault, address contract_)
external
view
returns (bool);
}
Read Contract
dcAddress 0x3b4244e6 → address
deployments 0x06609bbe → address
fiatMinter 0x55431928 → address
launchpassAddress 0x5ee7d9a2 → address
owner 0x8da5cb5b → address
r2eAddress 0xb6d91387 → address
treasuryAddress 0xc5f956af → address
treasuryShare 0x7796ff37 → uint16
Write Contract 4 functions
These functions modify contract state and require a wallet transaction to execute.
deploy 0xfbca0131
uint16 _id
string _name
string _symbol
string _uri
uint16 _launchpassId
address[] _payees
uint256[] _shares
tuple _token
tuple _royalties
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
updateConfig 0x0e025c87
address _treasuryAddress
address _launchpassAddress
uint16 _treasuryShare
address _fiatMinter
address _r2eAddress
address _dcAddress
Recent Transactions
No transactions found for this address