Address Contract Verified
Address
0xF6ee484f82f28d69688f37fe90Af514ce212b7c3
Balance
0 ETH
Nonce
1
Code Size
12597 bytes
Creator
0x21cE4EDD...CaB7 at tx 0xba4f4b4c...07f7d1
Indexed Transactions
0
Contract Bytecode
12597 bytes
0x608060405234801561001057600080fd5b50600436106103155760003560e01c806370a08231116101a7578063c2a0d4b3116100ee578063da1b91c311610097578063ef5d9ae811610071578063ef5d9ae814610639578063efef39a11461064c578063f2fde38b1461065f57600080fd5b8063da1b91c3146105e2578063e985e9c5146105ea578063eae498fe1461062657600080fd5b8063ca344d3b116100c8578063ca344d3b146105be578063cac92669146105c6578063d5abeb01146105d957600080fd5b8063c2a0d4b314610590578063c793803c146105a3578063c87b56dd146105ab57600080fd5b806395d89b4111610150578063b88d4fde1161012a578063b88d4fde14610563578063bc8893b414610576578063c218fd8a1461058857600080fd5b806395d89b4114610528578063a22cb46514610530578063abc8af181461054357600080fd5b80638c95d20c116101815780638c95d20c146104fb5780638da5cb5b1461050457806391b7f5ed1461051557600080fd5b806370a08231146104d7578063715018a6146104ea5780638ad1efa0146104f257600080fd5b80632a55205a1161026b5780634920b41e116102145780636465d23c116101ee5780636465d23c146104be5780636817c76c146104c65780636c0360eb146104cf57600080fd5b80634920b41e1461048f57806361b8ce8c146104a25780636352211e146104ab57600080fd5b80633ccfd60b116102455780633ccfd60b1461045a5780633fab755b1461046257806342842e0e1461047c57600080fd5b80632a55205a146104125780632eb4a7ab146104445780633ad7f56c1461044d57600080fd5b8063095ea7b3116102cd57806312487365116102a757806312487365146103d6578063140578f0146103f657806323b872dd146103ff57600080fd5b8063095ea7b3146103a45780630a302530146103b75780630c1c972a146103ce57600080fd5b8063054f7d9c116102fe578063054f7d9c1461035757806306fdde0314610364578063081812fc1461037957600080fd5b806301ffc9a71461031a57806302fe530514610342575b600080fd5b61032d610328366004612a01565b610672565b60405190151581526020015b60405180910390f35b610355610350366004612aaa565b6106b6565b005b600a5461032d9060ff1681565b61036c610764565b6040516103399190612b4b565b61038c610387366004612b5e565b6107f6565b6040516001600160a01b039091168152602001610339565b6103556103b2366004612b8e565b61081d565b6103c0600c5481565b604051908152602001610339565b61035561094e565b6103c06103e4366004612bb8565b600e6020526000908152604090205481565b6103c0600d5481565b61035561040d366004612bd3565b610a30565b610425610420366004612c0f565b610ab7565b604080516001600160a01b039093168352602083019190915201610339565b6103c0600b5481565b60135461032d9060ff1681565b610355610b94565b61046a600281565b60405160ff9091168152602001610339565b61035561048a366004612bd3565b610d25565b61035561049d366004612c3f565b610d40565b6103c060105481565b61038c6104b9366004612b5e565b610dca565b6103c060a381565b6103c060125481565b61036c610e2f565b6103c06104e5366004612bb8565b610ebd565b610355610f57565b6103c060145481565b6103c060115481565b6008546001600160a01b031661038c565b610355610523366004612b5e565b610f6b565b61036c610fa8565b61035561053e366004612c5c565b610fb7565b6103c0610551366004612bb8565b600f6020526000908152604090205481565b610355610571366004612c93565b610fc6565b60135461032d90610100900460ff1681565b61046a600381565b61035561059e366004612d20565b611054565b610355611126565b61036c6105b9366004612b5e565b6111bf565b61046a600181565b61032d6105d4366004612d3c565b611226565b6103c06107d081565b6103556112f7565b61032d6105f8366004612d6a565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610355610634366004612d9d565b611397565b6103c0610647366004612bb8565b6119ef565b61035561065a366004612b5e565b611a1d565b61035561066d366004612bb8565b611c92565b60006001600160e01b031982167f2baae9fd0000000000000000000000000000000000000000000000000000000014806106b057506106b082611d22565b92915050565b6106be611dbd565b600a5460ff16156107165760405162461bcd60e51b815260206004820152600760248201527f2166726f7a656e0000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b8051610729906009906020840190612952565b507fe9b617ecb5f63f6a9ccd8d4d5fa0d7b2ef9b17ce3f48e6b135808d6a40e67742816040516107599190612b4b565b60405180910390a150565b60606000805461077390612e34565b80601f016020809104026020016040519081016040528092919081815260200182805461079f90612e34565b80156107ec5780601f106107c1576101008083540402835291602001916107ec565b820191906000526020600020905b8154815290600101906020018083116107cf57829003601f168201915b5050505050905090565b600061080182611e17565b506000908152600460205260409020546001600160a01b031690565b600061082882610dca565b9050806001600160a01b0316836001600160a01b0316036108b15760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f7200000000000000000000000000000000000000000000000000000000000000606482015260840161070d565b336001600160a01b03821614806108cd57506108cd81336105f8565b61093f5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c0000606482015260840161070d565b6109498383611e7b565b505050565b610956611dbd565b601354610100900460ff16156109975760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b601380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000166101001790556011546010546109d660a36107d0612e84565b6109e09190612e9c565b6109ea9190612e9c565b6109f5906002612e84565b60148190556040519081527f9a0628c7c64732aee82a9dbbf70670416babc7306c40278e753cf26315fe9a18906020015b60405180910390a1565b610a3a3382611ef6565b610aac5760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206e6f7220617070726f766564000000000000000000000000000000000000606482015260840161070d565b610949838383611f75565b60008281526007602090815260408083208151808301909252546001600160a01b038116808352740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff16928201929092528291610b585750604080518082019091526006546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1660208201525b602081015160009061271090610b7c906bffffffffffffffffffffffff1687612eb3565b610b869190612ee8565b915196919550909350505050565b610b9c611dbd565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526000907f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316906370a0823190602401602060405180830381865afa158015610c1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c409190612efc565b90507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b031663a9059cbb610c836008546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015610cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf49190612f15565b506040518181527f4e70a604b23a8edee2b1d0a656e9b9c00b73ad8bb1afc2c59381ee9f69197de790602001610759565b61094983838360405180602001604052806000815250610fc6565b610d48611dbd565b601354610100900460ff1615610d895760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b6013805460ff19168215159081179091556040519081527ff118574ce3e4e67ef104c0589e4e5cf9a2c3cd2f0e43c05eeb39ae3dc0bc95f790602001610759565b6000818152600260205260408120546001600160a01b0316806106b05760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e2049440000000000000000604482015260640161070d565b60098054610e3c90612e34565b80601f0160208091040260200160405190810160405280929190818152602001828054610e6890612e34565b8015610eb55780601f10610e8a57610100808354040283529160200191610eb5565b820191906000526020600020905b815481529060010190602001808311610e9857829003601f168201915b505050505081565b60006001600160a01b038216610f3b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e65720000000000000000000000000000000000000000000000606482015260840161070d565b506001600160a01b031660009081526003602052604090205490565b610f5f611dbd565b610f69600061214f565b565b610f73611dbd565b60128190556040518181527f270b316b51ab2cf3a3bb8ca4d22e76a327d05e762fcaa8bd6afaf8cfde9270b790602001610759565b60606001805461077390612e34565b610fc23383836121ae565b5050565b610fd03383611ef6565b6110425760405162461bcd60e51b815260206004820152602e60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206e6f7220617070726f766564000000000000000000000000000000000000606482015260840161070d565b61104e8484848461227c565b50505050565b61105c611dbd565b60001960ff83160161107257600b8190556110e6565b60011960ff83160161108857600c8190556110e6565b60021960ff83160161109e57600d8190556110e6565b60405162461bcd60e51b815260206004820152600c60248201527f4e6f742076616c696420574c0000000000000000000000000000000000000000604482015260640161070d565b6040805160ff84168152602081018390527f98e93420c951077a731a1eee4a83eab9fa0d351bb38d67aefe6182eea5d72b9e910160405180910390a15050565b61112e611dbd565b600a5460ff16156111815760405162461bcd60e51b815260206004820152600760248201527f2166726f7a656e00000000000000000000000000000000000000000000000000604482015260640161070d565b600a805460ff191660011790556040517f80769e0fec5395870efbeb7790ddbe4c3669e465667108c34094cbcdd7c0ac5090610a2690600990612f32565b60606111ca82611e17565b6000600980546111d990612e34565b9050116111f557604051806020016040528060008152506106b0565b600961120083612305565b604051602001611211929190612fb7565b60405160208183030381529060405292915050565b6000611230611dbd565b6103e8826bffffffffffffffffffffffff1611156112925760405162461bcd60e51b815260040161070d9060208082526004908201527f2162707300000000000000000000000000000000000000000000000000000000604082015260600190565b6112ad6112a76008546001600160a01b031690565b8361243a565b6040516bffffffffffffffffffffffff831681527f3cf4fec9aae458c3a169ef0c25423c15fbfc6175238fa756786f345d9d9fdbc99060200160405180910390a15060015b919050565b6112ff611dbd565b601354610100900460ff1661133f5760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b601380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055600060148190556040517f185010463fd349b428a7c1ac5caaec4859fc9e4b00617bf0316c017390bab80d9190a1565b60135460ff166113d25760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b601354610100900460ff16156114135760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b60008411806114225750600083115b6114575760405162461bcd60e51b815260040161070d906020808252600490820152632171747960e01b604082015260600190565b60006114638486612e84565b6012546114709190612eb3565b6040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290529091507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb486001600160a01b0316906323b872dd906064016020604051808303816000875af11580156114ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115239190612f15565b61156f5760405162461bcd60e51b815260206004820152600660248201527f2176616c75650000000000000000000000000000000000000000000000000000604482015260640161070d565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152600090603401604051602081830303815290604052805190602001209050600160ff168760ff16036116f65761160a84848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600b549150849050612565565b61163f5760405162461bcd60e51b815260206004820152600660248201526510b83937b7b360d11b604482015260640161070d565b600086116116785760405162461bcd60e51b815260040161070d906020808252600490820152632171747960e01b604082015260600190565b336000908152600e602052604081208054889290611697908490612e84565b9091555050336000908152600e6020526040902054600210156116e55760405162461bcd60e51b815260040161070d90602080825260049082015263042dac2f60e31b604082015260600190565b6116f13387600061257b565b6119e6565b60011960ff88160161181e5761174384848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600c549150849050612565565b6117785760405162461bcd60e51b815260206004820152600660248201526510b83937b7b360d11b604482015260640161070d565b600086116117b15760405162461bcd60e51b815260040161070d906020808252600490820152632171747960e01b604082015260600190565b336000908152600e6020526040812080548892906117d0908490612e84565b9091555050336000908152600e6020526040902054600310156116e55760405162461bcd60e51b815260040161070d90602080825260049082015263042dac2f60e31b604082015260600190565b60021960ff88160161199e5761186b84848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050600d549150849050612565565b6118a05760405162461bcd60e51b815260206004820152600660248201526510b83937b7b360d11b604482015260640161070d565b336000908152600e6020526040812080548892906118bf908490612e84565b9091555050336000908152600f6020526040812080548792906118e3908490612e84565b9091555050336000908152600e6020526040902054600210156119315760405162461bcd60e51b815260040161070d90602080825260049082015263042dac2f60e31b604082015260600190565b336000908152600f60205260409020546001101561197a5760405162461bcd60e51b815260040161070d90602080825260049082015263042dac2f60e31b604082015260600190565b851561198c5761198c3387600061257b565b84156116f1576116f13386600161257b565b60405162461bcd60e51b815260206004820152600860248201527f21696e76616c6964000000000000000000000000000000000000000000000000604482015260640161070d565b50505050505050565b6001600160a01b0381166000908152600f6020908152604080832054600e9092528220546106b09190612e84565b601354610100900460ff16611a5d5760405162461bcd60e51b815260206004820152600660248201526521706861736560d01b604482015260640161070d565b60048111158015611a6e5750600081115b611aa35760405162461bcd60e51b815260040161070d906020808252600490820152632171747960e01b604082015260600190565b806014541015611af55760405162461bcd60e51b815260206004820152600760248201527f21737570706c7900000000000000000000000000000000000000000000000000604482015260640161070d565b6014805482900390556012546001600160a01b037f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4816906323b872dd9033903090611b41908690612eb3565b6040516001600160e01b031960e086901b1681526001600160a01b03938416600482015292909116602483015260448201526064016020604051808303816000875af1158015611b95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bb99190612f15565b611c055760405162461bcd60e51b815260206004820152600660248201527f2176616c75650000000000000000000000000000000000000000000000000000604482015260640161070d565b601154600090611c1760a36001612e84565b11611c23576000611c3c565b601154611c3260a36001612e84565b611c3c9190612e9c565b9050818115611c80576000828411611c545783611c56565b825b9050828411611c66576000611c70565b611c708385612e9c565b9150611c7e3382600161257b565b505b8015610949576109493382600061257b565b611c9a611dbd565b6001600160a01b038116611d165760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161070d565b611d1f8161214f565b50565b60006001600160e01b031982167f80ac58cd000000000000000000000000000000000000000000000000000000001480611d8557506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806106b057507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146106b0565b6008546001600160a01b03163314610f695760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161070d565b6000818152600260205260409020546001600160a01b0316611d1f5760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e2049440000000000000000604482015260640161070d565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190611ebd82610dca565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611f0283610dca565b9050806001600160a01b0316846001600160a01b03161480611f4957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b80611f6d5750836001600160a01b0316611f62846107f6565b6001600160a01b0316145b949350505050565b826001600160a01b0316611f8882610dca565b6001600160a01b0316146120045760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e6572000000000000000000000000000000000000000000000000000000606482015260840161070d565b6001600160a01b03821661207f5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f7265737300000000000000000000000000000000000000000000000000000000606482015260840161070d565b61208a600082611e7b565b6001600160a01b03831660009081526003602052604081208054600192906120b3908490612e9c565b90915550506001600160a01b03821660009081526003602052604081208054600192906120e1908490612e84565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600880546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361220f5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161070d565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b612287848484611f75565b612293848484846125fb565b61104e5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e7465720000000000000000000000000000606482015260840161070d565b60608160000361234857505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612372578061235c81613062565b915061236b9050600a83612ee8565b915061234c565b60008167ffffffffffffffff81111561238d5761238d612a1e565b6040519080825280601f01601f1916602001820160405280156123b7576020820181803683370190505b5090505b8415611f6d576123cc600183612e9c565b91506123d9600a8661307c565b6123e4906030612e84565b60f81b8183815181106123f9576123f9613090565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612433600a86612ee8565b94506123bb565b6127106bffffffffffffffffffffffff821611156124c05760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c65507269636500000000000000000000000000000000000000000000606482015260840161070d565b6001600160a01b0382166125165760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c696420726563656976657200000000000000604482015260640161070d565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff90911660209092018290527401000000000000000000000000000000000000000090910217600655565b6000826125728584612784565b14949350505050565b60008082156125bf575b838210156125ba57506011805490819060006125a083613062565b91905055506125af85826127d1565b816001019150612585565b6125f4565b838210156125f457506010805490819060006125da83613062565b91905055506125e985826127d1565b8160010191506125bf565b5050505050565b60006001600160a01b0384163b15612779576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a02906126589033908990889088906004016130a6565b6020604051808303816000875af1925050508015612693575060408051601f3d908101601f19168201909252612690918101906130e2565b60015b612746573d8080156126c1576040519150601f19603f3d011682016040523d82523d6000602084013e6126c6565b606091505b50805160000361273e5760405162461bcd60e51b815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e7465720000000000000000000000000000606482015260840161070d565b805181602001fd5b6001600160e01b0319167f150b7a0200000000000000000000000000000000000000000000000000000000149050611f6d565b506001949350505050565b600081815b84518110156127c9576127b5828683815181106127a8576127a8613090565b6020026020010151612920565b9150806127c181613062565b915050612789565b509392505050565b6001600160a01b0382166128275760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161070d565b6000818152600260205260409020546001600160a01b03161561288c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161070d565b6001600160a01b03821660009081526003602052604081208054600192906128b5908490612e84565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600081831061293c57600082815260208490526040902061294b565b60008381526020839052604090205b9392505050565b82805461295e90612e34565b90600052602060002090601f01602090048101928261298057600085556129c6565b82601f1061299957805160ff19168380011785556129c6565b828001600101855582156129c6579182015b828111156129c65782518255916020019190600101906129ab565b506129d29291506129d6565b5090565b5b808211156129d257600081556001016129d7565b6001600160e01b031981168114611d1f57600080fd5b600060208284031215612a1357600080fd5b813561294b816129eb565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612a4f57612a4f612a1e565b604051601f8501601f19908116603f01168101908282118183101715612a7757612a77612a1e565b81604052809350858152868686011115612a9057600080fd5b858560208301376000602087830101525050509392505050565b600060208284031215612abc57600080fd5b813567ffffffffffffffff811115612ad357600080fd5b8201601f81018413612ae457600080fd5b611f6d84823560208401612a34565b60005b83811015612b0e578181015183820152602001612af6565b8381111561104e5750506000910152565b60008151808452612b37816020860160208601612af3565b601f01601f19169290920160200192915050565b60208152600061294b6020830184612b1f565b600060208284031215612b7057600080fd5b5035919050565b80356001600160a01b03811681146112f257600080fd5b60008060408385031215612ba157600080fd5b612baa83612b77565b946020939093013593505050565b600060208284031215612bca57600080fd5b61294b82612b77565b600080600060608486031215612be857600080fd5b612bf184612b77565b9250612bff60208501612b77565b9150604084013590509250925092565b60008060408385031215612c2257600080fd5b50508035926020909101359150565b8015158114611d1f57600080fd5b600060208284031215612c5157600080fd5b813561294b81612c31565b60008060408385031215612c6f57600080fd5b612c7883612b77565b91506020830135612c8881612c31565b809150509250929050565b60008060008060808587031215612ca957600080fd5b612cb285612b77565b9350612cc060208601612b77565b925060408501359150606085013567ffffffffffffffff811115612ce357600080fd5b8501601f81018713612cf457600080fd5b612d0387823560208401612a34565b91505092959194509250565b803560ff811681146112f257600080fd5b60008060408385031215612d3357600080fd5b612baa83612d0f565b600060208284031215612d4e57600080fd5b81356bffffffffffffffffffffffff8116811461294b57600080fd5b60008060408385031215612d7d57600080fd5b612d8683612b77565b9150612d9460208401612b77565b90509250929050565b600080600080600060808688031215612db557600080fd5b612dbe86612d0f565b94506020860135935060408601359250606086013567ffffffffffffffff80821115612de957600080fd5b818801915088601f830112612dfd57600080fd5b813581811115612e0c57600080fd5b8960208260051b8501011115612e2157600080fd5b9699959850939650602001949392505050565b600181811c90821680612e4857607f821691505b602082108103612e6857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612e9757612e97612e6e565b500190565b600082821015612eae57612eae612e6e565b500390565b6000816000190483118215151615612ecd57612ecd612e6e565b500290565b634e487b7160e01b600052601260045260246000fd5b600082612ef757612ef7612ed2565b500490565b600060208284031215612f0e57600080fd5b5051919050565b600060208284031215612f2757600080fd5b815161294b81612c31565b6000602080835260008454612f4681612e34565b80848701526040600180841660008114612f675760018114612f7b57612fa9565b60ff198516838a0152606089019550612fa9565b896000528660002060005b85811015612fa15781548b8201860152908301908801612f86565b8a0184019650505b509398975050505050505050565b6000808454612fc581612e34565b60018281168015612fdd5760018114612fee5761301d565b60ff1984168752828701945061301d565b8860005260208060002060005b858110156130145781548a820152908401908201612ffb565b50505082870194505b505050508351613031818360208801612af3565b7f2e6a736f6e0000000000000000000000000000000000000000000000000000009101908152600501949350505050565b6000600019820361307557613075612e6e565b5060010190565b60008261308b5761308b612ed2565b500690565b634e487b7160e01b600052603260045260246000fd5b60006001600160a01b038087168352808616602084015250836040830152608060608301526130d86080830184612b1f565b9695505050505050565b6000602082840312156130f457600080fd5b815161294b816129eb56fea264697066735822122032dcf1bedce854979fe825aa592757f17d3ee4c16ac378ec211a5bb10413edd764736f6c634300080d0033
Verified Source Code Full Match
Compiler: v0.8.13+commit.abaa5c0e
EVM: london
Optimization: Yes (2000 runs)
ThisThingOfOurs.sol 390 lines
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
/**
* https://twitter.com/ttoonft
* https://ttoonft.io
* @title This Thing Of Ours
* @author BowTiedPickle
*/
contract ThisThingOfOurs is ERC721, ERC2981, Ownable {
using Strings for uint256;
event NewRoyalty(uint96 _newRoyalty);
event NewPrice(uint256 _newPrice);
event NewURI(string _newURI);
event URIFrozen(string _finalURI);
event NewRoot(uint8 _whitelist, bytes32 _root);
event PublicSaleStarted(uint256 _available);
event PublicSaleStopped();
event WhitelistSaleStatus(bool _status);
event Withdrawal(uint256 _balance);
string public baseURI;
bool public frozen;
uint8 public constant REGULAR_WL = 1;
uint8 public constant OG_WL = 2;
uint8 public constant CAPO_WL = 3;
bytes32 public merkleRoot;
bytes32 public ogMerkleRoot;
bytes32 public capoMerkleRoot;
mapping(address => uint256) public claimedSoldiers;
mapping(address => uint256) public claimedCapos;
// TokenIds 1-163 are reserved for whitelisted Capos
uint256 public nextId = 164;
uint256 public nextCapo = 1;
uint256 public constant maxCapoSupply = 163;
uint256 public mintPrice = 250e6; // Denominated in USDC
uint256 public constant maxSupply = 2000;
bool public whitelistSaleActive;
bool public publicSaleActive;
uint256 public publicSupplyAvailable;
IERC20 internal immutable USDC;
/**
* @param _owner Owner address
* @param _royaltyBPS Royalty in basis points, max is 10% (1000 BPS)
* @param _merkleRoot Merkle whitelist root for normal users
* @param _ogMerkleRoot Merkle whitelist root for OG users
* @param _capoMerkleRoot Merkle whitelist root for Capo users
* @param _USDC Address of the USDC token proxy
* @param _treasury Address to receive initial allocation
*/
constructor(
address _owner,
uint96 _royaltyBPS,
bytes32 _merkleRoot,
bytes32 _ogMerkleRoot,
bytes32 _capoMerkleRoot,
address _USDC,
address _treasury
) ERC721("This Thing Of Ours", "TTOO") {
require(_owner != address(0), "!addr");
require(_USDC != address(0), "!addr");
require(_royaltyBPS <= 1000, "!bps");
// Set Ownership
_transferOwnership(_owner);
_setDefaultRoyalty(owner(), _royaltyBPS);
// Set the merkle roots
merkleRoot = _merkleRoot;
ogMerkleRoot = _ogMerkleRoot;
capoMerkleRoot = _capoMerkleRoot;
// Set the USDC deployment
USDC = IERC20(_USDC);
// Mint admin allocation
mintInternal(_treasury, 75, false);
}
/**
* @notice Mint an NFT
* @dev User must have approved this contract for mintPrice * total quantity.
It is implicit that users should be only whitelisted for one category as they will not be able to utilize more than one tier fully.
* @param _whitelist Enter 1 for regular WL, 2 for OG WL, 3 for Capo WL
* @param _regularQty Amount of regular NFTs to mint
* @param _capoQty Amount of Capos to mint
* @param _proof Merkle proof for the chosen WL Merkle tree
*/
function mint(
uint8 _whitelist,
uint256 _regularQty,
uint256 _capoQty,
bytes32[] calldata _proof
) external {
require(whitelistSaleActive, "!phase");
require(!publicSaleActive, "!phase");
require(_regularQty > 0 || _capoQty > 0, "!qty");
uint256 totalCost = mintPrice * (_regularQty + _capoQty);
require(
USDC.transferFrom(msg.sender, address(this), totalCost),
"!value"
);
// Verify and assign tokenId based on which WL the user is in
bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
if (_whitelist == REGULAR_WL) {
require(MerkleProof.verify(_proof, merkleRoot, leaf), "!proof");
require(_regularQty > 0, "!qty");
claimedSoldiers[msg.sender] += _regularQty;
require(claimedSoldiers[msg.sender] <= 2, "!max");
mintInternal(msg.sender, _regularQty, false);
} else if (_whitelist == OG_WL) {
require(MerkleProof.verify(_proof, ogMerkleRoot, leaf), "!proof");
require(_regularQty > 0, "!qty");
claimedSoldiers[msg.sender] += _regularQty;
require(claimedSoldiers[msg.sender] <= 3, "!max");
mintInternal(msg.sender, _regularQty, false);
} else if (_whitelist == CAPO_WL) {
require(MerkleProof.verify(_proof, capoMerkleRoot, leaf), "!proof");
claimedSoldiers[msg.sender] += _regularQty;
claimedCapos[msg.sender] += _capoQty;
require(claimedSoldiers[msg.sender] <= 2, "!max");
require(claimedCapos[msg.sender] <= 1, "!max");
if (_regularQty > 0) {
mintInternal(msg.sender, _regularQty, false);
}
if (_capoQty > 0) {
mintInternal(msg.sender, _capoQty, true);
}
} else {
revert("!invalid");
}
}
function mintInternal(
address _to,
uint256 _qty,
bool _capo
) internal {
uint256 i;
uint256 tokenId;
if (_capo) {
for (; i < _qty; ) {
tokenId = nextCapo;
nextCapo++;
_mint(_to, tokenId);
unchecked {
++i;
}
}
} else {
for (; i < _qty; ) {
tokenId = nextId;
nextId++;
_mint(_to, tokenId);
unchecked {
++i;
}
}
}
}
/**
* @notice Purchase an NFT during public sale
* @dev User must have approved the contract for mintPrice
* @param _qty Quantity of NFTs to purchase, must be > 0 and <= 4
*/
function purchase(uint256 _qty) external {
require(publicSaleActive, "!phase");
require(_qty <= 4 && _qty > 0, "!qty");
require(publicSupplyAvailable >= _qty, "!supply");
// We have already checked this will not underflow
unchecked {
publicSupplyAvailable -= _qty;
}
require(
USDC.transferFrom(msg.sender, address(this), mintPrice * _qty),
"!value"
);
uint256 caposLeft = maxCapoSupply + 1 > nextCapo
? maxCapoSupply + 1 - nextCapo
: 0;
uint256 soldiersToMint = _qty;
// Mint Capos if any are left, otherwise mint regular tokens
if (caposLeft > 0) {
uint256 caposToMint = _qty > caposLeft ? caposLeft : _qty;
soldiersToMint = _qty > caposLeft ? _qty - caposLeft : 0;
mintInternal(msg.sender, caposToMint, true);
}
if (soldiersToMint > 0) {
mintInternal(msg.sender, soldiersToMint, false);
}
}
// ----- View Functions -----
/**
* @notice Get the total number of NFTs claimed for the user.
* @param _user Address to query
*/
function totalClaimed(address _user) external view returns (uint256) {
return claimedSoldiers[_user] + claimedCapos[_user];
}
// ----- Admin Functions -----
/**
* @notice Disable whitelist minting and start a public sale of the remaining supply
*/
function startPublicSale() external onlyOwner {
require(!publicSaleActive, "!phase");
whitelistSaleActive = false;
publicSaleActive = true;
publicSupplyAvailable = (maxSupply +
maxCapoSupply -
nextId -
nextCapo +
2);
// ----- Example Math -----
// Mint 1000 regular + 100 Capos = 900 available
// 2000 + 163 - 1159 - 101 + 2 = 900
// Mint 1845 regular + 155 Capo = 0 available
// 2000 + 163 - 2001 - 163 + 2 = 0
// ------------------------
emit PublicSaleStarted(publicSupplyAvailable);
}
/**
* @notice Stop a public sale
*/
function stopPublicSale() external onlyOwner {
require(publicSaleActive, "!phase");
publicSaleActive = false;
publicSupplyAvailable = 0;
emit PublicSaleStopped();
}
/**
* @notice Start or stop the whitelist sale
*/
function setWhitelistSaleStatus(bool _status) external onlyOwner {
require(!publicSaleActive, "!phase");
whitelistSaleActive = _status;
emit WhitelistSaleStatus(_status);
}
/**
* @notice Set a new mint price
* @param _newPrice New mint price in USDC (6 decimals)
*/
function setPrice(uint256 _newPrice) external onlyOwner {
mintPrice = _newPrice;
emit NewPrice(_newPrice);
}
/**
* @notice Withdraw profits from the contract
*/
function withdraw() external onlyOwner {
uint256 balance = USDC.balanceOf(address(this));
USDC.transfer(owner(), balance);
emit Withdrawal(balance);
}
/**
* @notice Sets a new royalty numerator
* @dev Cannot exceed 10%
* @param _royaltyBPS New royalty, denominated in BPS (10000 = 100%)
* @return True on success
*/
function setRoyalty(uint96 _royaltyBPS) external onlyOwner returns (bool) {
require(_royaltyBPS <= 1000, "!bps");
_setDefaultRoyalty(owner(), _royaltyBPS);
emit NewRoyalty(_royaltyBPS);
return true;
}
/**
* @notice Set a new base URI
* @param _newURI new URI string
*/
function setURI(string memory _newURI) external onlyOwner {
require(!frozen, "!frozen");
baseURI = _newURI;
emit NewURI(_newURI);
}
/**
* @notice Freeze the URI, preventing further changes
*/
function freezeURI() external onlyOwner {
require(!frozen, "!frozen");
frozen = true;
emit URIFrozen(baseURI);
}
/**
* @notice Set a Merkle root
* @param _whitelist ID of the whitelist to change
* @param _root New Merkle root
*/
function setRoot(uint8 _whitelist, bytes32 _root) external onlyOwner {
if (_whitelist == REGULAR_WL) {
merkleRoot = _root;
} else if (_whitelist == OG_WL) {
ogMerkleRoot = _root;
} else if (_whitelist == CAPO_WL) {
capoMerkleRoot = _root;
} else {
revert("Not valid WL");
}
emit NewRoot(_whitelist, _root);
}
// ----- Overrides -----
/// @inheritdoc ERC721
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
_requireMinted(tokenId);
return
bytes(baseURI).length > 0
? string(abi.encodePacked(baseURI, tokenId.toString(), ".json"))
: "";
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721, ERC2981)
returns (bool)
{
return
interfaceId == type(ERC2981).interfaceId ||
ERC721.supportsInterface(interfaceId);
}
}
ERC2981.sol 111 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
MerkleProof.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
* consuming from one or the other at each step according to the instructions given by
* `proofFlags`.
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_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) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @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);
}
}
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;
}
}
IERC2981.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
ERC721.sol 454 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 = _owners[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 nor 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 nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
_safeTransfer(from, to, tokenId, data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
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);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @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.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev 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);
}
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);
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
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);
}
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);
}
Read Contract
CAPO_WL 0xc218fd8a → uint8
OG_WL 0x3fab755b → uint8
REGULAR_WL 0xca344d3b → uint8
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
capoMerkleRoot 0x140578f0 → bytes32
claimedCapos 0xabc8af18 → uint256
claimedSoldiers 0x12487365 → uint256
frozen 0x054f7d9c → bool
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
maxCapoSupply 0x6465d23c → uint256
maxSupply 0xd5abeb01 → uint256
merkleRoot 0x2eb4a7ab → bytes32
mintPrice 0x6817c76c → uint256
name 0x06fdde03 → string
nextCapo 0x8c95d20c → uint256
nextId 0x61b8ce8c → uint256
ogMerkleRoot 0x0a302530 → bytes32
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
publicSaleActive 0xbc8893b4 → bool
publicSupplyAvailable 0x8ad1efa0 → uint256
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalClaimed 0xef5d9ae8 → uint256
whitelistSaleActive 0x3ad7f56c → bool
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
freezeURI 0xc793803c
No parameters
mint 0xeae498fe
uint8 _whitelist
uint256 _regularQty
uint256 _capoQty
bytes32[] _proof
purchase 0xefef39a1
uint256 _qty
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setPrice 0x91b7f5ed
uint256 _newPrice
setRoot 0xc2a0d4b3
uint8 _whitelist
bytes32 _root
setRoyalty 0xcac92669
uint96 _royaltyBPS
returns: bool
setURI 0x02fe5305
string _newURI
setWhitelistSaleStatus 0x4920b41e
bool _status
startPublicSale 0x0c1c972a
No parameters
stopPublicSale 0xda1b91c3
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address