Address Contract Partially Verified
Address
0x08D7C0242953446436F34b4C78Fe9da38c73668d
Balance
0 ETH
Nonce
1
Code Size
12053 bytes
Creator
0x6c8984bA...9ecA at tx 0x1687705c...f2bbf1
Indexed Transactions
0
Contract Bytecode
12053 bytes
0x6080604052600436106101ee5760003560e01c80637bd07f8b1161010d578063b88d4fde116100a0578063c87b56dd1161006f578063c87b56dd146105ee578063d547cfb71461060e578063e0c5b0ed14610623578063e985e9c514610643578063f2fde38b1461066357600080fd5b8063b88d4fde14610503578063bb69b7ef14610523578063bf62e21d146105ae578063c85b380d146105ce57600080fd5b80639106d7ba116100dc5780639106d7ba146104b157806395d89b41146104c6578063a22cb465146104db578063a6f2ae3a146104fb57600080fd5b80637bd07f8b146104105780638456cb591461045e5780638da5cb5b146104735780639097548d1461049157600080fd5b806330176e13116101855780635c975abb116101545780635c975abb1461039c5780636352211e146103bb57806370a08231146103db578063715018a6146103fb57600080fd5b806330176e131461032757806338af3eed146103475780633f4ba83a1461036757806342842e0e1461037c57600080fd5b806318160ddd116101c157806318160ddd146102a45780631c31f710146102c757806323b872dd146102e75780632f274bd41461030757600080fd5b806301ffc9a7146101f357806306fdde0314610228578063081812fc1461024a578063095ea7b314610282575b600080fd5b3480156101ff57600080fd5b5061021361020e366004612631565b610683565b60405190151581526020015b60405180910390f35b34801561023457600080fd5b5061023d610694565b60405161021f91906126a6565b34801561025657600080fd5b5061026a6102653660046126b9565b610726565b6040516001600160a01b03909116815260200161021f565b34801561028e57600080fd5b506102a261029d3660046126e7565b6107c0565b005b3480156102b057600080fd5b506102b96108d6565b60405190815260200161021f565b3480156102d357600080fd5b506102a26102e2366004612713565b6108e5565b3480156102f357600080fd5b506102a2610302366004612730565b610931565b34801561031357600080fd5b506102a26103223660046127dc565b610962565b34801561033357600080fd5b506102a26103423660046128ef565b610b50565b34801561035357600080fd5b50600d5461026a906001600160a01b031681565b34801561037357600080fd5b506102a2610b91565b34801561038857600080fd5b506102a2610397366004612730565b610bc5565b3480156103a857600080fd5b50600654600160a01b900460ff16610213565b3480156103c757600080fd5b5061026a6103d63660046126b9565b610be0565b3480156103e757600080fd5b506102b96103f6366004612713565b610c57565b34801561040757600080fd5b506102a2610cde565b34801561041c57600080fd5b5060115460125460135460145460155461044c94939291906001600160f81b03811690600160f81b900460ff1686565b60405161021f9695949392919061294e565b34801561046a57600080fd5b506102a2610d12565b34801561047f57600080fd5b506006546001600160a01b031661026a565b34801561049d57600080fd5b506102b96104ac3660046126b9565b610d44565b3480156104bd57600080fd5b506102b9610e69565b3480156104d257600080fd5b5061023d610e74565b3480156104e757600080fd5b506102a26104f63660046129a8565b610e83565b6102a2610e8e565b34801561050f57600080fd5b506102a261051e3660046129dd565b610e99565b34801561052f57600080fd5b50600854600954600a54600b54600c5461056b949392916001600160f81b0381169160ff600160f81b9092048216918181169161010090041687565b604080519788526020880196909652948601939093526001600160f81b03909116606085015215156080840152151560a0830152151560c082015260e00161021f565b3480156105ba57600080fd5b506102a26105c93660046126e7565b610ed1565b3480156105da57600080fd5b506102a26105e9366004612a5d565b611046565b3480156105fa57600080fd5b5061023d6106093660046126b9565b61122e565b34801561061a57600080fd5b5061023d6112dc565b34801561062f57600080fd5b506102a261063e3660046126b9565b61136a565b34801561064f57600080fd5b5061021361065e366004612ae0565b611399565b34801561066f57600080fd5b506102a261067e366004612713565b6113db565b600061068e8261147a565b92915050565b6060600080546106a390612b19565b80601f01602080910402602001604051908101604052809291908181526020018280546106cf90612b19565b801561071c5780601f106106f15761010080835404028352916020019161071c565b820191906000526020600020905b8154815290600101906020018083116106ff57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107a45760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60006107cb82610be0565b9050806001600160a01b0316836001600160a01b031614156108395760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161079b565b336001600160a01b038216148061085557506108558133611399565b6108c75760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161079b565b6108d183836114ca565b505050565b60006108e0610e69565b905090565b6006546001600160a01b0316331461090f5760405162461bcd60e51b815260040161079b90612b4e565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b61093b3382611538565b6109575760405162461bcd60e51b815260040161079b90612b83565b6108d183838361160f565b6006546001600160a01b0316331461098c5760405162461bcd60e51b815260040161079b90612b4e565b80606001516001600160f81b0316816000015110156109ed5760405162461bcd60e51b815260206004820152601c60248201527f53656c6c65723a2065786365737369766520667265652071756f746100000000604482015260640161079b565b600e5481511015610a405760405162461bcd60e51b815260206004820181905260248201527f53656c6c65723a20696e76656e746f7279203c20616c726561647920736f6c64604482015260640161079b565b60105481606001516001600160f81b03161015610aa95760405162461bcd60e51b815260206004820152602160248201527f53656c6c65723a20667265652071756f7461203c20616c7265616479207573656044820152601960fa1b606482015260840161079b565b600c54610100900460ff1615610ac657600160c082015260085481525b600c5460ff1615610aea57600160a0820152600b546001600160f81b031660608201525b805160085560208101516009556040810151600a55606081015160808201511515600160f81b026001600160f81b0390911617600b5560a0810151600c805460c09093015115156101000261ff00199215159290921661ffff1990931692909217179055565b6006546001600160a01b03163314610b7a5760405162461bcd60e51b815260040161079b90612b4e565b8051610b8d906016906020840190612582565b5050565b6006546001600160a01b03163314610bbb5760405162461bcd60e51b815260040161079b90612b4e565b610bc36117ba565b565b6108d183838360405180602001604052806000815250610e99565b6000818152600260205260408120546001600160a01b03168061068e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161079b565b60006001600160a01b038216610cc25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161079b565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314610d085760405162461bcd60e51b815260040161079b90612b4e565b610bc36000611857565b6006546001600160a01b03163314610d3c5760405162461bcd60e51b815260040161079b90612b4e565b610bc36118a9565b600060118160016004830154600160f81b900460ff166002811115610d6b57610d6b612938565b1415610d78575043610da3565b60026004830154600160f81b900460ff166002811115610d9a57610d9a612938565b1415610da35750425b815415801590610db4575081548110155b610e005760405162461bcd60e51b815260206004820152601f60248201527f4c696e656172447574636841756374696f6e3a204e6f74207374617274656400604482015260640161079b565b60028201548254600091610e3591610e189085612bea565b610e229190612c17565b60048501546001600160f81b031661190e565b9050826003015481610e479190612c2b565b8360010154610e569190612bea565b610e609086612c2b565b95945050505050565b60006108e0600e5490565b6060600180546106a390612b19565b610b8d338383611924565b610bc33360016119f3565b610ea33383611538565b610ebf5760405162461bcd60e51b815260040161079b90612b83565b610ecb84848484611ea5565b50505050565b6006546001600160a01b03163314610efb5760405162461bcd60e51b815260040161079b90612b4e565b600654600160a01b900460ff1615610f255760405162461bcd60e51b815260040161079b90612c4a565b600b546001600160f81b0316610f4d82610f3e60105490565b610f489084612bea565b61190e565b915060008211610f9f5760405162461bcd60e51b815260206004820152601b60248201527f53656c6c65723a20467265652071756f74612065786365656465640000000000604482015260640161079b565b600854610faf83610f3e600e5490565b925060008311610ff45760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b604482015260640161079b565b61100084846001611ed8565b61100b600e84611f11565b611016601084611f11565b80611020600e5490565b111561102e5761102e612c74565b8161103860105490565b1115610ecb57610ecb612c74565b6006546001600160a01b031633146110705760405162461bcd60e51b815260040161079b90612b4e565b8082608001516001600160f81b0316836060015102836020015103146110e65760405162461bcd60e51b815260206004820152602560248201527f4c696e656172447574636841756374696f6e3a20696e636f7272656374207265604482015264736572766560d81b606482015260840161079b565b60008260a0015160028111156110fe576110fe612938565b14156111585760405162461bcd60e51b8152602060048201526024808201527f4c696e656172447574636841756374696f6e3a20756e737065636966696564206044820152631d5b9a5d60e21b606482015260840161079b565b60008260400151116111bf5760405162461bcd60e51b815260206004820152602a60248201527f4c696e656172447574636841756374696f6e3a207a65726f206465637265617360448201526919481a5b9d195c9d985b60b21b606482015260840161079b565b815160119081556020830151601255604083015160135560608301516014556080830151601580546001600160f81b0319166001600160f81b03909216918217815560a0850151859392909190600160f81b83600281111561122357611223612938565b021790555050505050565b606081611252816000908152600260205260409020546001600160a01b0316151590565b6112a85760405162461bcd60e51b815260206004820152602160248201527f455243373231436f6d6d6f6e3a20546f6b656e20646f65736e277420657869736044820152601d60fa1b606482015260840161079b565b60166112b384611f2e565b6040516020016112c4929190612ca6565b60405160208183030381529060405291505b50919050565b601680546112e990612b19565b80601f016020809104026020016040519081016040528092919081815260200182805461131590612b19565b80156113625780601f1061133757610100808354040283529160200191611362565b820191906000526020600020905b81548152906001019060200180831161134557829003601f168201915b505050505081565b6006546001600160a01b031633146113945760405162461bcd60e51b815260040161079b90612b4e565b601155565b6001600160a01b03808316600090815260056020908152604080832093851683529290529081205460ff16806113d457506113d4838361202c565b9392505050565b6006546001600160a01b031633146114055760405162461bcd60e51b815260040161079b90612b4e565b6001600160a01b03811661146a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161079b565b61147381611857565b50565b5490565b60006001600160e01b031982166380ac58cd60e01b14806114ab57506001600160e01b03198216635b5e139f60e01b145b8061068e57506301ffc9a760e01b6001600160e01b031983161461068e565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906114ff82610be0565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166115b15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161079b565b60006115bc83610be0565b9050806001600160a01b0316846001600160a01b031614806115f75750836001600160a01b03166115ec84610726565b6001600160a01b0316145b8061160757506116078185611399565b949350505050565b826001600160a01b031661162282610be0565b6001600160a01b03161461168a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b606482015260840161079b565b6001600160a01b0382166116ec5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161079b565b6116f783838361210e565b6117026000826114ca565b6001600160a01b038316600090815260036020526040812080546001929061172b908490612bea565b90915550506001600160a01b0382166000908152600360205260408120805460019290611759908490612d44565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600654600160a01b900460ff1661180a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015260640161079b565b6006805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600654600160a01b900460ff16156118d35760405162461bcd60e51b815260040161079b90612c4a565b6006805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861183a3390565b600081831061191d57816113d4565b5090919050565b816001600160a01b0316836001600160a01b031614156119865760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161079b565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b60026007541415611a465760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161079b565b6002600755600654600160a01b900460ff1615611a755760405162461bcd60e51b815260040161079b90612c4a565b6040805160e08101825260085481526009546020820152600a54918101829052600b546001600160f81b038116606083015260ff600160f81b909104811615156080830152600c54808216151560a0840152610100900416151560c08201529060009015611af057611aeb83836040015161190e565b611af2565b825b905060008260800151611b06578251611b20565b60608301518351611b20916001600160f81b031690612bea565b9050611b2f82610f3e600e5490565b915060008211611b745760405162461bcd60e51b815260206004820152601060248201526f14d95b1b195c8e8814dbdb19081bdd5d60821b604482015260640161079b565b602083015115611cd057336001600160a01b038616811415906000903214801590611ba85750326001600160a01b03881614155b9050611bd884886040518060400160405280600b81526020016a109d5e595c881b1a5b5a5d60aa1b815250612119565b93508115611c1257611c0f84336040518060400160405280600c81526020016b14d95b99195c881b1a5b5a5d60a21b815250612119565b93505b8015611c4a57611c4784326040518060400160405280600c81526020016b13dc9a59da5b881b1a5b5a5d60a21b815250612119565b93505b6001600160a01b0387166000908152600f602052604081208054869290611c72908490612d44565b90915550508115611ca257336000908152600f602052604081208054869290611c9c908490612d44565b90915550505b8015611ccd57326000908152600f602052604081208054869290611cc7908490612d44565b90915550505b50505b6000611cdb83610d44565b905080341015611d3157611cfb611cf6633b9aca0083612c17565b611f2e565b604051602001611d0b9190612d5c565b60408051601f198184030181529082905262461bcd60e51b825261079b916004016126a6565b611d3d86846000611ed8565b611d48600e84611f11565b8351600e541115611d5b57611d5b612c74565b8015611dc057600d54611d77906001600160a01b031682612162565b600d5460408051858152602081018490526001600160a01b03909216917f01f51b99bd1c3cca301836178e5dee13aadfe44eff06dc3ddcbf3c9d058454f8910160405180910390a25b80341115611e9857336000611dd58334612bea565b9050600080836001600160a01b03168360405160006040518083038185875af1925050503d8060008114611e25576040519150601f19603f3d011682016040523d82523d6000602084013e611e2a565b606091505b5091509150818190611e4f5760405162461bcd60e51b815260040161079b91906126a6565b50836001600160a01b03167fbb28353e4598c3b9199101a66e0989549b659a59a54d2c27fbb183f1932c8e6d84604051611e8b91815260200190565b60405180910390a2505050505b5050600160075550505050565b611eb084848461160f565b611ebc8484848461227b565b610ecb5760405162461bcd60e51b815260040161079b90612da1565b60005b82811015610ecb57611eff8482611ef0610e69565b611efa9190612d44565b612379565b80611f0981612df3565b915050611edb565b80826000016000828254611f259190612d44565b90915550505050565b606081611f525750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611f7c5780611f6681612df3565b9150611f759050600a83612c17565b9150611f56565b60008167ffffffffffffffff811115611f9757611f97612771565b6040519080825280601f01601f191660200182016040528015611fc1576020820181803683370190505b5090505b841561160757611fd6600183612bea565b9150611fe3600a86612e0e565b611fee906030612d44565b60f81b81838151811061200357612003612e22565b60200101906001600160f81b031916908160001a905350612025600a86612c17565b9450611fc5565b6000804660018114612045576004811461206157612079565b73a5409ec958c83c3f309868babaca7c86dcb077c19150612079565b73f57b2c51ded3a29e6891aba85459d600256cf31791505b506001600160a01b03811615801590611607575060405163c455279160e01b81526001600160a01b038581166004830152808516919083169063c455279190602401602060405180830381865afa1580156120d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120fc9190612e38565b6001600160a01b031614949350505050565b6108d1838383612393565b6001600160a01b0382166000908152600f6020526040812054600954829161214091612bea565b9050806121585782604051602001611d0b9190612e55565b610e60858261190e565b804710156121b25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161079b565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146121ff576040519150601f19603f3d011682016040523d82523d6000602084013e612204565b606091505b50509050806108d15760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161079b565b60006001600160a01b0384163b1561236e57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906122bf903390899088908890600401612e85565b6020604051808303816000875af19250505080156122fa575060408051601f3d908101601f191682019092526122f791810190612ec2565b60015b612354573d808015612328576040519150601f19603f3d011682016040523d82523d6000602084013e61232d565b606091505b50805161234c5760405162461bcd60e51b815260040161079b90612da1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611607565b506001949350505050565b610b8d828260405180602001604052806000815250612401565b600654600160a01b900460ff16156108d15760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b606482015260840161079b565b61240b8383612434565b612418600084848461227b565b6108d15760405162461bcd60e51b815260040161079b90612da1565b6001600160a01b03821661248a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161079b565b6000818152600260205260409020546001600160a01b0316156124ef5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161079b565b6124fb6000838361210e565b6001600160a01b0382166000908152600360205260408120805460019290612524908490612d44565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b82805461258e90612b19565b90600052602060002090601f0160209004810192826125b057600085556125f6565b82601f106125c957805160ff19168380011785556125f6565b828001600101855582156125f6579182015b828111156125f65782518255916020019190600101906125db565b50612602929150612606565b5090565b5b808211156126025760008155600101612607565b6001600160e01b03198116811461147357600080fd5b60006020828403121561264357600080fd5b81356113d48161261b565b60005b83811015612669578181015183820152602001612651565b83811115610ecb5750506000910152565b6000815180845261269281602086016020860161264e565b601f01601f19169290920160200192915050565b6020815260006113d4602083018461267a565b6000602082840312156126cb57600080fd5b5035919050565b6001600160a01b038116811461147357600080fd5b600080604083850312156126fa57600080fd5b8235612705816126d2565b946020939093013593505050565b60006020828403121561272557600080fd5b81356113d4816126d2565b60008060006060848603121561274557600080fd5b8335612750816126d2565b92506020840135612760816126d2565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b60405160c0810167ffffffffffffffff811182821017156127aa576127aa612771565b60405290565b80356001600160f81b03811681146127c757600080fd5b919050565b803580151581146127c757600080fd5b600060e082840312156127ee57600080fd5b60405160e0810181811067ffffffffffffffff8211171561281157612811612771565b806040525082358152602083013560208201526040830135604082015261283a606084016127b0565b606082015261284b608084016127cc565b608082015261285c60a084016127cc565b60a082015261286d60c084016127cc565b60c08201529392505050565b600067ffffffffffffffff8084111561289457612894612771565b604051601f8501601f19908116603f011681019082821181831017156128bc576128bc612771565b816040528093508581528686860111156128d557600080fd5b858560208301376000602087830101525050509392505050565b60006020828403121561290157600080fd5b813567ffffffffffffffff81111561291857600080fd5b8201601f8101841361292957600080fd5b61160784823560208401612879565b634e487b7160e01b600052602160045260246000fd5b8681526020810186905260408101859052606081018490526001600160f81b038316608082015260c081016003831061299757634e487b7160e01b600052602160045260246000fd5b8260a0830152979650505050505050565b600080604083850312156129bb57600080fd5b82356129c6816126d2565b91506129d4602084016127cc565b90509250929050565b600080600080608085870312156129f357600080fd5b84356129fe816126d2565b93506020850135612a0e816126d2565b925060408501359150606085013567ffffffffffffffff811115612a3157600080fd5b8501601f81018713612a4257600080fd5b612a5187823560208401612879565b91505092959194509250565b60008082840360e0811215612a7157600080fd5b60c0811215612a7f57600080fd5b50612a88612787565b83358152602084013560208201526040840135604082015260608401356060820152612ab6608085016127b0565b608082015260a084013560038110612acd57600080fd5b60a08201529460c0939093013593505050565b60008060408385031215612af357600080fd5b8235612afe816126d2565b91506020830135612b0e816126d2565b809150509250929050565b600181811c90821680612b2d57607f821691505b602082108114156112d657634e487b7160e01b600052602260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600082821015612bfc57612bfc612bd4565b500390565b634e487b7160e01b600052601260045260246000fd5b600082612c2657612c26612c01565b500490565b6000816000190483118215151615612c4557612c45612bd4565b500290565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b634e487b7160e01b600052600160045260246000fd5b60008151612c9c81856020860161264e565b9290920192915050565b600080845481600182811c915080831680612cc257607f831692505b6020808410821415612ce257634e487b7160e01b86526022600452602486fd5b818015612cf65760018114612d0757612d34565b60ff19861689528489019650612d34565b60008b81526020902060005b86811015612d2c5781548b820152908501908301612d13565b505084890196505b505050505050610e608185612c8a565b60008219821115612d5757612d57612bd4565b500190565b6d029b2b63632b91d1021b7b9ba39960951b815260008251612d8581600e85016020870161264e565b64204757656960d81b600e939091019283015250601301919050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000600019821415612e0757612e07612bd4565b5060010190565b600082612e1d57612e1d612c01565b500690565b634e487b7160e01b600052603260045260246000fd5b600060208284031215612e4a57600080fd5b81516113d4816126d2565b67029b2b63632b91d160c51b815260008251612e7881600885016020870161264e565b9190910160080192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612eb89083018461267a565b9695505050505050565b600060208284031215612ed457600080fd5b81516113d48161261b56fea2646970667358221220fca7fa1394d1d2573416174e0038e6790e5c4267fe99f086b735880a32fe2e9b64736f6c634300080a0033
Verified Source Code Partial Match
Compiler: v0.8.10+commit.fc410830
EVM: london
Optimization: Yes (200 runs)
PROOFCollective.sol 89 lines
// SPDX-License-Identifier: UNLICENCED
// Copyright 2021 Arran Schlosberg (@divergencearran)
pragma solidity 0.8.10;
import "@divergencetech/ethier/contracts/erc721/ERC721Common.sol";
import "@divergencetech/ethier/contracts/sales/LinearDutchAuction.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
/// @title PROOF Collective NFT
/// @author @divergencearran
contract PROOFCollective is ERC721Common, LinearDutchAuction {
using Strings for uint256;
constructor(
string memory name,
string memory symbol,
address payable beneficiary
)
ERC721Common(name, symbol)
LinearDutchAuction(
LinearDutchAuction.DutchAuctionConfig({
startPoint: 0, // disabled at deployment
startPrice: 5 ether,
unit: AuctionIntervalUnit.Time,
decreaseInterval: 900, // 15 minutes
decreaseSize: 0.5 ether,
numDecreases: 9
}),
0.5 ether,
Seller.SellerConfig({
totalInventory: 1000,
lockTotalInventory: true,
maxPerAddress: 2,
maxPerTx: 1,
freeQuota: 75,
lockFreeQuota: true,
reserveFreeQuota: true
}),
beneficiary
)
{}
/// @notice Entry point for purchase of a single token.
function buy() external payable {
Seller._purchase(msg.sender, 1);
}
/**
@notice Internal override of Seller function for handling purchase (i.e.
minting).
*/
function _handlePurchase(
address to,
uint256 num,
bool
) internal override {
for (uint256 i = 0; i < num; i++) {
_safeMint(to, totalSold() + i);
}
}
/// @notice Prefix for tokenURI return values.
string public baseTokenURI;
/// @notice Set the baseTokenURI.
function setBaseTokenURI(string memory baseTokenURI_) external onlyOwner {
baseTokenURI = baseTokenURI_;
}
/// @notice Returns the token's metadata URI.
function tokenURI(uint256 tokenId)
public
view
override
tokenExists(tokenId)
returns (string memory)
{
return string(abi.encodePacked(baseTokenURI, tokenId.toString()));
}
/**
@notice Returns total number of existing tokens.
@dev Using ERC721Enumerable is unnecessarily expensive wrt gas. However
Etherscan uses totalSupply() so we provide it here.
*/
function totalSupply() external view returns (uint256) {
return totalSold();
}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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 Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_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 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @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 / b + (a % b == 0 ? 0 : 1);
}
}
Pausable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
ERC721.sol 424 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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: balance query for the zero address");
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: owner query for nonexistent token");
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) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, 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);
}
/**
* @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);
}
/**
* @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 of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
Seller.sol 294 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
import "../utils/Monotonic.sol";
import "../utils/OwnerPausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
/**
@notice An abstract contract providing the _purchase() function to:
- Enforce per-wallet / per-transaction limits
- Calculate required cost, forwarding to a beneficiary, and refunding extra
*/
abstract contract Seller is OwnerPausable, ReentrancyGuard {
using Address for address payable;
using Monotonic for Monotonic.Increaser;
using Strings for uint256;
/**
@dev Note that the address limits are vulnerable to wallet farming.
@param maxPerAddress Unlimited if zero.
@param maxPerTex Unlimited if zero.
@param freeQuota Maximum number that can be purchased free of charge by
the contract owner.
@param reserveFreeQuota Whether to excplitly reserve the freeQuota amount
and not let it be eroded by regular purchases.
@param lockFreeQuota If true, calls to setSellerConfig() will ignore changes
to freeQuota. Can be locked after initial setting, but not unlocked. This
allows a contract owner to commit to a maximum number of reserved items.
@param lockTotalInventory Similar to lockFreeQuota but applied to
totalInventory.
*/
struct SellerConfig {
uint256 totalInventory;
uint256 maxPerAddress;
uint256 maxPerTx;
uint248 freeQuota;
bool reserveFreeQuota;
bool lockFreeQuota;
bool lockTotalInventory;
}
constructor(SellerConfig memory config, address payable _beneficiary) {
setSellerConfig(config);
setBeneficiary(_beneficiary);
}
/// @notice Configuration of purchase limits.
SellerConfig public sellerConfig;
/// @notice Sets the seller config.
function setSellerConfig(SellerConfig memory config) public onlyOwner {
require(
config.totalInventory >= config.freeQuota,
"Seller: excessive free quota"
);
require(
config.totalInventory >= _totalSold.current(),
"Seller: inventory < already sold"
);
require(
config.freeQuota >= purchasedFreeOfCharge.current(),
"Seller: free quota < already used"
);
// Overriding the in-memory fields before copying the whole struct, as
// against writing individual fields, gives a greater guarantee of
// correctness as the code is simpler to read.
if (sellerConfig.lockTotalInventory) {
config.lockTotalInventory = true;
config.totalInventory = sellerConfig.totalInventory;
}
if (sellerConfig.lockFreeQuota) {
config.lockFreeQuota = true;
config.freeQuota = sellerConfig.freeQuota;
}
sellerConfig = config;
}
/// @notice Recipient of revenues.
address payable public beneficiary;
/// @notice Sets the recipient of revenues.
function setBeneficiary(address payable _beneficiary) public onlyOwner {
beneficiary = _beneficiary;
}
/**
@dev Must return the current cost of a batch of items. This may be constant
or, for example, decreasing for a Dutch auction or increasing for a bonding
curve.
@param n The number of items being purchased.
*/
function cost(uint256 n) public view virtual returns (uint256);
/**
@dev Called by both _purchase() and purchaseFreeOfCharge() after all limits
have been put in place; must perform all contract-specific sale logic, e.g.
ERC721 minting. When _handlePurchase() is called, the value returned by
Seller.totalSold() will be the pre-purchase amount.
@param to The recipient of the item(s).
@param n The number of items allowed to be purchased, which MAY be less than
to the number passed to _purchase() but SHALL be greater than zero.
@param freeOfCharge Indicates that the call originated from
purchaseFreeOfCharge() and not _purchase().
*/
function _handlePurchase(
address to,
uint256 n,
bool freeOfCharge
) internal virtual;
/**
@notice Tracks total number of items sold by this contract, including those
purchased free of charge by the contract owner.
*/
Monotonic.Increaser private _totalSold;
/// @notice Returns the total number of items sold by this contract.
function totalSold() public view returns (uint256) {
return _totalSold.current();
}
/**
@notice Tracks the number of items already bought by an address, regardless
of transferring out (in the case of ERC721).
@dev This isn't public as it may be skewed due to differences in msg.sender
and tx.origin, which it treats in the same way such that
sum(_bought)>=totalSold().
*/
mapping(address => uint256) private _bought;
/**
@notice Returns min(n, max(extra items addr can purchase)) and reverts if 0.
@param zeroMsg The message with which to revert on 0 extra.
*/
function _capExtra(
uint256 n,
address addr,
string memory zeroMsg
) internal view returns (uint256) {
uint256 extra = sellerConfig.maxPerAddress - _bought[addr];
if (extra == 0) {
revert(string(abi.encodePacked("Seller: ", zeroMsg)));
}
return Math.min(n, extra);
}
/// @notice Emitted when a buyer is refunded.
event Refund(address indexed buyer, uint256 amount);
/// @notice Emitted on all purchases of non-zero amount.
event Revenue(
address indexed beneficiary,
uint256 numPurchased,
uint256 amount
);
/// @notice Tracks number of items purchased free of charge.
Monotonic.Increaser private purchasedFreeOfCharge;
/**
@notice Allows the contract owner to purchase without payment, within the
quota enforced by the SellerConfig.
*/
function purchaseFreeOfCharge(address to, uint256 n)
public
onlyOwner
whenNotPaused
{
uint256 freeQuota = sellerConfig.freeQuota;
n = Math.min(n, freeQuota - purchasedFreeOfCharge.current());
require(n > 0, "Seller: Free quota exceeded");
uint256 totalInventory = sellerConfig.totalInventory;
n = Math.min(n, totalInventory - _totalSold.current());
require(n > 0, "Seller: Sold out");
_handlePurchase(to, n, true);
_totalSold.add(n);
purchasedFreeOfCharge.add(n);
assert(_totalSold.current() <= totalInventory);
assert(purchasedFreeOfCharge.current() <= freeQuota);
}
/**
@notice Enforces all purchase limits (counts and costs) before calling
_handlePurchase(), after which the received funds are disbursed to the
beneficiary, less any required refunds.
@param to The final recipient of the item(s).
@param requested The number of items requested for purchase, which MAY be
reduced when passed to _handlePurchase().
*/
function _purchase(address to, uint256 requested)
internal
nonReentrant
whenNotPaused
{
/**
* ##### CHECKS
*/
SellerConfig memory config = sellerConfig;
uint256 n = config.maxPerTx == 0
? requested
: Math.min(requested, config.maxPerTx);
uint256 maxAvailable = config.reserveFreeQuota
? config.totalInventory - config.freeQuota
: config.totalInventory;
n = Math.min(n, maxAvailable - _totalSold.current());
require(n > 0, "Seller: Sold out");
if (config.maxPerAddress > 0) {
bool alsoLimitSender = _msgSender() != to;
bool alsoLimitOrigin = tx.origin != _msgSender() && tx.origin != to;
n = _capExtra(n, to, "Buyer limit");
if (alsoLimitSender) {
n = _capExtra(n, _msgSender(), "Sender limit");
}
if (alsoLimitOrigin) {
n = _capExtra(n, tx.origin, "Origin limit");
}
_bought[to] += n;
if (alsoLimitSender) {
_bought[_msgSender()] += n;
}
if (alsoLimitOrigin) {
_bought[tx.origin] += n;
}
}
uint256 _cost = cost(n);
if (msg.value < _cost) {
revert(
string(
abi.encodePacked(
"Seller: Costs ",
(_cost / 1e9).toString(),
" GWei"
)
)
);
}
/**
* ##### EFFECTS
*/
_handlePurchase(to, n, false);
_totalSold.add(n);
assert(_totalSold.current() <= config.totalInventory);
/**
* ##### INTERACTIONS
*/
// Ideally we'd be using a PullPayment here, but the user experience is
// poor when there's a variable cost or the number of items purchased
// has been capped. We've addressed reentrancy with both a nonReentrant
// modifier and the checks, effects, interactions pattern.
if (_cost > 0) {
beneficiary.sendValue(_cost);
emit Revenue(beneficiary, n, _cost);
}
if (msg.value > _cost) {
address payable reimburse = payable(_msgSender());
uint256 refund = msg.value - _cost;
// Using Address.sendValue() here would mask the revertMsg upon
// reentrancy, but we want to expose it to allow for more precise
// testing. This otherwise uses the exact same pattern as
// Address.sendValue().
(bool success, bytes memory returnData) = reimburse.call{
value: refund
}("");
// Although `returnData` will have a spurious prefix, all we really
// care about is that it contains the ReentrancyGuard reversion
// message so we can check in the tests.
require(success, string(returnData));
emit Refund(reimburse, refund);
}
}
}
Monotonic.sol 48 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
/**
@notice Provides monotonic increasing and decreasing values, similar to
OpenZeppelin's Counter but (a) limited in direction, and (b) allowing for steps
> 1.
*/
library Monotonic {
/**
@notice Holds a value that can only increase.
@dev The internal value MUST NOT be accessed directly. Instead use current()
and add().
*/
struct Increaser {
uint256 value;
}
/// @notice Returns the current value of the Increaser.
function current(Increaser storage incr) internal view returns (uint256) {
return incr.value;
}
/// @notice Adds x to the Increaser's value.
function add(Increaser storage incr, uint256 x) internal {
incr.value += x;
}
/**
@notice Holds a value that can only decrease.
@dev The internal value MUST NOT be accessed directly. Instead use current()
and subtract().
*/
struct Decreaser {
uint256 value;
}
/// @notice Returns the current value of the Decreaser.
function current(Decreaser storage decr) internal view returns (uint256) {
return decr.value;
}
/// @notice Subtracts x from the Decreaser's value.
function subtract(Decreaser storage decr, uint256 x) internal {
decr.value -= x;
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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.0 (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);
}
ERC721Common.sol 71 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
import "./OpenSeaGasFreeListing.sol";
import "../utils/OwnerPausable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Pausable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
/**
@notice An ERC721 contract with common functionality:
- OpenSea gas-free listings
- OpenZeppelin Pausable
- OpenZeppelin Pausable with functions exposed to Owner only
*/
contract ERC721Common is Context, ERC721Pausable, OwnerPausable {
constructor(string memory name, string memory symbol)
ERC721(name, symbol)
{}
/// @notice Requires that the token exists.
modifier tokenExists(uint256 tokenId) {
require(ERC721._exists(tokenId), "ERC721Common: Token doesn't exist");
_;
}
/// @notice Requires that msg.sender owns or is approved for the token.
modifier onlyApprovedOrOwner(uint256 tokenId) {
require(
_isApprovedOrOwner(_msgSender(), tokenId),
"ERC721Common: Not approved nor owner"
);
_;
}
/// @notice Overrides _beforeTokenTransfer as required by inheritance.
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721Pausable) {
super._beforeTokenTransfer(from, to, tokenId);
}
/// @notice Overrides supportsInterface as required by inheritance.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
/**
@notice Returns true if either standard isApprovedForAll() returns true or
the operator is the OpenSea proxy for the owner.
*/
function isApprovedForAll(address owner, address operator)
public
view
virtual
override
returns (bool)
{
return
super.isApprovedForAll(owner, operator) ||
OpenSeaGasFreeListing.isApprovedForAll(owner, operator);
}
}
OwnerPausable.sol 19 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
/// @notice A Pausable contract that can only be toggled by the Owner.
contract OwnerPausable is Ownable, Pausable {
/// @notice Pauses the contract.
function pause() public onlyOwner {
Pausable._pause();
}
/// @notice Unpauses the contract.
function unpause() public onlyOwner {
Pausable._unpause();
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.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 `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
LinearDutchAuction.sol 127 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
import "./Seller.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
/// @notice A Seller with a linearly decreasing price.
abstract contract LinearDutchAuction is Seller {
/**
@param unit The unit of "time" used for decreasing prices, block number or
timestamp. NOTE: See the comment on AuctionIntervalUnit re use of Time as a
unit.
@param startPoint The block or timestamp at which the auction opens. A value
of zero disables the auction. See setAuctionStartPoint().
@param startPrice The price at `startPoint`.
@param decreaseInterval The number of units to wait before decreasing the
price. MUST be non-zero.
@param decreaseSize The amount by which price decreases after every
`decreaseInterval`.
@param numDecreases The maximum number of price decreases before remaining
constant. The reserve price is therefore implicit and equal to
startPrice-numDecrease*decreaseSize.
*/
struct DutchAuctionConfig {
uint256 startPoint;
uint256 startPrice;
uint256 decreaseInterval;
uint256 decreaseSize;
// From https://docs.soliditylang.org/en/v0.8.10/types.html#enums "Enums
// cannot have more than 256 members"; presumably they take 8 bits, so
// use some of the numDecreases space instead.
uint248 numDecreases;
AuctionIntervalUnit unit;
}
/**
@notice The unit of "time" along which the cost decreases.
@dev If no value is provided then the zero UNSPECIFIED will trigger an
error.
NOTE: The Block unit is more reliable as it has an explicit progression
(simply incrementing). Miners are allowed to have a time drift into the
future although which predisposes to unexpected behaviour by which "future"
costs are encountered. See the ConsenSys 15-second rule:
https://consensys.net/blog/developers/solidity-best-practices-for-smart-contract-security/
*/
enum AuctionIntervalUnit {
UNSPECIFIED,
Block,
Time
}
/// @param expectedReserve See setAuctionConfig().
constructor(
DutchAuctionConfig memory config,
uint256 expectedReserve,
Seller.SellerConfig memory sellerConfig,
address payable _beneficiary
) Seller(sellerConfig, _beneficiary) {
setAuctionConfig(config, expectedReserve);
}
/// @notice Configuration of price changes.
DutchAuctionConfig public dutchAuctionConfig;
/**
@notice Sets the auction config.
@param expectedReserve A safety check that the reserve, as calculated from
the config, is as expected.
*/
function setAuctionConfig(
DutchAuctionConfig memory config,
uint256 expectedReserve
) public onlyOwner {
// Underflow might occur is size/num decreases is too large.
unchecked {
require(
config.startPrice - config.decreaseSize * config.numDecreases ==
expectedReserve,
"LinearDutchAuction: incorrect reserve"
);
}
require(
config.unit != AuctionIntervalUnit.UNSPECIFIED,
"LinearDutchAuction: unspecified unit"
);
require(
config.decreaseInterval > 0,
"LinearDutchAuction: zero decrease interval"
);
dutchAuctionConfig = config;
}
/**
@notice Sets the config startPoint. A startPoint of zero disables the
auction.
@dev The auction can be toggle on and off with this function, without the
cost of having to update the entire config.
*/
function setAuctionStartPoint(uint256 startPoint) public onlyOwner {
dutchAuctionConfig.startPoint = startPoint;
}
/// @notice Override of Seller.cost() with Dutch-auction logic.
function cost(uint256 n) public view override returns (uint256) {
DutchAuctionConfig storage cfg = dutchAuctionConfig;
uint256 current;
if (cfg.unit == AuctionIntervalUnit.Block) {
current = block.number;
} else if (cfg.unit == AuctionIntervalUnit.Time) {
current = block.timestamp;
}
require(
cfg.startPoint != 0 && current >= cfg.startPoint,
"LinearDutchAuction: Not started"
);
uint256 decreases = Math.min(
(current - cfg.startPoint) / cfg.decreaseInterval,
cfg.numDecreases
);
return n * (cfg.startPrice - decreases * cfg.decreaseSize);
}
}
OpenSeaGasFreeListing.sol 45 lines
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;
// Inspired by BaseOpenSea by Simon Fremaux (@dievardump) but without the need
// to pass specific addresses depending on deployment network.
// https://gist.github.com/dievardump/483eb43bc6ed30b14f01e01842e3339b/
/// @notice Library to achieve gas-free listings on OpenSea.
library OpenSeaGasFreeListing {
/**
@notice Returns whether the operator is an OpenSea proxy for the owner, thus
allowing it to list without the token owner paying gas.
@dev ERC{721,1155}.isApprovedForAll should be overriden to also check if
this function returns true.
*/
function isApprovedForAll(address owner, address operator)
internal
view
returns (bool)
{
ProxyRegistry registry;
assembly {
switch chainid()
case 1 {
// mainnet
registry := 0xa5409ec958c83c3f309868babaca7c86dcb077c1
}
case 4 {
// rinkeby
registry := 0xf57b2c51ded3a29e6891aba85459d600256cf317
}
}
return
address(registry) != address(0) &&
address(registry.proxies(owner)) == operator;
}
}
contract OwnableDelegateProxy {}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
ERC721Pausable.sol 33 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Pausable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "../../../security/Pausable.sol";
/**
* @dev ERC721 token with pausable token transfers, minting and burning.
*
* Useful for scenarios such as preventing trades until the end of an evaluation
* period, or having an emergency switch for freezing all token transfers in the
* event of a large bug.
*/
abstract contract ERC721Pausable is ERC721, Pausable {
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*
* Requirements:
*
* - the contract must not be paused.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
require(!paused(), "ERC721Pausable: token transfer while paused");
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.0 (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
balanceOf 0x70a08231 → uint256
baseTokenURI 0xd547cfb7 → string
beneficiary 0x38af3eed → address
cost 0x9097548d → uint256
dutchAuctionConfig 0x7bd07f8b → uint256, uint256, uint256, uint256, uint248, uint8
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
sellerConfig 0xbb69b7ef → uint256, uint256, uint256, uint248, bool, bool, bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSold 0x9106d7ba → uint256
totalSupply 0x18160ddd → uint256
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
buy 0xa6f2ae3a
No parameters
pause 0x8456cb59
No parameters
purchaseFreeOfCharge 0xbf62e21d
address to
uint256 n
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
setAuctionConfig 0xf1deae82
tuple config
uint256 expectedReserve
setAuctionStartPoint 0xe0c5b0ed
uint256 startPoint
setBaseTokenURI 0x30176e13
string baseTokenURI_
setBeneficiary 0x1c31f710
address _beneficiary
setSellerConfig 0x343e1cd9
tuple config
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address