Address Contract Verified
Address
0x764AeebcF425d56800eF2c84F2578689415a2DAa
Balance
0 ETH
Nonce
1
Code Size
9950 bytes
Creator
0x9223abD7...729E at tx 0xc5529cd1...679e4c
Indexed Transactions
0
Contract Bytecode
9950 bytes
0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80638411a8f61161015c578063c5a1d7f0116100ce578063e985e9c511610087578063e985e9c5146105b2578063ed9aab51146105ee578063f2fde38b14610608578063f46eccc41461061b578063f47c84c51461063e578063f74f9bfd1461065f57600080fd5b8063c5a1d7f014610548578063c78f2e7b14610551578063c87b56dd14610564578063caa90c0314610577578063d76180ef1461057f578063e67a3b9a1461059f57600080fd5b8063ab7b499311610120578063ab7b4993146104df578063abd017ea146104f2578063ad7fa75114610506578063b3ab15fb1461051a578063b88d4fde1461052d578063bfc740841461054057600080fd5b80638411a8f6146104725780638da5cb5b146104a057806390578c81146104b157806395d89b41146104c4578063a22cb465146104cc57600080fd5b806346fff98d116102005780636352211e116101b95780636352211e1461040857806366caa6ab1461041b57806370a082311461042f578063715018a614610442578063753868e31461044a57806383ae3ec21461045257600080fd5b806346fff98d14610395578063471a4294146103a85780634f558e79146103bc57806351cff8d9146103cf57806355f804b3146103e2578063570ca735146103f557600080fd5b806323b872dd1161025257806323b872dd1461032e578063271a1746146103415780632f745c591461035457806342842e0e1461036757806342966c681461037a578063469c227b1461038d57600080fd5b806301ffc9a71461028f57806306fdde03146102b7578063081812fc146102cc578063095ea7b3146102f757806318160ddd1461030c575b600080fd5b6102a261029d366004611fb3565b610672565b60405190151581526020015b60405180910390f35b6102bf61069d565b6040516102ae9190612020565b6102df6102da366004612033565b61072f565b6040516001600160a01b0390911681526020016102ae565b61030a610305366004612068565b610756565b005b600954600160a01b90046001600160401b03165b6040519081526020016102ae565b61030a61033c366004612092565b610870565b61030a61034f3660046120ce565b6108a1565b610320610362366004612068565b610920565b61030a610375366004612092565b6109b6565b61030a610388366004612033565b6109d1565b61030a610a71565b61030a6103a33660046120f7565b610ae8565b600a546102a290600160e01b900460ff1681565b6102a26103ca366004612033565b610b63565b61030a6103dd3660046120ce565b610b82565b61030a6103f036600461219f565b610c9b565b6009546102df906001600160a01b031681565b6102df610416366004612033565b610cd2565b600a546102a290600160e81b900460ff1681565b61032061043d3660046120ce565b610d32565b61030a610db8565b61030a610dcc565b6104656104603660046120ce565b610e37565b6040516102ae91906121e7565b610485610480366004612033565b610ed8565b604080519384526020840192909252908201526060016102ae565b6008546001600160a01b03166102df565b61030a6104bf366004612033565b610f42565b6102bf610f72565b61030a6104da36600461222b565b610f81565b61030a6104ed3660046120ce565b610f8c565b600a546102a290600160f81b900460ff1681565b600a546102a290600160f01b900460ff1681565b61030a6105283660046120ce565b610fe8565b61030a61053b366004612262565b61106b565b6102bf6110a4565b610320600d5481565b61030a61055f36600461219f565b611132565b6102bf610572366004612033565b611169565b61030a6111d0565b61032061058d366004612033565b600f6020526000908152604090205481565b6103206105ad366004612068565b611247565b6102a26105c03660046122dd565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600a546102df90600160401b90046001600160a01b031681565b61030a6106163660046120ce565b611374565b6102a26106293660046120ce565b600e6020526000908152604090205460ff1681565b61064761753081565b6040516001600160401b0390911681526020016102ae565b600a54610647906001600160401b031681565b60006001600160e01b03198216632f745c5960e01b14806106975750610697826113ea565b92915050565b6060600080546106ac90612310565b80601f01602080910402602001604051908101604052809291908181526020018280546106d890612310565b80156107255780601f106106fa57610100808354040283529160200191610725565b820191906000526020600020905b81548152906001019060200180831161070857829003601f168201915b5050505050905090565b600061073a8261143a565b506000908152600460205260409020546001600160a01b031690565b600061076182610cd2565b9050806001600160a01b0316836001600160a01b0316036107d35760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806107ef57506107ef81336105c0565b6108615760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016107ca565b61086b8383611499565b505050565b61087a3382611507565b6108965760405162461bcd60e51b81526004016107ca9061234a565b61086b838383611586565b6009546001600160a01b031633146108cc576040516337fa462360e11b815260040160405180910390fd5b600a54600160f01b900460ff16156108f75760405163af9e1b4360e01b815260040160405180910390fd5b6001600160a01b03166000908152600e60205260409020805460ff19811660ff90911615179055565b600061092b83610d32565b821061098d5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016107ca565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61086b8383836040518060200160405280600081525061106b565b600a54600160e81b900460ff166109fb576040516303bdce4d60e51b815260040160405180910390fd5b610a048161172d565b610a215760405163aa2a4f3160e01b815260040160405180910390fd5b60098054601490610a4190600160a01b90046001600160401b03166123ae565b91906101000a8154816001600160401b0302191690836001600160401b03160217905550610a6e81611784565b50565b6009546001600160a01b03163314610a9c576040516337fa462360e11b815260040160405180910390fd5b600a54600160f01b900460ff1615610ac75760405163af9e1b4360e01b815260040160405180910390fd5b600a805460ff60e81b198116600160e81b9182900460ff1615909102179055565b6009546001600160a01b03163314610b13576040516337fa462360e11b815260040160405180910390fd5b600a54600160401b90046001600160a01b0316610b435760405163611ee86360e11b815260040160405180910390fd5b600a8054911515600160f81b026001600160f81b03909216919091179055565b6000818152600260205260408120546001600160a01b03161515610697565b6009546001600160a01b03163314610bad576040516337fa462360e11b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610bf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1891906123d1565b90508015610c975760095460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018390529083169063a9059cbb906044016020604051808303816000875af1158015610c73573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086b91906123ea565b5050565b6009546001600160a01b03163314610cc6576040516337fa462360e11b815260040160405180910390fd5b600b610c978282612455565b6000818152600260205260408120546001600160a01b0316806106975760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016107ca565b60006001600160a01b038216610d9c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016107ca565b506001600160a01b031660009081526003602052604090205490565b610dc061182b565b610dca6000611885565b565b6009546001600160a01b03163314610df7576040516337fa462360e11b815260040160405180910390fd5b600a54600160e01b900460ff1615610e2257604051634d9e996560e11b815260040160405180910390fd5b600a805460ff60f01b1916600160f01b179055565b60606000610e4483610d32565b90506000816001600160401b03811115610e6057610e60612114565b604051908082528060200260200182016040528015610e89578160200160208202803683370190505b50905060005b82811015610ed057610ea18582610920565b828281518110610eb357610eb3612514565b602090810291909101015280610ec88161252a565b915050610e8f565b509392505050565b600081815260026020526040812054819081906001600160a01b0316610f11576040516316d64dd960e11b815260040160405180910390fd5b5050506000908152600f602052604090819020546001600160401b03808216939282901c81169260809290921c1690565b6009546001600160a01b03163314610f6d576040516337fa462360e11b815260040160405180910390fd5b600d55565b6060600180546106ac90612310565b610c973383836118d7565b6009546001600160a01b03163314610fb7576040516337fa462360e11b815260040160405180910390fd5b600a80546001600160a01b03909216600160401b0268010000000000000000600160e01b0319909216919091179055565b610ff061182b565b6001600160a01b03811661101757604051637652539b60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527f4721129e0e676ed6a92909bb24e853ccdd63ad72280cc2e974e38e480e0e6e549060200160405180910390a150565b611076335b83611507565b6110925760405162461bcd60e51b81526004016107ca9061234a565b61109e848484846119a5565b50505050565b600c80546110b190612310565b80601f01602080910402602001604051908101604052809291908181526020018280546110dd90612310565b801561112a5780601f106110ff5761010080835404028352916020019161112a565b820191906000526020600020905b81548152906001019060200180831161110d57829003601f168201915b505050505081565b6009546001600160a01b0316331461115d576040516337fa462360e11b815260040160405180910390fd5b600c610c978282612455565b60606111748261143a565b600061117e6119d8565b9050600081511161119e57604051806020016040528060008152506111c9565b806111a8846119e7565b6040516020016111b9929190612543565b6040516020818303038152906040525b9392505050565b6009546001600160a01b031633146111fb576040516337fa462360e11b815260040160405180910390fd5b600a54600160f01b900460ff16156112265760405163af9e1b4360e01b815260040160405180910390fd5b600a805460ff60e01b198116600160e01b9182900460ff1615909102179055565b600a54600090600160e01b900460ff166112745760405163fbfb610360e01b815260040160405180910390fd5b600954617530600160a01b9091046001600160401b0316106112a95760405163adb00a1760e01b815260040160405180910390fd5b336000908152600e602052604090205460ff166112d95760405163bc88519760e01b815260040160405180910390fd5b600a80546001600160401b03169060006112f283612572565b91906101000a8154816001600160401b0302191690836001600160401b031602179055506009601481819054906101000a90046001600160401b031661133790612572565b82546001600160401b039182166101009390930a92830291909202199091161790556000818152600f602052604090208390556111c98482611ae7565b61137c61182b565b6001600160a01b0381166113e15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107ca565b610a6e81611885565b60006001600160e01b031982166380ac58cd60e01b148061141b57506001600160e01b03198216635b5e139f60e01b145b8061069757506301ffc9a760e01b6001600160e01b0319831614610697565b6000818152600260205260409020546001600160a01b0316610a6e5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016107ca565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906114ce82610cd2565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061151383610cd2565b9050806001600160a01b0316846001600160a01b0316148061155a57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061157e5750836001600160a01b03166115738461072f565b6001600160a01b0316145b949350505050565b826001600160a01b031661159982610cd2565b6001600160a01b0316146115fd5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016107ca565b6001600160a01b03821661165f5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107ca565b61166a838383611b01565b611675600082611499565b6001600160a01b038316600090815260036020526040812080546001929061169e908490612598565b90915550506001600160a01b03821660009081526003602052604081208054600192906116cc9084906125ab565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a54600090600160f01b900460ff161580156117595750336000908152600e602052604090205460ff165b1561176657506001919050565b61176f33611070565b1561177c57506001919050565b506000919050565b600061178f82610cd2565b905061179d81600084611b01565b6117a8600083611499565b6001600160a01b03811660009081526003602052604081208054600192906117d1908490612598565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6008546001600160a01b03163314610dca5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ca565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316036119385760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107ca565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6119b0848484611586565b6119bc84848484611b33565b61109e5760405162461bcd60e51b81526004016107ca906125be565b6060600b80546106ac90612310565b606081600003611a0e5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115611a385780611a228161252a565b9150611a319050600a83612626565b9150611a12565b6000816001600160401b03811115611a5257611a52612114565b6040519080825280601f01601f191660200182016040528015611a7c576020820181803683370190505b5090505b841561157e57611a91600183612598565b9150611a9e600a8661263a565b611aa99060306125ab565b60f81b818381518110611abe57611abe612514565b60200101906001600160f81b031916908160001a905350611ae0600a86612626565b9450611a80565b610c97828260405180602001604052806000815250611c34565b611b0a33611c67565b15611b1a5761086b838383611cfc565b604051631eb49d6d60e11b815260040160405180910390fd5b60006001600160a01b0384163b15611c2957604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611b7790339089908890889060040161264e565b6020604051808303816000875af1925050508015611bb2575060408051601f3d908101601f19168201909252611baf9181019061268b565b60015b611c0f573d808015611be0576040519150601f19603f3d011682016040523d82523d6000602084013e611be5565b606091505b508051600003611c075760405162461bcd60e51b81526004016107ca906125be565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061157e565b506001949350505050565b611c3e8383611d6e565b611c4b6000848484611b33565b61086b5760405162461bcd60e51b81526004016107ca906125be565b600a54600090600160f81b900460ff1615611cf457600a546040516370c5e04560e11b81526001600160a01b038481166004830152600160401b90920490911690819063e18bc08a90602401602060405180830381865afa158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c991906123ea565b506001919050565b6001600160a01b03831615801590611d265750816001600160a01b0316836001600160a01b031614155b15611d3557611d358382611ebc565b6001600160a01b03821615801590611d5f5750826001600160a01b0316826001600160a01b031614155b1561086b5761086b8282611f59565b6001600160a01b038216611dc45760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107ca565b6000818152600260205260409020546001600160a01b031615611e295760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107ca565b611e3560008383611b01565b6001600160a01b0382166000908152600360205260408120805460019290611e5e9084906125ab565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001611ec984610d32565b611ed39190612598565b600083815260076020526040902054909150808214611f26576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6000611f6483610d32565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610a6e57600080fd5b600060208284031215611fc557600080fd5b81356111c981611f9d565b60005b83811015611feb578181015183820152602001611fd3565b50506000910152565b6000815180845261200c816020860160208601611fd0565b601f01601f19169290920160200192915050565b6020815260006111c96020830184611ff4565b60006020828403121561204557600080fd5b5035919050565b80356001600160a01b038116811461206357600080fd5b919050565b6000806040838503121561207b57600080fd5b6120848361204c565b946020939093013593505050565b6000806000606084860312156120a757600080fd5b6120b08461204c565b92506120be6020850161204c565b9150604084013590509250925092565b6000602082840312156120e057600080fd5b6111c98261204c565b8015158114610a6e57600080fd5b60006020828403121561210957600080fd5b81356111c9816120e9565b634e487b7160e01b600052604160045260246000fd5b60006001600160401b038084111561214457612144612114565b604051601f8501601f19908116603f0116810190828211818310171561216c5761216c612114565b8160405280935085815286868601111561218557600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156121b157600080fd5b81356001600160401b038111156121c757600080fd5b8201601f810184136121d857600080fd5b61157e8482356020840161212a565b6020808252825182820181905260009190848201906040850190845b8181101561221f57835183529284019291840191600101612203565b50909695505050505050565b6000806040838503121561223e57600080fd5b6122478361204c565b91506020830135612257816120e9565b809150509250929050565b6000806000806080858703121561227857600080fd5b6122818561204c565b935061228f6020860161204c565b92506040850135915060608501356001600160401b038111156122b157600080fd5b8501601f810187136122c257600080fd5b6122d18782356020840161212a565b91505092959194509250565b600080604083850312156122f057600080fd5b6122f98361204c565b91506123076020840161204c565b90509250929050565b600181811c9082168061232457607f821691505b60208210810361234457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60006001600160401b038216806123c7576123c7612398565b6000190192915050565b6000602082840312156123e357600080fd5b5051919050565b6000602082840312156123fc57600080fd5b81516111c9816120e9565b601f82111561086b57600081815260208120601f850160051c8101602086101561242e5750805b601f850160051c820191505b8181101561244d5782815560010161243a565b505050505050565b81516001600160401b0381111561246e5761246e612114565b6124828161247c8454612310565b84612407565b602080601f8311600181146124b7576000841561249f5750858301515b600019600386901b1c1916600185901b17855561244d565b600085815260208120601f198616915b828110156124e6578886015182559484019460019091019084016124c7565b50858210156125045787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052603260045260246000fd5b60006001820161253c5761253c612398565b5060010190565b60008351612555818460208801611fd0565b835190830190612569818360208801611fd0565b01949350505050565b60006001600160401b0380831681810361258e5761258e612398565b6001019392505050565b8181038181111561069757610697612398565b8082018082111561069757610697612398565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261263557612635612610565b500490565b60008261264957612649612610565b500690565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061268190830184611ff4565b9695505050505050565b60006020828403121561269d57600080fd5b81516111c981611f9d56fea2646970667358221220977b677008d5bc6c5c10639c9e06f198ad41f3576431733a36b6427257dd879f64736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
Operator.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
error OnlyOperatorError();
error OperatorZeroAddressCheck();
contract Operator is Ownable {
address public operator;
event OperatorChanged(address operator);
modifier onlyOperator() {
if (operator != _msgSender()) revert OnlyOperatorError();
_;
}
constructor(address _operator) {
if (_operator == address(0)) revert OperatorZeroAddressCheck();
operator = _operator;
}
/**
* @notice change operator
*/
function setOperator(address _operator) external onlyOwner {
if (_operator == address(0)) revert OperatorZeroAddressCheck();
operator = _operator;
emit OperatorChanged(_operator);
}
}
BAYCSewerPass.sol 295 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./lib/ERC721EnumerableMod.sol";
import "./lib/Operator.sol";
import "./lib/IRegistry.sol";
// |||||\ |||||\ |||||\ |||||\
// ||||| | ||||| | ||||| | ||||| |
// \__|||||\ |||||\___\| \__|||||\ |||||\___\|
// ||||| | ||||| | ||||| | ||||| |
// \__|||||\___\| Y u g a \__|||||\___\|
// ||||| | L a b s ||||| |
// |||||\___\| Sewer Pass |||||\___\|
// ||||| | ||||| |
// \__|||||||||||\ \__|||||||||||\
// ||||||||||| | ||||||||||| |
// \_________\| \_________\|
error MintIsNotActive();
error BurnIsNotActive();
error UnauthorizedOwnerOfToken();
error NotAllowedToMint();
error ContractIsLocked();
error UnableToLockContract();
error MaxTokensMinted();
error TokenIdDoesNotExist();
error RegistryAddressIsNotSet();
/**
* @title BAYC Sewer Pass ERC-721 Smart Contract
*/
contract BAYCSewerPass is ERC721EnumerableMod, Operator {
uint64 private _totalSupply;
uint64 public mintIndex;
uint64 public constant MAX_TOKENS = 30000;
address public registryAddress;
bool public mintIsActive;
bool public burnIsActive;
bool public contractIsLocked;
bool public isRegistryActive;
string private baseURI;
string public nftLicenseTerms = "https://mdvmm.xyz/license";
bytes32 public metadataHash;
mapping(address => bool) public minters;
mapping(uint256 => uint256) public tokenIdtoMintData;
constructor(
string memory name,
string memory symbol,
address operator
) ERC721(name, symbol) Operator(operator) {}
/**
* @notice Mint a Sewer Pass
* can only be called by approved contracts
* @param to address of minting contract
* @param mintData data from the token mint stored in uint256
* | dogTokenId | apeTokenId | tier |
* 192 128 64 0
*/
function mintSewerPass(
address to,
uint256 mintData
) external returns (uint256) {
if (!mintIsActive) revert MintIsNotActive();
if (_totalSupply >= MAX_TOKENS) revert MaxTokensMinted();
if (!minters[_msgSender()]) revert NotAllowedToMint();
uint256 _mintIndex = mintIndex;
++mintIndex;
++_totalSupply;
tokenIdtoMintData[_mintIndex] = mintData;
_safeMint(to, _mintIndex);
return _mintIndex;
}
/**
* @notice Get the data from token mint by token id
* @param tokenId the token id
* @return tier game pass tier
* @return apeTokenId tier 1 & 2 mayc token id, tier 3 & 4 bayc token id
* @return dogTokenId bakc token id, if 10000 dog was not used in claim
*/
function getMintDataByTokenId(
uint256 tokenId
)
external
view
returns (uint256 tier, uint256 apeTokenId, uint256 dogTokenId)
{
if (!_exists(tokenId)) revert TokenIdDoesNotExist();
uint256 mintData = tokenIdtoMintData[tokenId];
tier = uint256(uint64(mintData));
apeTokenId = uint256(uint64(mintData >> 64));
dogTokenId = uint256(uint64(mintData >> 128));
}
/**
* @notice Get token ids by wallet
* @param _owner the address of the owner
*/
function tokenIdsByWallet(
address _owner
) external view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](tokenCount);
for (uint256 i; i < tokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
/**
* @notice Check if a token exists
*/
function exists(uint256 tokenId) external view returns (bool) {
return _exists(tokenId);
}
/**
* @notice Get the total supply of tokens
*/
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
// operator functions
/**
* @notice Flip mint state
*/
function flipMintIsActiveState() external onlyOperator {
if (contractIsLocked) revert ContractIsLocked();
mintIsActive = !mintIsActive;
}
/**
* @notice Flip burn state
*/
function flipBurnIsActiveState() external onlyOperator {
if (contractIsLocked) revert ContractIsLocked();
burnIsActive = !burnIsActive;
}
/**
* @notice Lock the contract - stops minting, contract burn,
* flipping burn state, and adding minter contracts
* KILL SWITCH - THIS CAN'T BE REVERSED
*/
function lockContract() external onlyOperator {
if (mintIsActive) revert UnableToLockContract();
contractIsLocked = true;
}
/**
* @notice Set base uri of metadata
* @param uri the base uri of the metadata store
*/
function setBaseURI(string memory uri) external onlyOperator {
baseURI = uri;
}
/**
* @notice Toggle the minting ability of a minter contract
* @param _minterContract address of contract
*/
function toggleMinterContract(
address _minterContract
) external onlyOperator {
if (contractIsLocked) revert ContractIsLocked();
minters[_minterContract] = !minters[_minterContract];
}
/**
* @notice Set the metadata provenance hash
* @param _metadataHash hash of metadata
*/
function setMetadataHash(bytes32 _metadataHash) external onlyOperator {
metadataHash = _metadataHash;
}
/**
* @notice Set NFT License URI
* @param _nftLicenseUri the uri to license
*/
function setNftLicenseTerms(
string memory _nftLicenseUri
) external onlyOperator {
nftLicenseTerms = _nftLicenseUri;
}
/**
* @notice Withdraw erc-20 tokens sent to the contract by error
* @param coinContract the erc-20 contract address
*/
function withdraw(address coinContract) external onlyOperator {
uint256 balance = IERC20(coinContract).balanceOf(address(this));
if (balance > 0) {
IERC20(coinContract).transfer(operator, balance);
}
}
/**
* @notice Set the registry contract
* @param _registryAddress Contract address for registry
*/
function setRegistryAddress(
address _registryAddress
) external onlyOperator {
registryAddress = _registryAddress;
}
/**
* @param isActive Enables or disables the registry
*/
function setIsRegistryActive(bool isActive) external onlyOperator {
if (registryAddress == address(0)) revert RegistryAddressIsNotSet();
isRegistryActive = isActive;
}
// Internal function
/**
* @notice Checks whether caller is valid on the registry
*/
function _isValidAgainstRegistry(
address operator
) internal view returns (bool) {
if (isRegistryActive) {
IRegistry registry = IRegistry(registryAddress);
return registry.isAllowedOperator(operator);
}
return true;
}
// Function overrides
/**
* @notice override _baseURI function
*/
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
/**
* @notice Overrides beforeTokenTransfer and triggers before any transfer
* @param from From address
* @param to Address being transfered to
* @param tokenId Token id being transferred
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
if (_isValidAgainstRegistry(msg.sender)) {
super._beforeTokenTransfer(from, to, tokenId);
} else {
revert IRegistry.NotAllowed();
}
}
// Token burning
/**
* @notice check if sender is approved to burn token
* includes token ownership and contract burn checks
* @param tokenId token id to check for burn approval
*/
function _isApprovedToBurn(uint256 tokenId) private view returns (bool) {
if (!contractIsLocked && minters[_msgSender()]) {
return true;
} else if (_isApprovedOrOwner(_msgSender(), tokenId)) {
return true;
}
return false;
}
/**
* @notice burn the token
* @param tokenId token id to burn
*/
function burn(uint256 tokenId) public virtual {
if (!burnIsActive) revert BurnIsNotActive();
if (!_isApprovedToBurn(tokenId)) revert UnauthorizedOwnerOfToken();
--_totalSupply;
_burn(tokenId);
}
}
IRegistry.sol 34 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
/**
* @dev Required interface of an Registry compliant contract.
*/
interface IRegistry {
/**
* @dev Emitted when address trying to transfer is not allowed on the registry
*/
error NotAllowed();
/**
* @dev Checks whether `operator` is valid on the registry; let the registry
* decide across both allow and blocklists.
* @param operator - Address of operator
* @return Bool whether operator is valid against registry
*/
function isAllowedOperator(address operator) external view returns (bool);
/**
* @dev Checks whether `operator` is allowed on the registry
* @param operator - Address of operator
* @return Bool whether operator is allowed
*/
function isAllowed(address operator) external view returns (bool);
/**
* @dev Checks whether `operator` is blocked on the registry
* @param operator - Address of operator
* @return Bool whether operator is blocked
*/
function isBlocked(address operator) external view returns (bool);
}
ERC721EnumerableMod.sol 118 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC721EnumerableMod.sol";
/**
* @dev gas optimized version of the OpenZepplin ERC721Enumerable Extension -
* This implements a partial optional extension of {ERC721} defined in the EIP that:
* keeps - enumerability of all the token ids owned by each account.
* removes - enumerability of all the token ids in the contract and totalSupply function
* WARNING: You have to code your own totalSupply function
*/
abstract contract ERC721EnumerableMod is ERC721, IERC721EnumerableMod {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(IERC165, ERC721) returns (bool) {
return
interfaceId == type(IERC721EnumerableMod).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(
address owner,
uint256 index
) public view virtual override returns (uint256) {
require(
index < ERC721.balanceOf(owner),
"ERC721Enumerable: owner index out of bounds"
);
return _ownedTokens[owner][index];
}
/**
* @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` cannot be the zero address.
* - `to` cannot be the zero address.
*
* 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 override {
super._beforeTokenTransfer(from, to, tokenId);
if (from != address(0) && from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to != address(0) && to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(
address from,
uint256 tokenId
) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
}
IERC721EnumerableMod.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, partial implementation of
* optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721EnumerableMod is IERC721 {
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(
address owner,
uint256 index
) external view returns (uint256 tokenId);
}
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;
}
}
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);
}
}
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);
}
}
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);
}
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);
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
Read Contract
MAX_TOKENS 0xf47c84c5 → uint64
balanceOf 0x70a08231 → uint256
burnIsActive 0x66caa6ab → bool
contractIsLocked 0xad7fa751 → bool
exists 0x4f558e79 → bool
getApproved 0x081812fc → address
getMintDataByTokenId 0x8411a8f6 → uint256, uint256, uint256
isApprovedForAll 0xe985e9c5 → bool
isRegistryActive 0xabd017ea → bool
metadataHash 0xc5a1d7f0 → bytes32
mintIndex 0xf74f9bfd → uint64
mintIsActive 0x471a4294 → bool
minters 0xf46eccc4 → bool
name 0x06fdde03 → string
nftLicenseTerms 0xbfc74084 → string
operator 0x570ca735 → address
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
registryAddress 0xed9aab51 → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenIdsByWallet 0x83ae3ec2 → uint256[]
tokenIdtoMintData 0xd76180ef → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 20 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
flipBurnIsActiveState 0x469c227b
No parameters
flipMintIsActiveState 0xcaa90c03
No parameters
lockContract 0x753868e3
No parameters
mintSewerPass 0xe67a3b9a
address to
uint256 mintData
returns: uint256
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
setBaseURI 0x55f804b3
string uri
setIsRegistryActive 0x46fff98d
bool isActive
setMetadataHash 0x90578c81
bytes32 _metadataHash
setNftLicenseTerms 0xc78f2e7b
string _nftLicenseUri
setOperator 0xb3ab15fb
address _operator
setRegistryAddress 0xab7b4993
address _registryAddress
toggleMinterContract 0x271a1746
address _minterContract
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x51cff8d9
address coinContract
Recent Transactions
No transactions found for this address