Address Contract Partially Verified
Address
0x5AE32ac9FE855076F006F20688d05f765B0fff62
Balance
0 ETH
Nonce
1
Code Size
15571 bytes
Creator
0xa50750ae...A2EE at tx 0xc50c05aa...b08ea8
Indexed Transactions
0
Contract Bytecode
15571 bytes
0x6080604052600436106103555760003560e01c80637284e416116101bb578063b7f751d8116100f7578063e527c6dd11610095578063ef3c66241161006f578063ef3c662414610991578063f2fde38b146109c5578063f3fef3a3146109e5578063f593bd5314610a0557600080fd5b8063e527c6dd1461091e578063e985e9c514610952578063ed329fa81461097257600080fd5b8063c87b56dd116100d1578063c87b56dd146108c1578063d547cfb7146108e1578063d62f3b1c146108f6578063d81bc6631461090b57600080fd5b8063b7f751d81461084e578063b88d4fde14610874578063bba7723e1461089457600080fd5b8063a0712d6811610164578063a4e2d6341161013e578063a4e2d634146107e8578063a4f4f8af1461080b578063a945bf801461067f578063affe39c11461082c57600080fd5b8063a0712d6814610795578063a22cb465146107a8578063a22e4faa146107c857600080fd5b806391ba317a1161019557806391ba317a1461074b57806395d89b41146107605780639df806d61461077557600080fd5b80637284e41614610703578063753868e3146107185780638da5cb5b1461072d57600080fd5b80633408e470116102955780634f6ccce711610233578063636e746b1161020d578063636e746b1461067f57806370a082311461069a578063715018a6146106ba57806371dedace146106cf57600080fd5b80634f6ccce71461062a5780635cdf532f1461064a5780636352211e1461065f57600080fd5b806342966c681161026f57806342966c681461058157806343bc1612146105a157806344be774f146105ea5780634dcc60af1461060a57600080fd5b80633408e470146105395780633fafa1271461054c57806342842e0e1461056157600080fd5b806314d7d5171161030257806323b872dd116102dc57806323b872dd146104a35780632d0335ab146104c35780632f745c59146104f957806330176e131461051957600080fd5b806314d7d5171461044b57806318160ddd1461046b57806320379ee51461048e57600080fd5b8063095ea7b311610333578063095ea7b3146103e95780630c53c51c1461040b5780630f7e59701461041e57600080fd5b806301ffc9a71461035a57806306fdde031461038f578063081812fc146103b1575b600080fd5b34801561036657600080fd5b5061037a610375366004613450565b610a1e565b60405190151581526020015b60405180910390f35b34801561039b57600080fd5b506103a4610a49565b60405161038691906134c5565b3480156103bd57600080fd5b506103d16103cc3660046134d8565b610adb565b6040516001600160a01b039091168152602001610386565b3480156103f557600080fd5b50610409610404366004613506565b610b68565b005b6103a46104193660046135de565b610c90565b34801561042a57600080fd5b506103a4604051806040016040528060018152602001603160f81b81525081565b34801561045757600080fd5b50610409610466366004613506565b610e7a565b34801561047757600080fd5b50610480610fb3565b604051908152602001610386565b34801561049a57600080fd5b50600654610480565b3480156104af57600080fd5b506104096104be36600461365c565b61100f565b3480156104cf57600080fd5b506104806104de36600461369d565b6001600160a01b031660009081526007602052604090205490565b34801561050557600080fd5b50610480610514366004613506565b611091565b34801561052557600080fd5b506104096105343660046136ba565b61116e565b34801561054557600080fd5b5046610480565b34801561055857600080fd5b50610480600981565b34801561056d57600080fd5b5061040961057c36600461365c565b6111ec565b34801561058d57600080fd5b5061040961059c3660046134d8565b611207565b3480156105ad57600080fd5b506103a46040518060400160405280600c81526020017f52656973204f27427269656e000000000000000000000000000000000000000081525081565b3480156105f657600080fd5b50610409610605366004613506565b61127d565b34801561061657600080fd5b506104096106253660046136ba565b6113a2565b34801561063657600080fd5b506104806106453660046134d8565b61142e565b34801561065657600080fd5b506103a461150a565b34801561066b57600080fd5b506103d161067a3660046134d8565b611598565b34801561068b57600080fd5b5061048066b1a2bc2ec5000081565b3480156106a657600080fd5b506104806106b536600461369d565b611632565b3480156106c657600080fd5b5061040961170c565b3480156106db57600080fd5b506104807f000000000000000000000000000000000000000000000000000000000000000581565b34801561070f57600080fd5b506103a46117bd565b34801561072457600080fd5b506104096117d9565b34801561073957600080fd5b506008546001600160a01b03166103d1565b34801561075757600080fd5b5061048061185b565b34801561076c57600080fd5b506103a4611872565b34801561078157600080fd5b5061040961079036600461369d565b611881565b6104096107a33660046134d8565b61190a565b3480156107b457600080fd5b506104096107c3366004613703565b611ae3565b3480156107d457600080fd5b506104096107e336600461369d565b611af5565b3480156107f457600080fd5b50600954600160401b900461ffff1660011461037a565b34801561081757600080fd5b50600954640100000000900461ffff16610480565b34801561083857600080fd5b50610841611b7e565b6040516103869190613741565b34801561085a57600080fd5b506009546601000000000000900461ffff1660011461037a565b34801561088057600080fd5b5061040961088f36600461378e565b611be4565b3480156108a057600080fd5b506108b46108af36600461369d565b611c6d565b60405161038691906137fa565b3480156108cd57600080fd5b506103a46108dc3660046134d8565b611d9f565b3480156108ed57600080fd5b506103a4611e25565b34801561090257600080fd5b50610409611e34565b610409610919366004613832565b611eb7565b34801561092a57600080fd5b506104807f000000000000000000000000000000000000000000000000000000000000029081565b34801561095e57600080fd5b5061037a61096d3660046138bd565b61219a565b34801561097e57600080fd5b5060095462010000900461ffff16610480565b34801561099d57600080fd5b506104807f000000000000000000000000000000000000000000000000000000000000000581565b3480156109d157600080fd5b506104096109e036600461369d565b612288565b3480156109f157600080fd5b50610409610a00366004613506565b6123b0565b348015610a1157600080fd5b5060095461ffff16610480565b60006001600160e01b0319821663780e9d6360e01b1480610a435750610a43826125a0565b92915050565b606060008054610a58906138eb565b80601f0160208091040260200160405190810160405280929190818152602001828054610a84906138eb565b8015610ad15780601f10610aa657610100808354040283529160200191610ad1565b820191906000526020600020905b815481529060010190602001808311610ab457829003601f168201915b5050505050905090565b6000610ae6826125f0565b610b4c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600360205260409020546001600160a01b031690565b6000610b7382611598565b9050806001600160a01b0316836001600160a01b03161415610be15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610b43565b806001600160a01b0316610bf361263a565b6001600160a01b03161480610c0f5750610c0f8161096d61263a565b610c815760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610b43565b610c8b8383612644565b505050565b60408051606081810183526001600160a01b03881660008181526007602090815290859020548452830152918101869052610cce87828787876126b2565b610d245760405162461bcd60e51b815260206004820152602160248201527f5369676e657220616e64207369676e617475726520646f206e6f74206d6174636044820152600d60fb1b6064820152608401610b43565b6001600160a01b038716600090815260076020526040902054610d489060016127a2565b6001600160a01b0388166000908152600760205260409081902091909155517f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b90610d9890899033908a90613920565b60405180910390a1600080306001600160a01b0316888a604051602001610dc0929190613968565b60408051601f1981840301815290829052610dda9161399f565b6000604051808303816000865af19150503d8060008114610e17576040519150601f19603f3d011682016040523d82523d6000602084013e610e1c565b606091505b509150915081610e6e5760405162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c000000006044820152606401610b43565b98975050505050505050565b600b546001600160a01b0316610e8e61263a565b6001600160a01b031614610ee45760405162461bcd60e51b815260206004820152601160248201527f63616c6c6572206e6f74206172746973740000000000000000000000000000006044820152606401610b43565b6009547f000000000000000000000000000000000000000000000000000000000000000590610f1e90839062010000900461ffff166139d1565b1115610f6c5760405162461bcd60e51b815260206004820152601460248201527f6578636565642061727469737420737570706c790000000000000000000000006044820152606401610b43565b6009805461ffff62010000808304821685019091160263ffff00001990911617905560005b81811015610c8b57610fa2836127b5565b50610fac816139e9565b9050610f91565b600254600090815b8181101561100a5760006001600160a01b031660028281548110610fe157610fe1613a04565b6000918252602090912001546001600160a01b031614611002578260010192505b600101610fbb565b505090565b61102061101a61263a565b826127d0565b6110865760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610b43565b610c8b838383612892565b6002546000905b808210156110f257836001600160a01b0316600283815481106110bd576110bd613a04565b6000918252602090912001546001600160a01b031614156110e7576000198301926110e7576110f2565b816001019150611098565b8082106111675760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201527f74206f6620626f756e64730000000000000000000000000000000000000000006064820152608401610b43565b5092915050565b61117661263a565b6001600160a01b03166111916008546001600160a01b031690565b6001600160a01b0316146111d55760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b80516111e890600d90602084019061336b565b5050565b610c8b83838360405180602001604052806000815250611be4565b600a546001600160a01b031661121b61263a565b6001600160a01b0316146112715760405162461bcd60e51b815260206004820152601160248201527f63616c6c6572206e6f74206275726e65720000000000000000000000000000006044820152606401610b43565b61127a816129e8565b50565b61128561263a565b6001600160a01b03166112a06008546001600160a01b031690565b6001600160a01b0316146112e45760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b6009547f00000000000000000000000000000000000000000000000000000000000000059061131890839061ffff166139d1565b11156113665760405162461bcd60e51b815260206004820152601560248201527f6578636565642067616c6c65727920737570706c7900000000000000000000006044820152606401610b43565b6009805461ffff80821684011661ffff1990911617905560005b81811015610c8b57611391836127b5565b5061139b816139e9565b9050611380565b6113aa61263a565b6001600160a01b03166113c56008546001600160a01b031690565b6001600160a01b0316146114095760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b805161141b5761127a600e60006133ef565b80516111e890600e90602084019061336b565b6002546000905b8082101561148f5760006001600160a01b03166002838154811061145b5761145b613a04565b6000918252602090912001546001600160a01b031614611484576000198301926114845761148f565b816001019150611435565b8082106115045760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201527f7574206f6620626f756e647300000000000000000000000000000000000000006064820152608401610b43565b50919050565b600e8054611517906138eb565b80601f0160208091040260200160405190810160405280929190818152602001828054611543906138eb565b80156115905780601f1061156557610100808354040283529160200191611590565b820191906000526020600020905b81548152906001019060200180831161157357829003601f168201915b505050505081565b60006115a3826125f0565b6116015760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610b43565b60006002838154811061161657611616613a04565b6000918252602090912001546001600160a01b03169392505050565b60006001600160a01b0382166116b05760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f2061646472657373000000000000000000000000000000000000000000006064820152608401610b43565b60025460005b8181101561170557836001600160a01b0316600282815481106116db576116db613a04565b6000918252602090912001546001600160a01b031614156116fd578260010192505b6001016116b6565b5050919050565b61171461263a565b6001600160a01b031661172f6008546001600160a01b031690565b6001600160a01b0316146117735760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b6008546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600880546001600160a01b0319169055565b604051806060016040528060298152602001613c756029913981565b6117e161263a565b6001600160a01b03166117fc6008546001600160a01b031690565b6001600160a01b0316146118405760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b6009805469ffff00000000000000001916600160401b179055565b60025460009061186d90600190613a1a565b905090565b606060018054610a58906138eb565b61188961263a565b6001600160a01b03166118a46008546001600160a01b031690565b6001600160a01b0316146118e85760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b600954600160401b900461ffff161561195a5760405162461bcd60e51b815260206004820152601260248201527118dbdb9d1c9858dd081a5cc81b1bd8dad95960721b6044820152606401610b43565b6009546601000000000000900461ffff166001146119ba5760405162461bcd60e51b815260206004820152601460248201527f7075626c6963206d696e74206e6f74206c6976650000000000000000000000006044820152606401610b43565b346119cc8266b1a2bc2ec50000613a31565b14611a0e5760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742066756e647360701b6044820152606401610b43565b6009547f000000000000000000000000000000000000000000000000000000000000029090611a4a908390640100000000900461ffff166139d1565b1115611a985760405162461bcd60e51b815260206004820152601460248201527f657863656564207075626c696320737570706c790000000000000000000000006044820152606401610b43565b6009805461ffff640100000000808304821685019091160265ffff000000001990911617905560005b818110156111e857611ad2336127b5565b50611adc816139e9565b9050611ac1565b6111e8611aee61263a565b8383612a65565b611afd61263a565b6001600160a01b0316611b186008546001600160a01b031690565b6001600160a01b031614611b5c5760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b606060006002805480602002602001604051908101604052809291908181526020018280548015611bd857602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611bba575b50939695505050505050565b611bf5611bef61263a565b836127d0565b611c5b5760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610b43565b611c6784848484612b34565b50505050565b60606000611c7a83611632565b905080611cd85760405162461bcd60e51b815260206004820152602660248201527f455243373231456e756d657261626c653a206f776e6572206f776e73206e6f20604482015265746f6b656e7360d01b6064820152608401610b43565b60025460008267ffffffffffffffff811115611cf657611cf6613532565b604051908082528060200260200182016040528015611d1f578160200160208202803683370190505b5090506000805b83811015611d9457866001600160a01b031660028281548110611d4b57611d4b613a04565b6000918252602090912001546001600160a01b03161415611d8c5780838380600101945081518110611d7f57611d7f613a04565b6020026020010181815250505b600101611d26565b509095945050505050565b6060600e8054611dae906138eb565b159050611dee57611dbd611e25565b600e611dc884612bb2565b604051602001611dda93929190613a50565b604051602081830303815290604052610a43565b611df6611e25565b611dff83612bb2565b604051602001611e10929190613b2b565b60405160208183030381529060405292915050565b6060600d8054610a58906138eb565b611e3c61263a565b6001600160a01b0316611e576008546001600160a01b031690565b6001600160a01b031614611e9b5760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b6009805467ffff00000000000019166601000000000000179055565b600954600160401b900461ffff1615611f075760405162461bcd60e51b815260206004820152601260248201527118dbdb9d1c9858dd081a5cc81b1bd8dad95960721b6044820152606401610b43565b34611f198266b1a2bc2ec50000613a31565b14611f5b5760405162461bcd60e51b8152602060048201526012602482015271696e73756666696369656e742066756e647360701b6044820152606401610b43565b6009547f000000000000000000000000000000000000000000000000000000000000029090611f97908390640100000000900461ffff166139d1565b1115611fe55760405162461bcd60e51b815260206004820152601460248201527f657863656564207075626c696320737570706c790000000000000000000000006044820152606401610b43565b336000908152600c602052604090205482906120029083906139d1565b11156120505760405162461bcd60e51b815260206004820152601160248201527f65786365656420616c6c6f636174696f6e0000000000000000000000000000006044820152606401610b43565b6120908585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612cc892505050565b6120dc5760405162461bcd60e51b815260206004820152600e60248201527f696e76616c6964207369676e65720000000000000000000000000000000000006044820152606401610b43565b6120e885338484612cfa565b6121345760405162461bcd60e51b815260206004820152600c60248201527f696e76616c6964206861736800000000000000000000000000000000000000006044820152606401610b43565b6009805461ffff640100000000808304821685019091160265ffff0000000019909116179055336000908152600c602052604081208054830190555b8181101561219257612181336127b5565b5061218b816139e9565b9050612170565b505050505050565b60405163c455279160e01b81526001600160a01b0383811660048301526000917f000000000000000000000000a5409ec958c83c3f309868babaca7c86dcb077c191848116919083169063c45527919060240160206040518083038186803b15801561220557600080fd5b505afa158015612219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223d9190613b67565b6001600160a01b03161415612256576001915050610a43565b6001600160a01b0380851660009081526004602090815260408083209387168352929052205460ff165b949350505050565b61229061263a565b6001600160a01b03166122ab6008546001600160a01b031690565b6001600160a01b0316146122ef5760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b6001600160a01b0381166123545760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b43565b6008546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600880546001600160a01b0319166001600160a01b0392909216919091179055565b6123b861263a565b6001600160a01b03166123d36008546001600160a01b031690565b6001600160a01b0316146124175760405162461bcd60e51b81526020600482018190526024820152600080516020613c558339815191526044820152606401610b43565b600081116124675760405162461bcd60e51b815260206004820152600c60248201527f616d6f756e7420656d70747900000000000000000000000000000000000000006044820152606401610b43565b478111156124b75760405162461bcd60e51b815260206004820152601660248201527f616d6f756e7420657863656564732062616c616e6365000000000000000000006044820152606401610b43565b6001600160a01b03821661250d5760405162461bcd60e51b815260206004820152600c60248201527f61646472657373206e756c6c00000000000000000000000000000000000000006044820152606401610b43565b6040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015610c8b573d6000803e3d6000fd5b60003330141561259a57600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b0316915061259d9050565b50335b90565b60006001600160e01b031982166380ac58cd60e01b14806125d157506001600160e01b03198216635b5e139f60e01b145b80610a4357506301ffc9a760e01b6001600160e01b0319831614610a43565b60025460009082108015610a43575060006001600160a01b03166002838154811061261d5761261d613a04565b6000918252602090912001546001600160a01b0316141592915050565b600061186d612543565b600081815260036020526040902080546001600160a01b0319166001600160a01b038416908117909155819061267982611598565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006001600160a01b0386166127185760405162461bcd60e51b815260206004820152602560248201527f4e61746976654d6574615472616e73616374696f6e3a20494e56414c49445f5360448201526424a3a722a960d91b6064820152608401610b43565b600161272b61272687612d55565b612dd2565b6040805160008152602081018083529290925260ff851690820152606081018690526080810185905260a0016020604051602081039080840390855afa158015612779573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b60006127ae82846139d1565b9392505050565b6000610a438260405180602001604052806000815250612e02565b60006127db826125f0565b61283c5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610b43565b600061284783611598565b9050806001600160a01b0316846001600160a01b031614806128825750836001600160a01b031661287784610adb565b6001600160a01b0316145b806122805750612280818561219a565b826001600160a01b03166128a582611598565b6001600160a01b03161461290d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610b43565b6001600160a01b03821661296f5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610b43565b61297a600082612644565b816002828154811061298e5761298e613a04565b6000918252602082200180546001600160a01b0319166001600160a01b03938416179055604051839285811692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9190a4505050565b60006129f382611598565b9050612a00600083612644565b60028281548110612a1357612a13613a04565b6000918252602082200180546001600160a01b03191690556040518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b03161415612ac75760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610b43565b6001600160a01b03838116600081815260046020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612b3f848484612892565b612b4b84848484612e83565b611c675760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b43565b606081612bd65750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612c005780612bea816139e9565b9150612bf99050600a83613b9a565b9150612bda565b60008167ffffffffffffffff811115612c1b57612c1b613532565b6040519080825280601f01601f191660200182016040528015612c45576020820181803683370190505b5090505b841561228057612c5a600183613a1a565b9150612c67600a86613bae565b612c729060306139d1565b60f81b818381518110612c8757612c87613a04565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612cc1600a86613b9a565b9450612c49565b600073f0f137b3f4b6862d5ef02c4dac6264ddbc110528612ce98484612fdf565b6001600160a01b0316149392505050565b6040516bffffffffffffffffffffffff19606085901b16602082015260348101839052605481018290526000908590612d4b90607401604051602081830303815290604052805190602001206130ae565b1495945050505050565b6000604051806080016040528060438152602001613c126043913980516020918201208351848301516040808701518051908601209051612db5950193845260208401929092526001600160a01b03166040830152606082015260800190565b604051602081830303815290604052805190602001209050919050565b6000612ddd60065490565b60405161190160f01b6020820152602281019190915260428101839052606201612db5565b6000612e0d836130e9565b9050612e1c6000848385612e83565b610a435760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b43565b60006001600160a01b0384163b15612fd757836001600160a01b031663150b7a02612eac61263a565b8786866040518563ffffffff1660e01b8152600401612ece9493929190613bc2565b602060405180830381600087803b158015612ee857600080fd5b505af1925050508015612f18575060408051601f3d908101601f19168201909252612f1591810190613bf4565b60015b612fbd573d808015612f46576040519150601f19603f3d011682016040523d82523d6000602084013e612f4b565b606091505b508051612fb55760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b6064820152608401610b43565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612280565b506001612280565b6000806000808451604114156130095750505060208201516040830151606084015160001a613098565b8451604014156130505750505060408201516020830151907f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81169060ff1c601b01613098565b60405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610b43565b6130a4868285856131c2565b9695505050505050565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01612db5565b60006001600160a01b0382166131415760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610b43565b506002546002805460018101825560009182527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b0385169081179091556040518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4919050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561323f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610b43565b8360ff16601b148061325457508360ff16601c145b6132ab5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610b43565b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa1580156132ff573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166133625760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610b43565b95945050505050565b828054613377906138eb565b90600052602060002090601f01602090048101928261339957600085556133df565b82601f106133b257805160ff19168380011785556133df565b828001600101855582156133df579182015b828111156133df5782518255916020019190600101906133c4565b506133eb929150613425565b5090565b5080546133fb906138eb565b6000825580601f1061340b575050565b601f01602090049060005260206000209081019061127a91905b5b808211156133eb5760008155600101613426565b6001600160e01b03198116811461127a57600080fd5b60006020828403121561346257600080fd5b81356127ae8161343a565b60005b83811015613488578181015183820152602001613470565b83811115611c675750506000910152565b600081518084526134b181602086016020860161346d565b601f01601f19169290920160200192915050565b6020815260006127ae6020830184613499565b6000602082840312156134ea57600080fd5b5035919050565b6001600160a01b038116811461127a57600080fd5b6000806040838503121561351957600080fd5b8235613524816134f1565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561356357613563613532565b604051601f8501601f19908116603f0116810190828211818310171561358b5761358b613532565b816040528093508581528686860111156135a457600080fd5b858560208301376000602087830101525050509392505050565b600082601f8301126135cf57600080fd5b6127ae83833560208501613548565b600080600080600060a086880312156135f657600080fd5b8535613601816134f1565b9450602086013567ffffffffffffffff81111561361d57600080fd5b613629888289016135be565b9450506040860135925060608601359150608086013560ff8116811461364e57600080fd5b809150509295509295909350565b60008060006060848603121561367157600080fd5b833561367c816134f1565b9250602084013561368c816134f1565b929592945050506040919091013590565b6000602082840312156136af57600080fd5b81356127ae816134f1565b6000602082840312156136cc57600080fd5b813567ffffffffffffffff8111156136e357600080fd5b8201601f810184136136f457600080fd5b61228084823560208401613548565b6000806040838503121561371657600080fd5b8235613721816134f1565b91506020830135801515811461373657600080fd5b809150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156137825783516001600160a01b03168352928401929184019160010161375d565b50909695505050505050565b600080600080608085870312156137a457600080fd5b84356137af816134f1565b935060208501356137bf816134f1565b925060408501359150606085013567ffffffffffffffff8111156137e257600080fd5b6137ee878288016135be565b91505092959194509250565b6020808252825182820181905260009190848201906040850190845b8181101561378257835183529284019291840191600101613816565b60008060008060006080868803121561384a57600080fd5b85359450602086013567ffffffffffffffff8082111561386957600080fd5b818801915088601f83011261387d57600080fd5b81358181111561388c57600080fd5b89602082850101111561389e57600080fd5b9699602092909201985095966040810135965060600135945092505050565b600080604083850312156138d057600080fd5b82356138db816134f1565b91506020830135613736816134f1565b600181811c908216806138ff57607f821691505b6020821081141561150457634e487b7160e01b600052602260045260246000fd5b60006001600160a01b038086168352808516602084015250606060408301526133626060830184613499565b6000815161395e81856020860161346d565b9290920192915050565b6000835161397a81846020880161346d565b60609390931b6bffffffffffffffffffffffff19169190920190815260140192915050565b600082516139b181846020870161346d565b9190910192915050565b634e487b7160e01b600052601160045260246000fd5b600082198211156139e4576139e46139bb565b500190565b60006000198214156139fd576139fd6139bb565b5060010190565b634e487b7160e01b600052603260045260246000fd5b600082821015613a2c57613a2c6139bb565b500390565b6000816000190483118215151615613a4b57613a4b6139bb565b500290565b600084516020613a638285838a0161346d565b602f60f81b918401918252855460019060009080831c81841680613a8857607f821691505b858210811415613aa657634e487b7160e01b84526022600452602484fd5b808015613aba5760018114613acf57613b00565b60ff1984168887015282880186019450613b00565b60008c81526020902060005b84811015613af65781548a8201890152908701908801613adb565b5050858389010194505b50505050613b1e613b1882602f60f81b815260010190565b8861394c565b9998505050505050505050565b60008351613b3d81846020880161346d565b602f60f81b9083019081528351613b5b81600184016020880161346d565b01600101949350505050565b600060208284031215613b7957600080fd5b81516127ae816134f1565b634e487b7160e01b600052601260045260246000fd5b600082613ba957613ba9613b84565b500490565b600082613bbd57613bbd613b84565b500690565b60006001600160a01b038087168352808616602084015250836040830152608060608301526130a46080830184613499565b600060208284031215613c0657600080fd5b81516127ae8161343a56fe4d6574615472616e73616374696f6e2875696e74323536206e6f6e63652c616464726573732066726f6d2c62797465732066756e6374696f6e5369676e6174757265294f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572436f6c6c656374696f6e206f662036363620756e697175652054696e792047686f7374204e4654732ea264697066735822122010957ac37c45e61349d643c33a1e462d84e200b7588a8418b4dae2e7b3958bc664736f6c63430008090033
Verified Source Code Partial Match
Compiler: v0.8.9+commit.e5eed63a
EVM: london
Optimization: Yes (666 runs)
GeneticChain721.sol 450 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//------------------------------------------------------------------------------
// geneticchain.io - NextGen Generative NFT Platform
//------------------------------------------------------------------------------
//________________________________________________________________ .¿yy¿. __
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM```````/MMM\\\\\ \\$$$$$$S/ .
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`` `/ yyyy ` _____J$$$*^^*/%#//
//MMMMMMMMMMMMMMMMMMMYYYMMM```` `\/ .¿yü / $ùpüüü%%% | ``|//|` __
//MMMMMYYYYMMMMMMM/` `| ___.¿yüy¿. .d$$$$ / $$$$SSSSM | | || MMNNNNNNM
//M/`` ``\/` .¿ù%%/. |.d$$$$$$$b.$$$*°^ / o$$$ __ | | || MMMMMMMMM
//M .¿yy¿. .dX$$$$$$7.|$$$$"^"$$$$$$o` /MM o$$$ MM | | || MMYYYYYYM
// \\$$$$$$S/ .S$$o"^"4$$$$$$$` _ `SSSSS\ ____ MM |___|_|| MM ____
// J$$$*^^*/%#//oSSS` YSSSSSS / pyyyüüü%%%XXXÙ$$$$ MM pyyyyyyy, `` ,$$$o
//.$$$` ___ pyyyyyyyyyyyy//+ / $$$$$$SSSSSSSÙM$$$. `` .S&&T$T$$$byyd$$$$\
//\$$7 `` //o$$SSXMMSSSS | / $$/&&X _ ___ %$$$byyd$$$X\$`/S$$$$$$$S\
//o$$l .\\YS$$X>$X _ ___| | / $$/%$$b.,.d$$$\`7$$$$$$$$7`.$ `"***"` __
//o$$l __ 7$$$X>$$b.,.d$$$\ | / $$.`7$$$$$$$$%` `*+SX+*|_\\$ /. ..\MM
//o$$L MM !$$$$\$$$$$$$$$%|__| / $$// `*+XX*\'` `____ ` `/MMMMMMM
///$$X, `` ,S$$$$\ `*+XX*\'`____ / %SXX . ., NERV ___.¿yüy¿. /MMMMM
// 7$$$byyd$$$>$X\ .,,_ $$$$ ` ___ .y%%ü¿. _______ $.d$$$$$$$S. `MMMM
// `/S$$$$$$$\\$J`.\\$$$ : $\`.¿yüy¿. `\\ $$$$$$S.//XXSSo $$$$$"^"$$$$. /MMM
//y `"**"`"Xo$7J$$$$$\ $.d$$$$$$$b. ^``/$$$$.`$$$$o $$$$\ _ 'SSSo /MMM
//M/.__ .,\Y$$$\\$$O` _/ $d$$$*°\ pyyyüüü%%%W $$$o.$$$$/ S$$$. ` S$To MMM
//MMMM` \$P*$$X+ b$$l MM $$$$` _ $$$$$$SSSSM $$$X.$T&&X o$$$. ` S$To MMM
//MMMX` $<.\X\` -X$$l MM $$$$ / $$/&&X X$$$/$/X$$dyS$$>. ` S$X%/ `MM
//MMMM/ `"` . -$$$l MM yyyy / $$/%$$b.__.d$$$$/$.'7$$$$$$$. ` %SXXX. MM
//MMMMM// ./M .<$$S, `` ,S$$> / $$.`7$$$$$$$$$$$/S//_'*+%%XX\ `._ /MM
//MMMMMMMMMMMMM\ /$$$$byyd$$$$\ / $$// `*+XX+*XXXX ,. .\MMMMMMMMMMM
//GENETIC/MMMMM\. /$$$$$$$$$$\| / %SXX ,_ . .\MMMMMMMMMMMMMMMMMMMMMMMM
//CHAIN/MMMMMMMM/__ `*+YY+*`_\| /_______//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//------------------------------------------------------------------------------
// Genetic Chain: GeneticChain721
//------------------------------------------------------------------------------
// Author: papaver (@tronicdreams)
//------------------------------------------------------------------------------
import "openzeppelin-solidity/contracts/access/Ownable.sol";
import "openzeppelin-solidity/contracts/utils/cryptography/ECDSA.sol";
import "openzeppelin-solidity/contracts/utils/Strings.sol";
import "./common/meta-transactions/ContentMixin.sol";
import "./common/meta-transactions/NativeMetaTransaction.sol";
import "./geneticchain/ERC721Sequential.sol";
import "./geneticchain/ERC721SeqEnumerable.sol";
import "./libraries/State.sol";
//------------------------------------------------------------------------------
// helper contracts
//------------------------------------------------------------------------------
contract OwnableDelegateProxy {}
//------------------------------------------------------------------------------
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
//------------------------------------------------------------------------------
// GeneticChain721
//------------------------------------------------------------------------------
/**
* @title GeneticChain721
*
* ERC721 contract with various features:
* - low-gas implmentation
* - off-chain whitelist verify (secure minting)
* - dynamic token allocation
* - artist allocation
* - gallery allocation
* - low-gas generative token hash
* - protected controlled burns
* - opensea proxy setup
* - simple funds withdrawl
*/
abstract contract GeneticChain721 is
ContextMixin,
ERC721SeqEnumerable,
NativeMetaTransaction,
Ownable
{
using ECDSA for bytes32;
using State for State.Data;
//-------------------------------------------------------------------------
// fields
//-------------------------------------------------------------------------
// erc721 metadata
string constant private __name = "Tiny Ghost Genesis";
string constant private __symbol = "TINYGHOST";
// metadata
uint256 constant public projectId = 9;
string constant public artist = "Reis O'Brien";
string constant public description = "Collection of 666 unique Tiny Ghost NFTs.";
// mint price
uint256 constant public memberPrice = .05 ether;
uint256 constant public publicPrice = .05 ether;
// verification address
address constant private _signer = 0xf0f137b3f4b6862d5ef02C4dAC6264DDbC110528;
// token limits
uint256 public immutable publicMax;
uint256 public immutable artistMax;
uint256 public immutable galleryMax;
// opensea proxy
address private immutable _proxyRegistryAddress;
// contract state
State.Data private _state;
// roles
address private _burnerAddress;
address private _artistAddress = 0x00f630965f882298219edBB1B96e0409EC6C8698;
// track mint count per address
mapping (address => uint256) private _mints;
//-------------------------------------------------------------------------
// modifiers
//-------------------------------------------------------------------------
modifier validTokenId(uint256 tokenId) {
require(_exists(tokenId), "invalid token");
_;
}
//-------------------------------------------------------------------------
modifier approvedOrOwner(address operator, uint256 tokenId) {
require(_isApprovedOrOwner(operator, tokenId));
_;
}
//-------------------------------------------------------------------------
modifier isArtist() {
require(_msgSender() == _artistAddress, "caller not artist");
_;
}
//-------------------------------------------------------------------------
modifier isBurner() {
require(_msgSender() == _burnerAddress, "caller not burner");
_;
}
//-------------------------------------------------------------------------
modifier notLocked() {
require(_state._locked == 0, "contract is locked");
_;
}
//-------------------------------------------------------------------------
// ctor
//-------------------------------------------------------------------------
constructor(
uint256[3] memory tokenMax_,
address proxyRegistryAddress)
ERC721Sequential(__name, __symbol)
{
publicMax = tokenMax_[0];
artistMax = tokenMax_[1];
galleryMax = tokenMax_[2];
_proxyRegistryAddress = proxyRegistryAddress;
_initializeEIP712(__name);
// start tokens at 1 index
_owners.push();
}
//-------------------------------------------------------------------------
// accessors
//-------------------------------------------------------------------------
/**
* Set artist address.
*/
function setArtistAddress(address artistAddress)
public onlyOwner
{
_artistAddress = artistAddress;
}
//-------------------------------------------------------------------------
/**
* Set burner address.
*/
function setBurnerAddress(address burner)
public onlyOwner
{
_burnerAddress = burner;
}
//-------------------------------------------------------------------------
/**
* Enable public minting.
*/
function enablePublicMint()
public onlyOwner
{
_state.setLive(1);
}
//-------------------------------------------------------------------------
/**
* Check if public minting is live.
*/
function publicLive()
public view returns (bool)
{
return _state._live == 1;
}
//-------------------------------------------------------------------------
/**
* Lock contract. Disable public/member minting. Disallow on-chain
* code/library updates.
*/
function lockContract()
public onlyOwner
{
_state.setLocked(1);
}
//-------------------------------------------------------------------------
/**
* Check if contract is locked.
*/
function isLocked()
public view returns (bool)
{
return _state._locked == 1;
}
//-------------------------------------------------------------------------
/**
* Get total gallery has minted.
*/
function gallryMinted()
public view returns (uint256)
{
return _state._gallery;
}
//-------------------------------------------------------------------------
/**
* Get total artist has minted.
*/
function artistMinted()
public view returns (uint256)
{
return _state._artist;
}
//-------------------------------------------------------------------------
/**
* Get total public has minted.
*/
function publicMinted()
public view returns (uint256)
{
return _state._public;
}
//-------------------------------------------------------------------------
// security
//-------------------------------------------------------------------------
/**
* Validate hash contains input data.
*/
function validateHash(
bytes32 msgHash,
address sender,
uint256 allocation,
uint256 count)
private pure returns(bool)
{
return ECDSA.toEthSignedMessageHash(
keccak256(abi.encodePacked(sender, allocation, count))) == msgHash;
}
//-------------------------------------------------------------------------
/**
* Validate message was signed by signer.
*/
function validateSigner(bytes32 msgHash, bytes memory signature)
private pure returns(bool)
{
return msgHash.recover(signature) == _signer;
}
//-------------------------------------------------------------------------
// minting
//-------------------------------------------------------------------------
/**
* Allow anyone to mint tokens for the right price.
*/
function mint(uint256 count)
payable public notLocked
{
require(_state._live == 1, "public mint not live");
require(publicPrice * count == msg.value, "insufficient funds");
require(_state._public + count <= publicMax, "exceed public supply");
_state.addPublic(count);
for (uint256 i = 0; i < count; ++i) {
_safeMint(msg.sender);
}
}
//-------------------------------------------------------------------------
/**
* Mint count tokens using securely signed message.
*/
function secureMint(
bytes32 msgHash,
bytes calldata signature,
uint256 allocation,
uint256 count)
payable external notLocked
{
require(memberPrice * count == msg.value, "insufficient funds");
require(_state._public + count <= publicMax, "exceed public supply");
require(_mints[msg.sender] + count <= allocation, "exceed allocation");
require(validateSigner(msgHash, signature), "invalid signer");
require(validateHash(msgHash, msg.sender, allocation, count), "invalid hash");
_state.addPublic(count);
unchecked {
_mints[msg.sender] += count;
}
for (uint256 i = 0; i < count; ++i) {
_safeMint(msg.sender);
}
}
//-------------------------------------------------------------------------
/**
* @dev Mints a token to an address.
* @param _to address of the future owner of the token
*/
function galleryMintTo(address _to, uint256 count)
public onlyOwner
{
require(_state._gallery + count <= galleryMax, "exceed gallery supply");
_state.addGallery(count);
for (uint256 i = 0; i < count; ++i) {
_safeMint(_to);
}
}
//-------------------------------------------------------------------------
/**
* @dev Mints a token to an address.
* @param _to address of the future owner of the token
*/
function artistMintTo(address _to, uint256 count)
public isArtist
{
require(_state._artist + count <= artistMax, "exceed artist supply");
_state.addArtist(count);
for (uint256 i = 0; i < count; ++i) {
_safeMint(_to);
}
}
//-------------------------------------------------------------------------
/**
* @dev Burns `tokenId`. See {ERC721-_burn}.
*/
function burn(uint256 tokenId)
public isBurner
{
_burn(tokenId);
}
//-------------------------------------------------------------------------
// money
//-------------------------------------------------------------------------
/**
* Pull money out of this contract.
*/
function withdraw(address to, uint256 amount)
public onlyOwner
{
require(amount > 0, "amount empty");
require(amount <= address(this).balance, "amount exceeds balance");
require(to != address(0), "address null");
payable(to).transfer(amount);
}
//-------------------------------------------------------------------------
// approval
//-------------------------------------------------------------------------
/**
* Override isApprovedForAll to whitelist user's OpenSea proxy accounts
* to enable gas-less listings.
*/
function isApprovedForAll(address owner, address operator)
override public view returns (bool)
{
// whitelist OpenSea proxy contract for easy trading
ProxyRegistry proxyRegistry = ProxyRegistry(_proxyRegistryAddress);
if (address(proxyRegistry.proxies(owner)) == operator) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
//-------------------------------------------------------------------------
/**
* This is used instead of msg.sender as transactions won't be sent by
* the original token owner, but by OpenSea.
*/
function _msgSender()
override internal view returns (address sender)
{
return ContextMixin.msgSender();
}
}
State.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//------------------------------------------------------------------------------
// geneticchain.io - NextGen Generative NFT Platform
//------------------------------------------------------------------------------
// _______ __ __ ______ __ __
// | __|-----.-----.-----| |_|__|----. | | |--.---.-|__|-----.
// | | | -__| | -__| _| | __| | ---| | _ | | |
// |_______|_____|__|__|_____|____|__|____| |______|__|__|___._|__|__|__|
//
//------------------------------------------------------------------------------
// Genetic Chain: library/State
//------------------------------------------------------------------------------
// Author: papaver (@tronicdreams)
//------------------------------------------------------------------------------
/**
* @dev Handle contract state efficiently as possbile.
*/
library State {
struct Data {
uint16 _gallery;
uint16 _artist;
uint16 _public;
uint16 _live;
uint16 _locked;
uint176 _unused;
}
function addGallery(Data storage data, uint256 count)
internal
{
unchecked {
data._gallery += uint16(count);
}
}
function addArtist(Data storage data, uint256 count)
internal
{
unchecked {
data._artist += uint16(count);
}
}
function addPublic(Data storage data, uint256 count)
internal
{
unchecked {
data._public += uint16(count);
}
}
function setLive(Data storage data, uint256 enable)
internal
{
data._live = uint16(enable);
}
function setLocked(Data storage data, uint256 enable)
internal
{
data._locked = uint16(enable);
}
function set(Data storage data, uint256 _gallery, uint256 _artist, uint256 _public)
internal
{
data._gallery = uint16(_gallery);
data._artist = uint16(_artist);
data._public = uint16(_public);
}
}
TinyGhostGenesis.sol 134 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//-----------------------------------------------------------------------------
// geneticchain.io - NextGen Generative NFT Platform
//-----------------------------------------------------------------------------
/*\_____________________________________________________________ .¿yy¿. __
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM```````/MMM\\\\\ \\$$$$$$S/ .
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM`` `/ yyyy ` _____J$$$^^^^/%#//
MMMMMMMMMMMMMMMMMMMYYYMMM```` `\/ .¿yü / $ùpüüü%%% | ``|//|` __
MMMMMYYYYMMMMMMM/` `| ___.¿yüy¿. .d$$$$ / $$$$SSSSM | | || MMNNNNNNM
M/`` ``\/` .¿ù%%/. |.d$$$$$$$b.$$$*°^ / o$$$ __ | | || MMMMMMMMM
M .¿yy¿. .dX$$$$$$7.|$$$$"^"$$$$$$o` /MM o$$$ MM | | || MMYYYYYYM
\\$$$$$$S/ .S$$o"^"4$$$$$$$` _ `SSSSS\ ____ MM |___|_|| MM ____
J$$$^^^^/%#//oSSS` YSSSSSS / pyyyüüü%%%XXXÙ$$$$ MM pyyyyyyy, `` ,$$$o
.$$$` ___ pyyyyyyyyyyyy//+ / $$$$$$SSSSSSSÙM$$$. `` .S&&T$T$$$byyd$$$$\
\$$7 `` //o$$SSXMMSSSS | / $$/&&X _ ___ %$$$byyd$$$X\$`/S$$$$$$$S\
o$$l .\\YS$$X>$X _ ___| | / $$/%$$b.,.d$$$\`7$$$$$$$$7`.$ `"***"` __
o$$l __ 7$$$X>$$b.,.d$$$\ | / $$.`7$$$$$$$$%` `*+SX+*|_\\$ /. ..\MM
o$$L MM !$$$$\$$$$$$$$$%|__| / $$// `*+XX*\'` `____ ` `/MMMMMMM
/$$X, `` ,S$$$$\ `*+XX*\'`____ / %SXX . ., NERV ___.¿yüy¿. /MMMMM
7$$$byyd$$$>$X\ .,,_ $$$$ ` ___ .y%%ü¿. _______ $.d$$$$$$$S. `MMMM
`/S$$$$$$$\\$J`.\\$$$ : $\`.¿yüy¿. `\\ $$$$$$S.//XXSSo $$$$$"^"$$$$. /MMM
y `"**"`"Xo$7J$$$$$\ $.d$$$$$$$b. ^``/$$$$.`$$$$o $$$$\ _ 'SSSo /MMM
M/.__ .,\Y$$$\\$$O` _/ $d$$$*°\ pyyyüüü%%%W $$$o.$$$$/ S$$$. ` S$To MMM
MMMM` \$P*$$X+ b$$l MM $$$$` _ $$$$$$SSSSM $$$X.$T&&X o$$$. ` S$To MMM
MMMX` $<.\X\` -X$$l MM $$$$ / $$/&&X X$$$/$/X$$dyS$$>. ` S$X%/ `MM
MMMM/ `"` . -$$$l MM yyyy / $$/%$$b.__.d$$$$/$.'7$$$$$$$. ` %SXXX. MM
MMMMM// ./M .<$$S, `` ,S$$> / $$.`7$$$$$$$$$$$/S//_'*+%%XX\ `._ /MM
MMMMMMMMMMMMM\ /$$$$byyd$$$$\ / $$// `*+XX+*XXXX ,. .\MMMMMMMMMMM
GENETIC/MMMMM\. /$$$$$$$$$$\| / %SXX ,_ . .\MMMMMMMMMMMMMMMMMMMMMMMM
CHAIN/MMMMMMMM/__ `*+YY+*`_\| /_______//MMMMMMMMMMMMMMMMMMMMMMMMMMM/-/-/-\*/
//-----------------------------------------------------------------------------
// Genetic Chain: TinyGhost
//-----------------------------------------------------------------------------
// Author: papaver (@tronicdreams)
//-----------------------------------------------------------------------------
import "./GeneticChain721.sol";
//------------------------------------------------------------------------------
// GeneticChainMetadata
//------------------------------------------------------------------------------
/**
* @title TinyGhostGenesis
* GeneticChain - Project #8 - Rainbow7
*/
contract TinyGhostGenesis is GeneticChain721
{
//-------------------------------------------------------------------------
// fields
//-------------------------------------------------------------------------
string private _baseUri;
string public tokenIpfsHash;
//-------------------------------------------------------------------------
// ctor
//-------------------------------------------------------------------------
constructor(
string memory baseUri_,
string memory ipfsHash_,
uint256[3] memory tokenMax_,
address proxyRegistryAddress)
GeneticChain721(
tokenMax_,
proxyRegistryAddress)
{
_baseUri = baseUri_;
tokenIpfsHash = ipfsHash_;
}
//-------------------------------------------------------------------------
// accessors
//-------------------------------------------------------------------------
function setTokenIpfsHash(string memory hash)
public
onlyOwner
{
if (bytes(hash).length == 0) {
delete tokenIpfsHash;
} else {
tokenIpfsHash = hash;
}
}
//-------------------------------------------------------------------------
function setBaseTokenURI(string memory baseUri)
public
onlyOwner
{
_baseUri = baseUri;
}
//-------------------------------------------------------------------------
// ERC721Metadata
//-------------------------------------------------------------------------
function baseTokenURI()
public
view
returns (string memory)
{
return _baseUri;
}
//-------------------------------------------------------------------------
/**
* @dev Returns uri of a token. Not guarenteed token exists.
*/
function tokenURI(uint256 tokenId)
override
public
view
returns (string memory)
{
return bytes(tokenIpfsHash).length == 0
? string(abi.encodePacked(
baseTokenURI(), "/", Strings.toString(tokenId)))
: string(abi.encodePacked(
baseTokenURI(),
"/", tokenIpfsHash,
"/", Strings.toString(tokenId)));
}
}
ERC721Sequential.sol 464 lines
// SPDX-License-Identifier: MIT
// Forked from: OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
//------------------------------------------------------------------------------
// geneticchain.io - NextGen Generative NFT Platform
//------------------------------------------------------------------------------
// _______ __ __ ______ __ __
// | __|-----.-----.-----| |_|__|----. | | |--.---.-|__|-----.
// | | | -__| | -__| _| | __| | ---| | _ | | |
// |_______|_____|__|__|_____|____|__|____| |______|__|__|___._|__|__|__|
//
//------------------------------------------------------------------------------
// Genetic Chain: ERC721Sequential
//------------------------------------------------------------------------------
// Author: papaver (@tronicdreams)
//------------------------------------------------------------------------------
import "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721Receiver.sol";
import "openzeppelin-solidity/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "openzeppelin-solidity/contracts/utils/Address.sol";
import "openzeppelin-solidity/contracts/utils/Context.sol";
import "openzeppelin-solidity/contracts/utils/Strings.sol";
import "openzeppelin-solidity/contracts/utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721
* [ERC721] Non-Fungible Token Standard
*
* This implmentation of ERC721 assumes sequencial token creation to provide
* efficient minting. Storage for balance are no longer required reducing
* gas significantly. This comes at the price of calculating the balance by
* iterating through the entire array. The balanceOf function should NOT
* be used inside a contract. Gas usage will explode as the size of tokens
* increase. A convineiance function is provided which returns the entire
* list of owners whose index maps tokenIds to thier owners. Zero addresses
* indicate burned tokens.
*
*/
contract ERC721Sequential is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
address[] _owners;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256 balance) {
require(owner != address(0), "ERC721: balance query for the zero address");
unchecked {
uint256 length = _owners.length;
for (uint256 i = 0; i < length; ++i) {
if (_owners[i] == owner) {
++balance;
}
}
}
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: owner query for nonexistent token");
address owner = _owners[tokenId];
return owner;
}
/**
* @dev Returns entire list of owner enumerated by thier tokenIds. Burned tokens
* will have a zero address.
*/
function owners() public view returns (address[] memory) {
address[] memory owners_ = _owners;
return owners_;
}
/**
* @dev Return largest tokenId minted.
*/
function maxTokenId() public view returns (uint256) {
return _owners.length - 1;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721Sequential.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return tokenId < _owners.length && _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721Sequential.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to) internal virtual returns (uint256 tokenId) {
tokenId = _safeMint(to, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
bytes memory _data
) internal virtual returns (uint256 tokenId) {
tokenId = _mint(to);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to) internal virtual returns (uint256 tokenId) {
require(to != address(0), "ERC721: mint to the zero address");
tokenId = _owners.length;
_beforeTokenTransfer(address(0), to, tokenId);
_owners.push(to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721Sequential.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721Sequential.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721Sequential.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
ERC721SeqEnumerable.sol 123 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
//------------------------------------------------------------------------------
// geneticchain.io - NextGen Generative NFT Platform
//------------------------------------------------------------------------------
// _______ __ __ ______ __ __
// | __|-----.-----.-----| |_|__|----. | | |--.---.-|__|-----.
// | | | -__| | -__| _| | __| | ---| | _ | | |
// |_______|_____|__|__|_____|____|__|____| |______|__|__|___._|__|__|__|
//
//------------------------------------------------------------------------------
// Genetic Chain: ERC721SeqEnumerable
//------------------------------------------------------------------------------
// Author: papaver (@tronicdreams)
//------------------------------------------------------------------------------
import "openzeppelin-solidity/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "./ERC721Sequential.sol";
/**
* @dev This is a no storage implemntation of the optional extension {ERC721}
* defined in the EIP that adds enumerability of all the token ids in the
* contract as well as all token ids owned by each account. These functions
* are mainly for convienence and should NEVER be called from inside a
* contract on the chain.
*/
abstract contract ERC721SeqEnumerable is ERC721Sequential, IERC721Enumerable {
address constant zero = address(0);
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, ERC721Sequential) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId
|| super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(
address owner,
uint256 index
) public view virtual override returns (uint256 tokenId) {
uint256 length = _owners.length;
unchecked {
for (; tokenId < length; ++tokenId) {
if (_owners[tokenId] == owner) {
if (index-- == 0) {
break;
}
}
}
}
require(tokenId < length, "ERC721Enumerable: owner index out of bounds");
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256 supply) {
unchecked {
uint256 length = _owners.length;
for (uint256 tokenId = 0; tokenId < length; ++tokenId) {
if (_owners[tokenId] != zero) {
++supply;
}
}
}
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(
uint256 index
) public view virtual override returns (uint256 tokenId) {
uint256 length = _owners.length;
unchecked {
for (; tokenId < length; ++tokenId) {
if (_owners[tokenId] != zero) {
if (index-- == 0) {
break;
}
}
}
}
require(tokenId < length, "ERC721Enumerable: global index out of bounds");
}
/**
* @dev Get all tokens owned by owner.
*/
function ownerTokens(
address owner
) public view returns (uint256[] memory) {
uint256 tokenCount = ERC721Sequential.balanceOf(owner);
require(tokenCount != 0, "ERC721Enumerable: owner owns no tokens");
uint256 length = _owners.length;
uint256[] memory tokenIds = new uint256[](tokenCount);
unchecked {
uint256 i = 0;
for (uint256 tokenId = 0; tokenId < length; ++tokenId) {
if (_owners[tokenId] == owner) {
tokenIds[i++] = tokenId;
}
}
}
return tokenIds;
}
}
Address.sol 189 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant alphabet = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = alphabet[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
EIP712Base.sol 77 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Initializable} from "./Initializable.sol";
contract EIP712Base is Initializable {
struct EIP712Domain {
string name;
string version;
address verifyingContract;
bytes32 salt;
}
string constant public ERC712_VERSION = "1";
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256(
bytes(
"EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"
)
);
bytes32 internal domainSeperator;
// supposed to be called once while initializing.
// one of the contracts that inherits this contract follows proxy pattern
// so it is not possible to do this in a constructor
function _initializeEIP712(
string memory name
)
internal
initializer
{
_setDomainSeperator(name);
}
function _setDomainSeperator(string memory name) internal {
domainSeperator = keccak256(
abi.encode(
EIP712_DOMAIN_TYPEHASH,
keccak256(bytes(name)),
keccak256(bytes(ERC712_VERSION)),
address(this),
bytes32(getChainId())
)
);
}
function getDomainSeperator() public view returns (bytes32) {
return domainSeperator;
}
function getChainId() public view returns (uint256) {
uint256 id;
assembly {
id := chainid()
}
return id;
}
/**
* Accept message hash and returns hash message in EIP712 compatible form
* So that it can be used to recover signer from signature signed using EIP712 formatted data
* https://eips.ethereum.org/EIPS/eip-712
* "\\x19" makes the encoding deterministic
* "\\x01" is the version byte to make it compatible to EIP-191
*/
function toTypedMessageHash(bytes32 messageHash)
internal
view
returns (bytes32)
{
return
keccak256(
abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash)
);
}
}
Ownable.sol 68 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = 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");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
ContentMixin.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
abstract contract ContextMixin {
function msgSender()
internal
view
returns (address payable sender)
{
if (msg.sender == address(this)) {
bytes memory array = msg.data;
uint256 index = msg.data.length;
assembly {
// Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
sender := and(
mload(add(array, index)),
0xffffffffffffffffffffffffffffffffffffffff
)
}
} else {
sender = payable(msg.sender);
}
return sender;
}
}
Initializable.sol 13 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Initializable {
bool inited = false;
modifier initializer() {
require(!inited, "already inited");
_;
inited = true;
}
}
SafeMath.sol 218 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
IERC721.sol 129 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
ECDSA.sol 111 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Divide the signature in r, s and v variables
bytes32 r;
bytes32 s;
uint8 v;
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
} else if (signature.length == 64) {
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
// solhint-disable-next-line no-inline-assembly
assembly {
let vs := mload(add(signature, 0x40))
r := mload(add(signature, 0x20))
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
} else {
revert("ECDSA: invalid signature length");
}
return recover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value");
require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
NativeMetaTransaction.sol 106 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {SafeMath} from "openzeppelin-solidity/contracts/utils/math/SafeMath.sol";
import {EIP712Base} from "./EIP712Base.sol";
contract NativeMetaTransaction is EIP712Base {
using SafeMath for uint256;
bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256(
bytes(
"MetaTransaction(uint256 nonce,address from,bytes functionSignature)"
)
);
event MetaTransactionExecuted(
address userAddress,
address payable relayerAddress,
bytes functionSignature
);
mapping(address => uint256) nonces;
/*
* Meta transaction structure.
* No point of including value field here as if user is doing value transfer then he has the funds to pay for gas
* He should call the desired function directly in that case.
*/
struct MetaTransaction {
uint256 nonce;
address from;
bytes functionSignature;
}
function executeMetaTransaction(
address userAddress,
bytes memory functionSignature,
bytes32 sigR,
bytes32 sigS,
uint8 sigV
) public payable returns (bytes memory) {
MetaTransaction memory metaTx = MetaTransaction({
nonce: nonces[userAddress],
from: userAddress,
functionSignature: functionSignature
});
require(
verify(userAddress, metaTx, sigR, sigS, sigV),
"Signer and signature do not match"
);
// increase nonce for user (to avoid re-use)
nonces[userAddress] = nonces[userAddress].add(1);
emit MetaTransactionExecuted(
userAddress,
payable(msg.sender),
functionSignature
);
// Append userAddress and relayer address at the end to extract it from calling context
(bool success, bytes memory returnData) = address(this).call(
abi.encodePacked(functionSignature, userAddress)
);
require(success, "Function call not successful");
return returnData;
}
function hashMetaTransaction(MetaTransaction memory metaTx)
internal
pure
returns (bytes32)
{
return
keccak256(
abi.encode(
META_TRANSACTION_TYPEHASH,
metaTx.nonce,
metaTx.from,
keccak256(metaTx.functionSignature)
)
);
}
function getNonce(address user) public view returns (uint256 nonce) {
nonce = nonces[user];
}
function verify(
address signer,
MetaTransaction memory metaTx,
bytes32 sigR,
bytes32 sigS,
uint8 sigV
) internal view returns (bool) {
require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER");
return
signer ==
ecrecover(
toTypedMessageHash(hashMetaTransaction(metaTx)),
sigV,
sigR,
sigS
);
}
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
ERC712_VERSION 0x0f7e5970 → string
artist 0x43bc1612 → string
artistMax 0xef3c6624 → uint256
artistMinted 0xed329fa8 → uint256
balanceOf 0x70a08231 → uint256
baseTokenURI 0xd547cfb7 → string
description 0x7284e416 → string
galleryMax 0x71dedace → uint256
gallryMinted 0xf593bd53 → uint256
getApproved 0x081812fc → address
getChainId 0x3408e470 → uint256
getDomainSeperator 0x20379ee5 → bytes32
getNonce 0x2d0335ab → uint256
isApprovedForAll 0xe985e9c5 → bool
isLocked 0xa4e2d634 → bool
maxTokenId 0x91ba317a → uint256
memberPrice 0x636e746b → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
ownerTokens 0xbba7723e → uint256[]
owners 0xaffe39c1 → address[]
projectId 0x3fafa127 → uint256
publicLive 0xb7f751d8 → bool
publicMax 0xe527c6dd → uint256
publicMinted 0xa4f4f8af → uint256
publicPrice 0xa945bf80 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenIpfsHash 0x5cdf532f → string
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 20 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
artistMintTo 0x14d7d517
address _to
uint256 count
burn 0x42966c68
uint256 tokenId
enablePublicMint 0xd62f3b1c
No parameters
executeMetaTransaction 0x0c53c51c
address userAddress
bytes functionSignature
bytes32 sigR
bytes32 sigS
uint8 sigV
returns: bytes
galleryMintTo 0x44be774f
address _to
uint256 count
lockContract 0x753868e3
No parameters
mint 0xa0712d68
uint256 count
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
secureMint 0xd81bc663
bytes32 msgHash
bytes signature
uint256 allocation
uint256 count
setApprovalForAll 0xa22cb465
address operator
bool approved
setArtistAddress 0xa22e4faa
address artistAddress
setBaseTokenURI 0x30176e13
string baseUri
setBurnerAddress 0x9df806d6
address burner
setTokenIpfsHash 0x4dcc60af
string hash
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0xf3fef3a3
address to
uint256 amount
Recent Transactions
No transactions found for this address