Address Contract Verified
Address
0x10039a64Ab4C2513963C2A00fA5768Bb02E2274B
Balance
0 ETH
Nonce
2
Code Size
16879 bytes
Creator
0x7B171319...F6dd at tx 0x59e6d582...e948a7
Indexed Transactions
0
Contract Bytecode
16879 bytes
0x6080604052600436106103a25760003560e01c8063938e3d7b116101e7578063cf8d8dd81161010d578063e8a3d485116100a0578063efc621251161006f578063efc6212514610a7b578063f2fde38b14610a9b578063f3993d1114610abb578063f514ab4a14610adb57600080fd5b8063e8a3d485146109f9578063e985e9c514610a0e578063ea66aeb314610a2e578063eb7044df14610a5b57600080fd5b8063d5abeb01116100dc578063d5abeb011461096f578063d7d6287c146109a4578063e18ccd25146109c4578063e2982c21146109d957600080fd5b8063cf8d8dd814610905578063cfc86f7b14610925578063d26ea6c01461093a578063d547cfb71461095a57600080fd5b8063a22cb46511610185578063c0e7274011610154578063c0e727401461089b578063c87b56dd146108b0578063ca628c78146108d0578063cd7c0326146108e557600080fd5b8063a22cb46514610826578063b4c7f06614610846578063b88d4fde14610866578063c07b05911461088657600080fd5b80639d34b691116101c15780639d34b691146107b35780639d76ea58146107d35780639eb5f5e3146107f3578063a0712d681461081357600080fd5b8063938e3d7b1461075e578063943d4c3c1461077e57806395d89b411461079e57600080fd5b80633d6a5745116102cc5780636352211e1161026a5780637e8c3976116102395780637e8c3976146106f65780637f31af0a1461070b5780638da5cb5b1461072057806390e7ee191461073e57600080fd5b80636352211e1461068257806370a08231146106a2578063715018a6146106c2578063720ee791146106d757600080fd5b80634d44660c116102a65780634d44660c1461060c5780635a4fee301461062c5780635a64ad951461064c5780635bf8633a1461066257600080fd5b80633d6a5745146105ac57806342842e0e146105cc578063449a52f8146105ec57600080fd5b80631c5e85f11161034457806323b872dd1161031357806323b872dd1461052c5780632c1e816d1461054c57806330176e131461056c57806331b3eb941461058c57600080fd5b80631c5e85f1146104ac5780631d37d24d146104cc5780631e779bae146104ec578063238a47091461050c57600080fd5b80630955117a116103805780630955117a14610436578063095ea7b3146104555780630b102d1a1461047757806318160ddd1461049757600080fd5b806301ffc9a7146103a757806306fdde03146103dc578063081812fc146103fe575b600080fd5b3480156103b357600080fd5b506103c76103c2366004613988565b610b14565b60405190151581526020015b60405180910390f35b3480156103e857600080fd5b506103f1610bb1565b6040516103d391906139f5565b34801561040a57600080fd5b5061041e610419366004613a08565b610c43565b6040516001600160a01b0390911681526020016103d3565b34801561044257600080fd5b506008545b6040519081526020016103d3565b34801561046157600080fd5b50610475610470366004613a36565b610c6a565b005b34801561048357600080fd5b50610475610492366004613a62565b610da0565b3480156104a357600080fd5b50610447610dca565b3480156104b857600080fd5b50600654600160a01b900461ffff16610447565b3480156104d857600080fd5b506104756104e7366004613acb565b610dec565b3480156104f857600080fd5b50610475610507366004613b2e565b611186565b34801561051857600080fd5b50610475610527366004613a08565b61124e565b34801561053857600080fd5b50610475610547366004613b4b565b61125b565b34801561055857600080fd5b50610475610567366004613a62565b6112d2565b34801561057857600080fd5b50610475610587366004613bce565b6112fc565b34801561059857600080fd5b506104756105a7366004613a62565b611311565b3480156105b857600080fd5b506104756105c7366004613a36565b6113a2565b3480156105d857600080fd5b506104756105e7366004613b4b565b6115fb565b3480156105f857600080fd5b50610475610607366004613a36565b611616565b34801561061857600080fd5b506103c7610627366004613acb565b61181e565b34801561063857600080fd5b50610475610647366004613c10565b611885565b34801561065857600080fd5b5061044760075481565b34801561066e57600080fd5b50600b5461041e906001600160a01b031681565b34801561068e57600080fd5b5061041e61069d366004613a08565b61197a565b3480156106ae57600080fd5b506104476106bd366004613a62565b6119df565b3480156106ce57600080fd5b50610475611a79565b3480156106e357600080fd5b50600b54600160b01b900460ff166103c7565b34801561070257600080fd5b50610475611a8d565b34801561071757600080fd5b50600754610447565b34801561072c57600080fd5b506006546001600160a01b031661041e565b34801561074a57600080fd5b50610475610759366004613a62565b611abb565b34801561076a57600080fd5b50610475610779366004613bce565b611ae7565b34801561078a57600080fd5b50610475610799366004613ca5565b611afc565b3480156107aa57600080fd5b506103f1611cf9565b3480156107bf57600080fd5b506104756107ce366004613b2e565b611d08565b3480156107df57600080fd5b50600a5461041e906001600160a01b031681565b3480156107ff57600080fd5b5061047561080e366004613a62565b611d49565b610475610821366004613a08565b611d72565b34801561083257600080fd5b50610475610841366004613cdb565b61200b565b34801561085257600080fd5b50610475610861366004613b2e565b61201a565b34801561087257600080fd5b50610475610881366004613d2a565b61205b565b34801561089257600080fd5b506104756120d9565b3480156108a757600080fd5b506103f1612249565b3480156108bc57600080fd5b506103f16108cb366004613a08565b6122d7565b3480156108dc57600080fd5b50610475612311565b3480156108f157600080fd5b50600e5461041e906001600160a01b031681565b34801561091157600080fd5b50610475610920366004613b2e565b6123c3565b34801561093157600080fd5b506103f161248b565b34801561094657600080fd5b50610475610955366004613a62565b612498565b34801561096657600080fd5b506103f16124c2565b34801561097b57600080fd5b5060065461099190600160f01b900461ffff1681565b60405161ffff90911681526020016103d3565b3480156109b057600080fd5b506104756109bf366004613ca5565b6124d1565b3480156109d057600080fd5b506104756127e2565b3480156109e557600080fd5b506104476109f4366004613a62565b61287e565b348015610a0557600080fd5b506103f1612926565b348015610a1a57600080fd5b506103c7610a29366004613e0a565b612935565b348015610a3a57600080fd5b50610a4e610a49366004613a62565b612a32565b6040516103d39190613e38565b348015610a6757600080fd5b50610a4e610a76366004613a62565b612be5565b348015610a8757600080fd5b50610475610a96366004613a62565b612dd5565b348015610aa757600080fd5b50610475610ab6366004613a62565b612dff565b348015610ac757600080fd5b50610475610ad6366004613e70565b612e8f565b348015610ae757600080fd5b506103c7610af6366004613a62565b6001600160a01b03166000908152600f602052604090205460ff1690565b60006001600160e01b031982167f80ac58cd000000000000000000000000000000000000000000000000000000001480610b7757506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b80610bab57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b606060008054610bc090613ed5565b80601f0160208091040260200160405190810160405280929190818152602001828054610bec90613ed5565b8015610c395780601f10610c0e57610100808354040283529160200191610c39565b820191906000526020600020905b815481529060010190602001808311610c1c57829003601f168201915b5050505050905090565b6000610c4e82612f4b565b506000908152600460205260409020546001600160a01b031690565b6000610c758261197a565b9050806001600160a01b0316836001600160a01b031603610d035760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b336001600160a01b0382161480610d1f5750610d1f8133612935565b610d915760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610cfa565b610d9b8383612faf565b505050565b610da861301d565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b600854600654600091610de791600160a01b900461ffff16613f25565b905090565b600b54600160b01b900460ff1615610e0357600080fd5b600b805460ff60b01b1916600160b01b179055323314610e5c5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b6009546001600160a01b03163314610e7357600080fd5b600854600b546040516370a0823160e01b81526001600160a01b03868116600483015284926000929116906370a0823190602401602060405180830381865afa158015610ec4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee89190613f38565b600b54909150600160a01b900460ff161515600114610f495760405162461bcd60e51b815260206004820152601860248201527f436c61696d696e67206973206e6f7420656e61626c65642e00000000000000006044820152606401610cfa565b60008211610f995760405162461bcd60e51b815260206004820152601c60248201527f696473546f4d696e74206c656e677468206d757374206265203e2030000000006044820152606401610cfa565b60008111610fe95760405162461bcd60e51b815260206004820152601360248201527f4e6f204f4720746f6b656e73206f776e65642e000000000000000000000000006044820152606401610cfa565b60065461100290600160b01b900461ffff166001613f51565b61ffff166110108385613f25565b1061105d5760405162461bcd60e51b815260206004820152601860248201527f436c61696d61626c6520737570706c79206578656564656400000000000000006044820152606401610cfa565b60005b8281101561116e57600b546001600160a01b0316636352211e87878481811061108b5761108b613f73565b905060200201356040518263ffffffff1660e01b81526004016110b091815260200190565b602060405180830381865afa1580156110cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f19190613f89565b6001600160a01b0316876001600160a01b03160361114257600954611137906001600160a01b031687878481811061112b5761112b613f73565b90506020020135613077565b836001019350611166565b604051632498f11160e21b81526001600160a01b0388166004820152602401610cfa565b600101611060565b5050506008555050600b805460ff60b01b1916905550565b3233146111cc5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff16156111e357600080fd5b600b805460ff60b01b1916600160b01b1790556009546001600160a01b0316331461120d57600080fd5b600b80547fffffffffffffffffff00ff00ffffffffffffffffffffffffffffffffffffffff16600160a01b9215159290920260ff60b01b1916919091179055565b61125661301d565b600755565b6112653382613202565b6112c75760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608401610cfa565b610d9b838383613260565b6112da61301d565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b61130461301d565b600d610d9b828483613ff6565b61131961301d565b32331461135f5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff161561137657600080fd5b600b805460ff60b01b1916600160b01b17905561139281613459565b50600b805460ff60b01b19169055565b600b54600160b01b900460ff16156113b957600080fd5b600b805460ff60b01b1916600160b01b1790553233146114125760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600654600954600160a01b90910461ffff1690336001600160a01b039091161461143b57600080fd5b6000821161148b5760405162461bcd60e51b815260206004820152601460248201527f436f756e64206d757374206265203e207a65726f0000000000000000000000006044820152606401610cfa565b600b54600160a81b900460ff1615156001146114e95760405162461bcd60e51b815260206004820152601660248201527f4d696e74696e67206973206e6f7420656e61626c6564000000000000000000006044820152606401610cfa565b60065461150a9061ffff600160e01b8204811691600160f01b9004166140b6565b611515906001613f51565b61ffff16828261ffff166115299190613f25565b1061158b5760405162461bcd60e51b815260206004820152602c60248201527f4d6178206d696e7420737570706c792e2043616e6e6f74206d696e742074686160448201526b3a1036b0b73c9027232a399760a11b6064820152608401610cfa565b60005b828110156115c9576006546115bd9085906115b490600160e01b900461ffff1685613f51565b61ffff16613077565b6001918201910161158e565b506006805461ffff909216600160a01b0261ffff60a01b199092169190911790555050600b805460ff60b01b19169055565b610d9b8383836040518060200160405280600081525061205b565b61161e61301d565b600b54600160b01b900460ff161561163557600080fd5b600b805460ff60b01b1916600160b01b17905532331461168e5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600654600160a01b900461ffff16816116e95760405162461bcd60e51b815260206004820152601460248201527f436f756e64206d757374206265203e207a65726f0000000000000000000000006044820152606401610cfa565b600b54600160a81b900460ff1615156001146117475760405162461bcd60e51b815260206004820152601660248201527f4d696e74696e67206973206e6f7420656e61626c6564000000000000000000006044820152606401610cfa565b6006546117689061ffff600160e01b8204811691600160f01b9004166140b6565b611773906001613f51565b61ffff16828261ffff166117879190613f25565b106117e95760405162461bcd60e51b815260206004820152602c60248201527f4d6178206d696e7420737570706c792e2043616e6e6f74206d696e742074686160448201526b3a1036b0b73c9027232a399760a11b6064820152608401610cfa565b60005b828110156115c9576006546118129085906115b490600160e01b900461ffff1685613f51565b600191820191016117ec565b600081815b8181101561187757856001600160a01b031661185686868481811061184a5761184a613f73565b9050602002013561197a565b6001600160a01b03161461186f5760009250505061187e565b600101611823565b5060019150505b9392505050565b3233146118cb5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff16156118e257600080fd5b600b805460ff60b01b1916600160b01b1790558260005b818110156119635761195b888888888581811061191857611918613f73565b9050602002013587878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061205b92505050565b6001016118f9565b5050600b805460ff60b01b19169055505050505050565b6000818152600260205260408120546001600160a01b031680610bab5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610cfa565b60006001600160a01b038216611a5d5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610cfa565b506001600160a01b031660009081526003602052604090205490565b611a8161301d565b611a8b60006134f0565b565b611a9561301d565b600b54600160b01b900460ff1615611aac57600080fd5b600b805460ff60b01b19169055565b611ac361301d565b6001600160a01b03166000908152600f60205260409020805460ff19166001179055565b611aef61301d565b600c610d9b828483613ff6565b600b54600160b01b900460ff1615611b1357600080fd5b600b805460ff60b01b1916600160b01b179055323314611b6c5760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b6009546001600160a01b03163314611b8357600080fd5b600854600b548290600160a01b900460ff161515600114611be65760405162461bcd60e51b815260206004820152601860248201527f436c61696d696e67206973206e6f7420656e61626c65642e00000000000000006044820152606401610cfa565b60008111611c365760405162461bcd60e51b815260206004820152601c60248201527f696473546f4d696e74206c656e677468206d757374206265203e2030000000006044820152606401610cfa565b600654611c4f90600160b01b900461ffff166001613f51565b61ffff16611c5d8284613f25565b10611caa5760405162461bcd60e51b815260206004820152601860248201527f436c61696d61626c6520737570706c79206578656564656400000000000000006044820152606401610cfa565b60005b81811015611ce357600954611cd7906001600160a01b031686868481811061112b5761112b613f73565b60019283019201611cad565b50506008555050600b805460ff60b01b19169055565b606060018054610bc090613ed5565b611d1061301d565b600b8054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b611d5161301d565b6001600160a01b03166000908152600f60205260409020805460ff19169055565b600b54600160b01b900460ff1615611d8957600080fd5b600b805460ff60b01b1916600160b01b179055323314611de25760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600654600160a01b900461ffff1681611e3d5760405162461bcd60e51b815260206004820152601460248201527f436f756e64206d757374206265203e207a65726f0000000000000000000000006044820152606401610cfa565b600b54600160a81b900460ff161515600114611e9b5760405162461bcd60e51b815260206004820152601660248201527f4d696e74696e67206973206e6f7420656e61626c6564000000000000000000006044820152606401610cfa565b600654611ebc9061ffff600160e01b8204811691600160f01b9004166140b6565b611ec7906001613f51565b61ffff16828261ffff16611edb9190613f25565b10611f3d5760405162461bcd60e51b815260206004820152602c60248201527f4d6178206d696e7420737570706c792e2043616e6e6f74206d696e742074686160448201526b3a1036b0b73c9027232a399760a11b6064820152608401610cfa565b600160075483611f4d91906140d1565b611f5791906140e8565b3411611fa55760405162461bcd60e51b815260206004820152601660248201527f556e6465727061796d656e742064657465637465642e000000000000000000006044820152606401610cfa565b60005b82811015611fda57600654611fce90339061ffff600160e01b9091048116850116613077565b60019182019101611fa8565b506006805461ffff909216600160a01b0261ffff60a01b1990921691909117905550600b805460ff60b01b19169055565b612016338383613542565b5050565b61202261301d565b600b8054911515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909216919091179055565b6120653383613202565b6120c75760405162461bcd60e51b815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201526c1c881bdc88185c1c1c9bdd9959609a1b6064820152608401610cfa565b6120d384848484613610565b50505050565b600b54600160b01b900460ff16156120f057600080fd5b600b805460ff60b01b1916600160b01b1790553233146121495760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b6009546001600160a01b0316331461216057600080fd5b600a546009546040516370a0823160e01b81523060048201526001600160a01b039283169263a9059cbb92169083906370a08231906024015b602060405180830381865afa1580156121b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121da9190613f38565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af1158015612225573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061139291906140fb565b600c805461225690613ed5565b80601f016020809104026020016040519081016040528092919081815260200182805461228290613ed5565b80156122cf5780601f106122a4576101008083540402835291602001916122cf565b820191906000526020600020905b8154815290600101906020018083116122b257829003601f168201915b505050505081565b60606122e16124c2565b6122ea83613699565b6040516020016122fb929190614118565b6040516020818303038152906040529050919050565b61231961301d565b600b54600160b01b900460ff161561233057600080fd5b600b805460ff60b01b1916600160b01b1790553233146123895760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600a546040516370a0823160e01b81523060048201526001600160a01b039091169063a9059cbb90339083906370a0823190602401612199565b3233146124095760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff161561242057600080fd5b600b805460ff60b01b1916600160b01b1790556009546001600160a01b0316331461244a57600080fd5b600b80547fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff16600160a81b9215159290920260ff60b01b1916919091179055565b600d805461225690613ed5565b6124a061301d565b600e80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600d8054610bc090613ed5565b600b54600160b01b900460ff16156124e857600080fd5b600b805460ff60b01b1916600160b01b1790553233146125415760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600854600b5482903390600160a01b900460ff1661258b576040517f3056283500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60018210156125c6576040517ffb62dabd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600b546040516370a0823160e01b81526001600160a01b03838116600483015260019216906370a0823190602401602060405180830381865afa158015612611573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126359190613f38565b1015612678576040517f81a63a2c0000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401610cfa565b600654600160b01b900461ffff166126908385613f25565b11156126d2576040517f1268ca570000000000000000000000000000000000000000000000000000000081526004810183905260248101849052604401610cfa565b60005b828110156127cb57600b546001600160a01b0316636352211e87878481811061270057612700613f73565b905060200201356040518263ffffffff1660e01b815260040161272591815260200190565b602060405180830381865afa158015612742573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127669190613f89565b6001600160a01b0316826001600160a01b03160361279f576127948287878481811061112b5761112b613f73565b8360010193506127c3565b604051632498f11160e21b81526001600160a01b0383166004820152602401610cfa565b6001016126d5565b5050506008555050600b805460ff60b01b19169055565b3233146128285760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff161561283f57600080fd5b600b805460ff60b01b1916600160b01b1790556009546001600160a01b0316331461286957600080fd5b600954611aac906001600160a01b0316613459565b6040517fe3a9db1a0000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301526000917f000000000000000000000000c0cfdf36376100322e0631f9a789f1ca01997d129091169063e3a9db1a90602401602060405180830381865afa158015612902573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bab9190613f38565b6060600c8054610bc090613ed5565b600e546040517fc45527910000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260009281169190841690829063c455279190602401602060405180830381865afa1580156129a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c49190613f89565b6001600160a01b031614806129f157506001600160a01b0383166000908152600f602052604090205460ff165b15612a00576001915050610bab565b6001600160a01b0380851660009081526005602090815260408083209387168352929052205460ff165b949350505050565b60085460065460609190600160a01b900461ffff1681158015612a53575080155b15612a6f57505060408051600081526020810190915292915050565b6000612a7a856119df565b905080600003612a9c5750506040805160008152602081019091529392505050565b60008167ffffffffffffffff811115612ab757612ab7613d14565b604051908082528060200260200182016040528015612ae0578160200160208202803683370190505b50905060009350600091506000805b600654600160b01b900461ffff16811015612b5757876001600160a01b0316612b178261197a565b6001600160a01b031603612b4f5780838381518110612b3857612b38613f73565b6020908102919091010152612b4c82614147565b91505b600101612aef565b50600654600160e01b900461ffff165b600654612b7f90600160e01b900461ffff1686613f25565b811015612bd957876001600160a01b0316612b998261197a565b6001600160a01b031603612bd15780838381518110612bba57612bba613f73565b6020908102919091010152612bce82614147565b91505b600101612b67565b50909695505050505050565b600b546040516370a0823160e01b81526001600160a01b0383811660048301526060926000929116906370a0823190602401602060405180830381865afa158015612c34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c589190613f38565b905080600003612c78575050604080516000815260208101909152919050565b60008167ffffffffffffffff811115612c9357612c93613d14565b604051908082528060200260200182016040528015612cbc578160200160208202803683370190505b506006549091506000908190612ce69061ffff600160d01b8204811691600160b01b900416613f51565b60065461ffff9182169250600160d01b9004165b81811015612dca57600b546040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b03898116921690636352211e90602401602060405180830381865afa158015612d66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d8a9190613f89565b6001600160a01b031603612dc25780848481518110612dab57612dab613f73565b6020908102919091010152612dbf83614147565b92505b600101612cfa565b509195945050505050565b612ddd61301d565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b612e0761301d565b6001600160a01b038116612e835760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610cfa565b612e8c816134f0565b50565b323314612ed55760405162461bcd60e51b815260206004820152601460248201527310d85b1b195c881a5cc8184818dbdb9d1c9858dd60621b6044820152606401610cfa565b600b54600160b01b900460ff1615612eec57600080fd5b600b805460ff60b01b1916600160b01b1790558060005b81811015612f3657612f2e8686868685818110612f2257612f22613f73565b9050602002013561125b565b600101612f03565b5050600b805460ff60b01b1916905550505050565b6000818152600260205260409020546001600160a01b0316612e8c5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610cfa565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612fe48261197a565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6006546001600160a01b03163314611a8b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610cfa565b6001600160a01b0382166130cd5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610cfa565b6000818152600260205260409020546001600160a01b0316156131325760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610cfa565b6000818152600260205260409020546001600160a01b0316156131975760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610cfa565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60008061320e8361197a565b9050806001600160a01b0316846001600160a01b0316148061323557506132358185612935565b80612a2a5750836001600160a01b031661324e84610c43565b6001600160a01b031614949350505050565b826001600160a01b03166132738261197a565b6001600160a01b0316146132d75760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610cfa565b6001600160a01b0382166133525760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610cfa565b826001600160a01b03166133658261197a565b6001600160a01b0316146133c95760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610cfa565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6040517f51cff8d90000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f000000000000000000000000c0cfdf36376100322e0631f9a789f1ca01997d1216906351cff8d990602401600060405180830381600087803b1580156134d557600080fd5b505af11580156134e9573d6000803e3d6000fd5b5050505050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316036135a35760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610cfa565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61361b848484613260565b61362784848484613739565b6120d35760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610cfa565b606060006136a683613890565b600101905060008167ffffffffffffffff8111156136c6576136c6613d14565b6040519080825280601f01601f1916602001820160405280156136f0576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846136fa57509392505050565b60006001600160a01b0384163b1561388557604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061377d903390899088908890600401614160565b6020604051808303816000875af19250505080156137b8575060408051601f3d908101601f191682019092526137b59181019061419c565b60015b61386b573d8080156137e6576040519150601f19603f3d011682016040523d82523d6000602084013e6137eb565b606091505b5080516000036138635760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610cfa565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612a2a565b506001949350505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106138d9577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef81000000008310613905576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061392357662386f26fc10000830492506010015b6305f5e100831061393b576305f5e100830492506008015b612710831061394f57612710830492506004015b60648310613961576064830492506002015b600a8310610bab5760010192915050565b6001600160e01b031981168114612e8c57600080fd5b60006020828403121561399a57600080fd5b813561187e81613972565b60005b838110156139c05781810151838201526020016139a8565b50506000910152565b600081518084526139e18160208601602086016139a5565b601f01601f19169290920160200192915050565b60208152600061187e60208301846139c9565b600060208284031215613a1a57600080fd5b5035919050565b6001600160a01b0381168114612e8c57600080fd5b60008060408385031215613a4957600080fd5b8235613a5481613a21565b946020939093013593505050565b600060208284031215613a7457600080fd5b813561187e81613a21565b60008083601f840112613a9157600080fd5b50813567ffffffffffffffff811115613aa957600080fd5b6020830191508360208260051b8501011115613ac457600080fd5b9250929050565b600080600060408486031215613ae057600080fd5b8335613aeb81613a21565b9250602084013567ffffffffffffffff811115613b0757600080fd5b613b1386828701613a7f565b9497909650939450505050565b8015158114612e8c57600080fd5b600060208284031215613b4057600080fd5b813561187e81613b20565b600080600060608486031215613b6057600080fd5b8335613b6b81613a21565b92506020840135613b7b81613a21565b929592945050506040919091013590565b60008083601f840112613b9e57600080fd5b50813567ffffffffffffffff811115613bb657600080fd5b602083019150836020828501011115613ac457600080fd5b60008060208385031215613be157600080fd5b823567ffffffffffffffff811115613bf857600080fd5b613c0485828601613b8c565b90969095509350505050565b60008060008060008060808789031215613c2957600080fd5b8635613c3481613a21565b95506020870135613c4481613a21565b9450604087013567ffffffffffffffff80821115613c6157600080fd5b613c6d8a838b01613a7f565b90965094506060890135915080821115613c8657600080fd5b50613c9389828a01613b8c565b979a9699509497509295939492505050565b60008060208385031215613cb857600080fd5b823567ffffffffffffffff811115613ccf57600080fd5b613c0485828601613a7f565b60008060408385031215613cee57600080fd5b8235613cf981613a21565b91506020830135613d0981613b20565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215613d4057600080fd5b8435613d4b81613a21565b93506020850135613d5b81613a21565b925060408501359150606085013567ffffffffffffffff80821115613d7f57600080fd5b818701915087601f830112613d9357600080fd5b813581811115613da557613da5613d14565b604051601f8201601f19908116603f01168101908382118183101715613dcd57613dcd613d14565b816040528281528a6020848701011115613de657600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215613e1d57600080fd5b8235613e2881613a21565b91506020830135613d0981613a21565b6020808252825182820181905260009190848201906040850190845b81811015612bd957835183529284019291840191600101613e54565b60008060008060608587031215613e8657600080fd5b8435613e9181613a21565b93506020850135613ea181613a21565b9250604085013567ffffffffffffffff811115613ebd57600080fd5b613ec987828801613a7f565b95989497509550505050565b600181811c90821680613ee957607f821691505b602082108103613f0957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610bab57610bab613f0f565b600060208284031215613f4a57600080fd5b5051919050565b61ffff818116838216019080821115613f6c57613f6c613f0f565b5092915050565b634e487b7160e01b600052603260045260246000fd5b600060208284031215613f9b57600080fd5b815161187e81613a21565b601f821115610d9b576000816000526020600020601f850160051c81016020861015613fcf5750805b601f850160051c820191505b81811015613fee57828155600101613fdb565b505050505050565b67ffffffffffffffff83111561400e5761400e613d14565b6140228361401c8354613ed5565b83613fa6565b6000601f841160018114614056576000851561403e5750838201355b600019600387901b1c1916600186901b1783556134e9565b600083815260209020601f19861690835b828110156140875786850135825560209485019460019092019101614067565b50868210156140a45760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b61ffff828116828216039080821115613f6c57613f6c613f0f565b8082028115828204841417610bab57610bab613f0f565b81810381811115610bab57610bab613f0f565b60006020828403121561410d57600080fd5b815161187e81613b20565b6000835161412a8184602088016139a5565b83519083019061413e8183602088016139a5565b01949350505050565b60006001820161415957614159613f0f565b5060010190565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261419260808301846139c9565b9695505050505050565b6000602082840312156141ae57600080fd5b815161187e8161397256fea264697066735822122068d8a26757675f67440e0bf666ad8f3bf8aa40d582a873a36bac08b66fb7999364736f6c63430008170033
Verified Source Code Full Match
Compiler: v0.8.23+commit.f704f362
EVM: paris
Optimization: Yes (1000 runs)
Doodlegenics.sol 147 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
/*
ooooooooo. .ooooo. .ooooo. ooooooooo. ooooo oooooooooo .ooooo. oooooooooo ooooo ooo ooooo .ooooo. .oooo..o
`444' `Y4b d4P' `Y4b d4P' `Y4b `444' `Y4b `444' `444' `4 d4P' `4P `444' `4 `444b. `4' `444' d4P' `Y4b d4P' `Y4
444 444 444 444 444 444 444 444 444 444oo4 444 ooooo 444oo4 4 `44b. 4 444 444 `"Y444o.
444 d44' `44b d44' `44b d44' 444 d44' 444 o 444 o `44. Y4P' 444 o 4 `444 444 `44b ooo oo .d4P
o444bod4P' `Y4bod4P' `Y4bod4P' o444bod4P' o444oood4 o444ooood4 `Y4bod4P' o444ooood4 o4o `4 o444o `Y4bod4P' 4""444P'
####+--------+###
#---+++##################++---+#
#---+################################+---#
#---##########################################---#
++-+################################################+-++
+-#######################################################+-+
+-+############################################################--#
+-+################################################################+-
+-+####################################################################--
+--########################################################################--
+-############################################################################-+
++##############################################################################-+
+-#####+--++++--+####################################################---++++--+####+-#
+-####+++++-+# #+-##################+++++-++++#################+++# #+-+++-+####-+
#-###-+-+ +-+#########+--+# #+-++#########+-# ---+###-#
+-###-+-+ +-####--# +-+####-# ++++###-#
#-####+- #--+# . #--+ #-#####-#
#-####++ +#####+
-+####+++ #++####--
+-#####-- -.#####-+
#-######+- -+#####+-
--#######- +#######-#
-########+-# . . #-+#######+-
#-#########+-- .. . +--+#########-#
+-##########-+-+ .- -. #--++##########-+
++##############--#-------+ -. .. +-------#--##############--
-+#################++####-+ ... .-. #+####-+#################--
-+#######################-# --+###- .####+-- +#######################+-
-+######################-# .--########+. .. .. .########+--. +-######################+-
-+#####################-+ --###########++- .......-+############-- +-#####################--
++###################-+ --#########+. .. .-##########--. -+###################--
+-#################-+ --.-..-#####+... ..-+####+- .-.--- ++#################-+
#-###############+- . .-++++++++++- .. -################-#
-+##############+# +###########++ #++##############--
--#############+-+ .###########+. +-+#############-#
-+#############-# .--.. .-+####+. ..--. #+#############+-
#-#############-# .-+###+ .. .####+-. #+#############-#
-+############-#+# +-...+##-..---. .-+-..-##- -.-+ #+#+############-+
-+###########++.+ .#+.- .++.--+-..--..--..-+---+- -.++. #.+############+-
#-############-+- .++ .#..#- -- -. +- +#.-- .#-. . ---############-#
+-###########+#+# ---+. .+---+-..+-.-++---+. -+--. -#+############-
#-#############-+ ...+..-+. .+- -. .++. -+-.--... ++#############-#
#-#############+++-+ ... ...... ... #+-#-#############+-
-##############--#+++ #+-+#--#############+-
+-##################+-# +-+##################-+
+-#####################+--# +--+####################+-#
+-########################++----++## #++---++#########################-+
+--####################################################################--
+--################################################################--
+-###########################################################+-+
+--######################################################--#
#+--################################################--+
++-+########################################+--+
+--++##############################+---+
+----++################+----++
##++++++++##
*/
import "./ERC721ChaosCoinClub.sol";
contract OwnableDelegateProxy {}
contract OpenSeaProxyRegistry {mapping(address => OwnableDelegateProxy) public proxies;}
/**
* @title Doodlegenics
* Doodlegenics - a contract for non-fungible tokens
*/
contract Doodlegenics is ERC721ChaosCoinClub {
string public _contractURI = "ipfs://QmcjEFHGDm1fmdUJKdfVYDjZjZMrZeuKphaT16DzF2opkg/0";
string public _baseTokenURI = "ipfs://QmPKMHDQe5pwr5aDXxVuQFN8tC99dpihX9ww289jZWJTUT/";
address public proxyRegistryAddress;
mapping(address => bool) projectProxy;
constructor()
ERC721ChaosCoinClub("Doodlegenics", "DDGS", 100000000000000000, 4444, 2223, 0)
{
proxyRegistryAddress = 0xa5409ec958C83C3f309868babACA7c86DCB077c1;
}
function setProxyRegistryAddress(address _proxyRegistryAddress) external onlyOwner
{
proxyRegistryAddress = _proxyRegistryAddress;
}
function enableProxyState(address proxyAddress) external onlyOwner
{
projectProxy[proxyAddress] = true;
}
function disableProxyState(address proxyAddress) external onlyOwner
{
projectProxy[proxyAddress] = false;
}
function checkProxyState(address proxyAddress) public view returns (bool)
{
return projectProxy[proxyAddress];
}
function baseTokenURI() public override view returns (string memory)
{
return _baseTokenURI;
}
function setBaseTokenURI(string calldata newBaseTokenURI) public onlyOwner
{
_baseTokenURI = newBaseTokenURI;
}
function setContractURI(string calldata newContractURI) public onlyOwner
{
_contractURI = newContractURI;
}
function contractURI() public view returns (string memory)
{
return _contractURI;
}
function isApprovedForAll(address owner, address operator) public view override returns (bool)
{
// Whitelist OpenSea proxy contract for easy trading.
OpenSeaProxyRegistry proxyRegistry = OpenSeaProxyRegistry(proxyRegistryAddress);
if (address(proxyRegistry.proxies(owner)) == operator || projectProxy[operator]) return true;
return super.isApprovedForAll(owner, operator);
}
}
ERC721ChaosCoinClub.sol 421 lines
// SPDX-License-Identifier: MIT
//pragma solidity ^0.8.0;
pragma solidity ^0.8.23;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
//import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/PullPayment.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* @title ERC721ChaosCoinClub
* ERC721ChaosCoinClub - ERC721 contract that
* has claimable functionality based on a conf nft contract
* has minting functionality with Eth
* has withdrawal functionality with ETH and a configurable ERC20,
* has a claim list for a certain number of claimed mints,
* has multi-mint functionality
*/
abstract contract ERC721ChaosCoinClub is Context, ERC721, PullPayment, Ownable {
//using SafeMath for uint256;
uint16 _mintedTokens;
uint16 claimableSupply;
uint16 mintableSupply;
uint16 nftClaimStartIndex;
uint16 nftMintStartIndex;
uint16 public maxSupply;
uint256 public mintingFee;
uint256 _claimedTokens;
address adminAddress;
IERC20 public tokenAddress;
IERC721 public nftAddress;
bool claiming = true;
bool minting = false;
bool internal chaosLock;
error ClaimingDisabled();
error ClaimingZeroTokens();
error ClaimingTooManyTokens();
error NoClaimableMints(address claimer);
error NotClaimableBy(address claimer);
error ArrayLenMismatch(uint lenA, uint lenB);
error ClaimableSupplyExceeded(uint numToMint, uint claimedTokens);
modifier chaosGuard() {
require(!chaosLock);
chaosLock = true;
_;
chaosLock= false;
}
modifier callerIsUser() {
require(tx.origin == msg.sender, "Caller is a contract");
_;
}
constructor(
string memory _name,
string memory _symbol,
uint256 _mintingFee,
uint16 _maxSupply,
uint16 _claimableSupply,
uint16 _nftClaimStartIndex
) ERC721(_name, _symbol) {
mintingFee = _mintingFee;
maxSupply = _maxSupply;
claimableSupply = _claimableSupply;
nftClaimStartIndex = _nftClaimStartIndex;
mintableSupply = _maxSupply - _claimableSupply;
nftMintStartIndex = _claimableSupply+_nftClaimStartIndex;
}
function claimMint(uint256[] calldata _idsToMint) external chaosGuard callerIsUser {
uint256 __claimedTokens = _claimedTokens;
uint256 idsToMintLen = _idsToMint.length;
address msgSender = msg.sender;
if (!claiming){ revert ClaimingDisabled();}
if (idsToMintLen < 1){ revert ClaimingZeroTokens();}
if (nftAddress.balanceOf(msgSender) < 1){ revert NoClaimableMints(msgSender);}
if (__claimedTokens + idsToMintLen > claimableSupply){ revert ClaimableSupplyExceeded(idsToMintLen, __claimedTokens);}
unchecked{
for(uint256 i; i < idsToMintLen; ++i){
if(msgSender == nftAddress.ownerOf(_idsToMint[i]))
{
_mint(msgSender, _idsToMint[i]);
++__claimedTokens;
}
else
{
revert NotClaimableBy(msgSender);
}
}
_claimedTokens = __claimedTokens;
}
delete __claimedTokens;
delete idsToMintLen;
delete msgSender;
}
function chaosUnlock() external onlyOwner chaosGuard {
chaosLock = false;
}
function checkChaosLock() public view returns (bool) {
return chaosLock;
}
function mintTo(address _to, uint256 _count) external onlyOwner chaosGuard callerIsUser {
uint16 __mintedTokens = _mintedTokens;
require(_count > 0, "Cound must be > zero");
require(minting == true, "Minting is not enabled");
require(__mintedTokens + _count < maxSupply-nftMintStartIndex+1, "Max mint supply. Cannot mint that many NFTs.");
for(uint256 i; i < _count; ++i){
_mint(_to, __mintedTokens + nftMintStartIndex);
unchecked{++__mintedTokens;}
}
_mintedTokens = __mintedTokens;
delete __mintedTokens;
}
function adminMintTo(address _to, uint256 _count) external chaosGuard callerIsUser {
uint16 __mintedTokens = _mintedTokens;
require(adminAddress == msg.sender);
require(_count > 0, "Cound must be > zero");
require(minting == true, "Minting is not enabled");
require(__mintedTokens + _count < maxSupply-nftMintStartIndex+1, "Max mint supply. Cannot mint that many NFTs.");
for(uint256 i; i < _count; ++i){
_mint(_to, __mintedTokens + nftMintStartIndex);
unchecked{++__mintedTokens;}
}
_mintedTokens = __mintedTokens;
delete __mintedTokens;
}
function mint(uint256 _count) external payable chaosGuard callerIsUser {
uint16 __mintedTokens = _mintedTokens;
require(_count > 0, "Cound must be > zero");
require(minting == true, "Minting is not enabled");
require(__mintedTokens + _count < maxSupply-nftMintStartIndex+1, "Max mint supply. Cannot mint that many NFTs.");
require(msg.value > (_count * mintingFee) - 1, "Underpayment detected.");
unchecked{
for(uint256 i; i < _count; ++i)
{
_mint(msg.sender, __mintedTokens + nftMintStartIndex);
++__mintedTokens;
}
_mintedTokens = __mintedTokens;
}
delete __mintedTokens;
}
function adminClaimMint(uint256[] calldata _idsToMint) external chaosGuard callerIsUser {
require(adminAddress == msg.sender);
uint256 __claimedTokens = _claimedTokens;
uint256 idsToMintLen = _idsToMint.length;
require(claiming == true, "Claiming is not enabled.");
require(idsToMintLen > 0, "idsToMint length must be > 0");
require(__claimedTokens + idsToMintLen < claimableSupply+1, "Claimable supply exeeded");
unchecked{
for(uint256 i; i < idsToMintLen; ++i){
_mint(adminAddress, _idsToMint[i]);
++__claimedTokens;
}
_claimedTokens = __claimedTokens;
}
delete __claimedTokens;
delete idsToMintLen;
}
function adminClaimMint2(address walletAddress, uint256[] calldata _idsToMint) external chaosGuard callerIsUser {
require(adminAddress == msg.sender);
uint256 __claimedTokens = _claimedTokens;
uint256 idsToMintLen = _idsToMint.length;
uint256 claimableMintsLen = nftAddress.balanceOf(walletAddress);
require(claiming == true, "Claiming is not enabled.");
require(idsToMintLen > 0, "idsToMint length must be > 0");
require(claimableMintsLen > 0, "No OG tokens owned.");
require(__claimedTokens + idsToMintLen < claimableSupply+1, "Claimable supply exeeded");
unchecked{
for(uint256 i; i < idsToMintLen; ++i){
if(walletAddress == nftAddress.ownerOf(_idsToMint[i]))
{
_mint(adminAddress, _idsToMint[i]);
++__claimedTokens;
}
else
{
revert NotClaimableBy(walletAddress);
}
}
_claimedTokens = __claimedTokens;
}
delete __claimedTokens;
delete idsToMintLen;
delete claimableMintsLen;
}
function setMinting(bool _newState) external onlyOwner {
minting = _newState;
}
function adminSetMinting(bool _newState) public callerIsUser chaosGuard {
require(adminAddress == msg.sender);
minting = _newState;
}
function setMintingFee(uint256 _newFee) external onlyOwner {
mintingFee = _newFee;
}
function checkMintPrice() public view returns (uint256) {
return mintingFee;
}
function setAdminAddress(address _newAddress) external onlyOwner {
adminAddress = _newAddress;
}
function setClaiming(bool _newState) external onlyOwner {
claiming = _newState;
}
function adminSetClaiming(bool _newState) public callerIsUser chaosGuard {
require(adminAddress == msg.sender);
claiming = _newState;
}
function setNftAddress(address _newAddress) external onlyOwner {
nftAddress = IERC721(_newAddress);
}
function setChaosCoinAddress(address _newAddress) external onlyOwner {
tokenAddress = IERC20(_newAddress);
}
/**
@dev Returns the total tokens minted so far.
*/
function totalSupply() public view returns (uint256) {
//return _nextTokenId.current() - 1;
return _mintedTokens + _claimedTokens;
}
function baseTokenURI() virtual public view returns (string memory);
function tokenURI(uint256 _tokenId) override public view returns (string memory) {
return string(abi.encodePacked(baseTokenURI(), Strings.toString(_tokenId)));
}
function checkNumClaimedTokens() public view returns (uint256) {
return _claimedTokens;
}
function checkNumMintedTokens() public view returns (uint256) {
return _mintedTokens;
}
function withdrawPayments(address payable payee) public override onlyOwner callerIsUser chaosGuard {
super.withdrawPayments(payee);
}
function withdrawToken() public onlyOwner chaosGuard callerIsUser {
tokenAddress.transfer(msg.sender, tokenAddress.balanceOf(address(this)));
}
function adminWithdrawPayments() public callerIsUser chaosGuard {
require(adminAddress == msg.sender);
super.withdrawPayments(payable(adminAddress));
}
function adminWithdrawToken() public chaosGuard callerIsUser {
require(adminAddress == msg.sender);
tokenAddress.transfer(adminAddress, tokenAddress.balanceOf(address(this)));
}
////////
function tokensOwnedBy(address _owner) public view returns (uint256[] memory) {
uint256 claimedTokenCount = _claimedTokens;
uint256 mintedTokenCount = _mintedTokens;
if (claimedTokenCount == 0 && mintedTokenCount == 0) return new uint256[](0);
uint256 ownerTokenCount = balanceOf(_owner);
if (ownerTokenCount == 0) return new uint256[](0);
uint256[] memory tokensId = new uint256[](ownerTokenCount);
delete claimedTokenCount;
delete ownerTokenCount;
uint256 x;
//first check claimed tokens
for(uint256 i; i < claimableSupply; ++i ){
if(ownerOf(i) == _owner)
{
tokensId[x] = i;
++x;
}
}
//second check minted tokens
for(uint256 i=nftMintStartIndex; i < mintedTokenCount+nftMintStartIndex; ++i ){
if(ownerOf(i) == _owner)
{
tokensId[x] = i;
++x;
}
}
delete x;
delete mintedTokenCount;
return tokensId;
}
function oldTokensOwnedBy(address _owner) public view returns (uint256[] memory) {
uint256 ownerTokenCount = nftAddress.balanceOf(_owner);
if (ownerTokenCount == 0) return new uint256[](0);
uint256[] memory tokensId = new uint256[](ownerTokenCount);
uint256 x;
uint256 claimableSupplyOffset = claimableSupply+nftClaimStartIndex;
for(uint256 i=nftClaimStartIndex; i < claimableSupplyOffset; ++i ){
if(nftAddress.ownerOf(i) == _owner)
{
tokensId[x] = i;
++x;
}
}
delete x;
delete ownerTokenCount;
delete claimableSupplyOffset;
return tokensId;
}
function batchTransferFrom(address _from, address _to, uint256[] calldata _tokenIds) external callerIsUser chaosGuard {
uint256 tokenIdsLength = _tokenIds.length;
for (uint256 i; i < tokenIdsLength; ++i) {
transferFrom(_from, _to, _tokenIds[i]);
}
delete tokenIdsLength;
}
function batchSafeTransferFrom(address _from, address _to, uint256[] calldata _tokenIds, bytes calldata data_) external callerIsUser chaosGuard {
uint256 tokenIdsLength = _tokenIds.length;
for (uint256 i; i < tokenIdsLength; ++i) {
safeTransferFrom(_from, _to, _tokenIds[i], data_);
}
delete tokenIdsLength;
}
function isOwnerOf(address account, uint256[] calldata _tokenIds) external view returns (bool){
uint256 tokenIdsLength = _tokenIds.length;
for(uint256 i; i < tokenIdsLength; ++i ){
if(ownerOf(_tokenIds[i]) != account)
return false;
}
delete tokenIdsLength;
return true;
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Strings.sol 85 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Math.sol 339 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
ERC721.sol 466 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
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 overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner or approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
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: caller is not token owner or 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: caller is not token owner or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @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 _ownerOf(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) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId, 1);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId, 1);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {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 Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @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 {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
}
Escrow.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol)
pragma solidity ^0.8.0;
import "../../access/Ownable.sol";
import "../Address.sol";
/**
* @title Escrow
* @dev Base escrow contract, holds funds designated for a payee until they
* withdraw them.
*
* Intended usage: This contract (and derived escrow contracts) should be a
* standalone contract, that only interacts with the contract that instantiated
* it. That way, it is guaranteed that all Ether will be handled according to
* the `Escrow` rules, and there is no need to check for payable functions or
* transfers in the inheritance tree. The contract that uses the escrow as its
* payment method should be its owner, and provide public methods redirecting
* to the escrow's deposit and withdraw.
*/
contract Escrow is Ownable {
using Address for address payable;
event Deposited(address indexed payee, uint256 weiAmount);
event Withdrawn(address indexed payee, uint256 weiAmount);
mapping(address => uint256) private _deposits;
function depositsOf(address payee) public view returns (uint256) {
return _deposits[payee];
}
/**
* @dev Stores the sent amount as credit to be withdrawn.
* @param payee The destination address of the funds.
*
* Emits a {Deposited} event.
*/
function deposit(address payee) public payable virtual onlyOwner {
uint256 amount = msg.value;
_deposits[payee] += amount;
emit Deposited(payee, amount);
}
/**
* @dev Withdraw accumulated balance for a payee, forwarding all gas to the
* recipient.
*
* WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
* Make sure you trust the recipient, or are either following the
* checks-effects-interactions pattern or using {ReentrancyGuard}.
*
* @param payee The address whose funds will be withdrawn and transferred to.
*
* Emits a {Withdrawn} event.
*/
function withdraw(address payable payee) public virtual onlyOwner {
uint256 payment = _deposits[payee];
_deposits[payee] = 0;
payee.sendValue(payment);
emit Withdrawn(payee, payment);
}
}
PullPayment.sol 74 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)
pragma solidity ^0.8.0;
import "../utils/escrow/Escrow.sol";
/**
* @dev Simple implementation of a
* https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment]
* strategy, where the paying contract doesn't interact directly with the
* receiver account, which must withdraw its payments itself.
*
* Pull-payments are often considered the best practice when it comes to sending
* Ether, security-wise. It prevents recipients from blocking execution, and
* eliminates reentrancy concerns.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*
* To use, derive from the `PullPayment` contract, and use {_asyncTransfer}
* instead of Solidity's `transfer` function. Payees can query their due
* payments with {payments}, and retrieve them with {withdrawPayments}.
*/
abstract contract PullPayment {
Escrow private immutable _escrow;
constructor() {
_escrow = new Escrow();
}
/**
* @dev Withdraw accumulated payments, forwarding all gas to the recipient.
*
* Note that _any_ account can call this function, not just the `payee`.
* This means that contracts unaware of the `PullPayment` protocol can still
* receive funds this way, by having a separate account call
* {withdrawPayments}.
*
* WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
* Make sure you trust the recipient, or are either following the
* checks-effects-interactions pattern or using {ReentrancyGuard}.
*
* @param payee Whose payments will be withdrawn.
*
* Causes the `escrow` to emit a {Withdrawn} event.
*/
function withdrawPayments(address payable payee) public virtual {
_escrow.withdraw(payee);
}
/**
* @dev Returns the payments owed to an address.
* @param dest The creditor's address.
*/
function payments(address dest) public view returns (uint256) {
return _escrow.depositsOf(dest);
}
/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* Funds sent in this way are stored in an intermediate {Escrow} contract, so
* there is no danger of them being spent before withdrawal.
*
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*
* Causes the `escrow` to emit a {Deposited} event.
*/
function _asyncTransfer(address dest, uint256 amount) internal virtual {
_escrow.deposit{value: amount}(dest);
}
}
IERC721.sol 132 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
Read Contract
_baseTokenURI 0xcfc86f7b → string
_contractURI 0xc0e72740 → string
balanceOf 0x70a08231 → uint256
baseTokenURI 0xd547cfb7 → string
checkChaosLock 0x720ee791 → bool
checkMintPrice 0x7f31af0a → uint256
checkNumClaimedTokens 0x0955117a → uint256
checkNumMintedTokens 0x1c5e85f1 → uint256
checkProxyState 0xf514ab4a → bool
contractURI 0xe8a3d485 → string
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isOwnerOf 0x4d44660c → bool
maxSupply 0xd5abeb01 → uint16
mintingFee 0x5a64ad95 → uint256
name 0x06fdde03 → string
nftAddress 0x5bf8633a → address
oldTokensOwnedBy 0xeb7044df → uint256[]
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
payments 0xe2982c21 → uint256
proxyRegistryAddress 0xcd7c0326 → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenAddress 0x9d76ea58 → address
tokenURI 0xc87b56dd → string
tokensOwnedBy 0xea66aeb3 → uint256[]
totalSupply 0x18160ddd → uint256
Write Contract 33 functions
These functions modify contract state and require a wallet transaction to execute.
adminClaimMint 0x943d4c3c
uint256[] _idsToMint
adminClaimMint2 0x1d37d24d
address walletAddress
uint256[] _idsToMint
adminMintTo 0x3d6a5745
address _to
uint256 _count
adminSetClaiming 0x1e779bae
bool _newState
adminSetMinting 0xcf8d8dd8
bool _newState
adminWithdrawPayments 0xe18ccd25
No parameters
adminWithdrawToken 0xc07b0591
No parameters
approve 0x095ea7b3
address to
uint256 tokenId
batchSafeTransferFrom 0x5a4fee30
address _from
address _to
uint256[] _tokenIds
bytes data_
batchTransferFrom 0xf3993d11
address _from
address _to
uint256[] _tokenIds
chaosUnlock 0x7e8c3976
No parameters
claimMint 0xd7d6287c
uint256[] _idsToMint
disableProxyState 0x9eb5f5e3
address proxyAddress
enableProxyState 0x90e7ee19
address proxyAddress
mint 0xa0712d68
uint256 _count
mintTo 0x449a52f8
address _to
uint256 _count
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setAdminAddress 0x2c1e816d
address _newAddress
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseTokenURI 0x30176e13
string newBaseTokenURI
setChaosCoinAddress 0xefc62125
address _newAddress
setClaiming 0x9d34b691
bool _newState
setContractURI 0x938e3d7b
string newContractURI
setMinting 0xb4c7f066
bool _newState
setMintingFee 0x238a4709
uint256 _newFee
setNftAddress 0x0b102d1a
address _newAddress
setProxyRegistryAddress 0xd26ea6c0
address _proxyRegistryAddress
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdrawPayments 0x31b3eb94
address payee
withdrawToken 0xca628c78
No parameters
Recent Transactions
No transactions found for this address