Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0xAD0db7368CDFbd3153F7dfaCA51A78Eeb39F6d71
Balance 0 ETH
Nonce 1
Code Size 16634 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

16634 bytes
0x6080604052600436106103f95760003560e01c806367bdeba711610213578063bd5e5e0c11610123578063e1c3ad0c116100ab578063e73a9a251161007a578063e73a9a2514610ad4578063e985e9c514610af4578063ee21123314610b3d578063f2fde38b14610b5d578063fd48354e14610b7d57600080fd5b8063e1c3ad0c14610a6d578063e3764a8b14610a8e578063e3f2f54b14610aa9578063e43437c814610abe57600080fd5b8063c87b56dd116100f2578063c87b56dd146109ec578063c973d72d14610a0c578063d0b77feb14610a22578063d7d0b41714610a37578063d91a0d5414610a5757600080fd5b8063bd5e5e0c1461098e578063bdce4bc9146109ae578063c0bb92ea146109c4578063c15e24bc146109d957600080fd5b80638da5cb5b116101a6578063a7f93ebd11610175578063a7f93ebd14610903578063accf4eb114610918578063b23142e214610938578063b88d4fde1461094e578063bc8893b41461096e57600080fd5b80638da5cb5b1461089657806395d89b41146108b45780639dc40c15146108c9578063a22cb465146108e357600080fd5b8063725ae16c116101e2578063725ae16c1461082e5780637565f25f14610844578063831fc3b4146108575780638ac1e1611461087657600080fd5b806367bdeba7146107d05780636bb7b1d9146107e357806370a08231146107f9578063715018a61461081957600080fd5b806331c3c7a01161030e57806354c06aee116102a157806357b8dc041161027057806357b8dc04146107375780635bfa60f61461075757806361169ea81461076d5780636352211e1461078357806366fca980146107a357600080fd5b806354c06aee146106cc57806355f804b3146106e2578063565f2bfe14610702578063567ac4f61461072257600080fd5b806342842e0e116102dd57806342842e0e14610662578063435f3b8e1461068257806348cd4f08146106975780634f6ccce7146106ac57600080fd5b806331c3c7a0146105f157806333c41a901461060d5780633a12e9331461062d5780633ccfd60b1461064d57600080fd5b80630c894cfe1161039157806322f76af31161036057806322f76af31461057057806323b872dd1461058657806324460778146105a65780632f2eda31146105bb5780632f745c59146105d157600080fd5b80630c894cfe1461051157806318160ddd146105265780631a8957411461053b57806322c69fe71461055b57600080fd5b8063081812fc116103cd578063081812fc14610481578063095ea7b3146104b95780630af7f2b8146104d95780630c41f497146104fc57600080fd5b8062dbabc7146103fe57806301ffc9a71461041557806306851cf11461044a57806306fdde031461045f575b600080fd5b34801561040a57600080fd5b50610413610b93565b005b34801561042157600080fd5b50610435610430366004613a99565b610dff565b60405190151581526020015b60405180910390f35b34801561045657600080fd5b50610413610e2a565b34801561046b57600080fd5b50610474610e68565b6040516104419190613cce565b34801561048d57600080fd5b506104a161049c366004613a80565b610efa565b6040516001600160a01b039091168152602001610441565b3480156104c557600080fd5b506104136104d4366004613a54565b610f82565b3480156104e557600080fd5b506104ee601481565b604051908152602001610441565b34801561050857600080fd5b50610413611098565b34801561051d57600080fd5b50610413611138565b34801561053257600080fd5b506008546104ee565b34801561054757600080fd5b50610413610556366004613a80565b611181565b34801561056757600080fd5b506024546104ee565b34801561057c57600080fd5b506104ee61138881565b34801561059257600080fd5b506104136105a1366004613960565b61136a565b3480156105b257600080fd5b506104ee600581565b3480156105c757600080fd5b506104ee60285481565b3480156105dd57600080fd5b506104ee6105ec366004613a54565b61139b565b3480156105fd57600080fd5b506104ee670214e8348c4f000081565b34801561061957600080fd5b50610435610628366004613a80565b611431565b34801561063957600080fd5b50610413610648366004613baf565b611497565b34801561065957600080fd5b5061041361156a565b34801561066e57600080fd5b5061041361067d366004613960565b6115b3565b34801561068e57600080fd5b506104136115ce565b3480156106a357600080fd5b506104ee611615565b3480156106b857600080fd5b506104ee6106c7366004613a80565b611632565b3480156106d857600080fd5b506104ee60225481565b3480156106ee57600080fd5b506104136106fd366004613ad3565b6116c5565b34801561070e57600080fd5b5061043561071d366004613a80565b611706565b34801561072e57600080fd5b506104ee611753565b34801561074357600080fd5b50610413610752366004613a80565b6117cd565b34801561076357600080fd5b506104ee601f5481565b34801561077957600080fd5b506104ee61138781565b34801561078f57600080fd5b506104a161079e366004613a80565b6117fc565b3480156107af57600080fd5b506104ee6107be3660046138ed565b601e6020526000908152604090205481565b6104136107de366004613b35565b611873565b3480156107ef57600080fd5b506104ee60265481565b34801561080557600080fd5b506104ee6108143660046138ed565b611bd8565b34801561082557600080fd5b50610413611c5f565b34801561083a57600080fd5b506104ee60295481565b610413610852366004613b35565b611c95565b34801561086357600080fd5b5060275461043590610100900460ff1681565b34801561088257600080fd5b50610413610891366004613a80565b611f45565b3480156108a257600080fd5b50600a546001600160a01b03166104a1565b3480156108c057600080fd5b50610474611f74565b3480156108d557600080fd5b506027546104359060ff1681565b3480156108ef57600080fd5b506104136108fe366004613a21565b611f83565b34801561090f57600080fd5b506104ee611f8e565b34801561092457600080fd5b50610413610933366004613a80565b61202e565b34801561094457600080fd5b506104ee602a5481565b34801561095a57600080fd5b506104136109693660046139a1565b61205d565b34801561097a57600080fd5b506027546104359062010000900460ff1681565b34801561099a57600080fd5b506104ee6109a9366004613bd1565b612095565b3480156109ba57600080fd5b506104ee60205481565b3480156109d057600080fd5b506104ee601581565b6104136109e7366004613a80565b61216b565b3480156109f857600080fd5b50610474610a07366004613a80565b612395565b348015610a1857600080fd5b506104ee60235481565b348015610a2e57600080fd5b5061041361245f565b348015610a4357600080fd5b50610413610a52366004613a80565b6124aa565b348015610a6357600080fd5b506104ee60215481565b348015610a7957600080fd5b50602754610435906301000000900460ff1681565b348015610a9a57600080fd5b506104ee662386f26fc1000081565b348015610ab557600080fd5b506104ee600181565b348015610aca57600080fd5b506104ee60245481565b348015610ae057600080fd5b50610413610aef366004613baf565b6124d9565b348015610b0057600080fd5b50610435610b0f366004613927565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b348015610b4957600080fd5b50610435610b58366004613bfd565b612988565b348015610b6957600080fd5b50610413610b783660046138ed565b6129cf565b348015610b8957600080fd5b506104ee60255481565b60295415610bfd5760405162461bcd60e51b815260206004820152602c60248201527f4d696e746564204d7574616e7473207374617274696e6720696e64657820697360448201526b08185b1c9958591e481cd95d60a21b60648201526084015b60405180910390fd5b602a5415610c605760405162461bcd60e51b815260206004820152602a60248201527f4d656761204d7574616e7473207374617274696e6720696e64657820697320616044820152691b1c9958591e481cd95d60b21b6064820152608401610bf4565b602854610caf5760405162461bcd60e51b815260206004820181905260248201527f5374617274696e6720696e64657820626c6f636b206d757374206265207365746044820152606401610bf4565b6000610cb9612a67565b90506025548110158015610ccf57506000602654115b610d295760405162461bcd60e51b815260206004820152602560248201527f496e76616c6964207365745374617274696e67496e646963657320636f6e646960448201526474696f6e7360d81b6064820152608401610bf4565b610d37602854611388612a85565b602955602854610d48906015612a85565b602a5560285460ff90610d5b9043613f5c565b1115610d9357610d77610d6f600143613f5c565b611388612a85565b602955610d8f610d88600143613f5c565b6015612a85565b602a555b602954610db05760298054906000610daa83613ffc565b91905055505b602a54610dcd57602a8054906000610dc783613ffc565b91905055505b602a546029546040517f78350484f1ffcc8f055a7c88028cb214465df9c18d7d2b8c6584ab2389c4bceb90600090a350565b60006001600160e01b0319821663780e9d6360e01b1480610e245750610e2482612a92565b92915050565b600a546001600160a01b03163314610e545760405162461bcd60e51b8152600401610bf490613e54565b6027805460ff19811660ff90911615179055565b606060008054610e7790613f9f565b80601f0160208091040260200160405190810160405280929190818152602001828054610ea390613f9f565b8015610ef05780601f10610ec557610100808354040283529160200191610ef0565b820191906000526020600020905b815481529060010190602001808311610ed357829003601f168201915b5050505050905090565b6000610f0582612ae2565b610f665760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610bf4565b506000908152600460205260409020546001600160a01b031690565b6000610f8d826117fc565b9050806001600160a01b0316836001600160a01b03161415610ffb5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610bf4565b336001600160a01b038216148061101757506110178133610b0f565b6110895760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610bf4565b6110938383612aff565b505050565b600a546001600160a01b031633146110c25760405162461bcd60e51b8152600401610bf490613e54565b60275462010000900460ff166110ea5760405162461bcd60e51b8152600401610bf490613dd2565b60006110f4611f8e565b6027805462ff000019169055905061110a612a67565b60405182907f11be19c514ca2377de0ba482bedfd33a9a262050819cf2b8bc52c04298447f3090600090a350565b600a546001600160a01b031633146111625760405162461bcd60e51b8152600401610bf490613e54565b6027805462ff0000198116620100009182900460ff1615909102179055565b6002600b5414156111a45760405162461bcd60e51b8152600401610bf490613eda565b6002600b556027546301000000900460ff166112025760405162461bcd60e51b815260206004820152601c60248201527f536572756d204d75746174696f6e206973206e6f7420616374697665000000006044820152606401610bf4565b6040516331a9108f60e11b81526004810182905233906001600160a01b037f0000000000000000000000004b103d07c18798365946e76845edc6b5657794021690636352211e9060240160206040518083038186803b15801561126457600080fd5b505afa158015611278573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061129c919061390a565b6001600160a01b0316146112c25760405162461bcd60e51b8152600401610bf490613ce1565b6112cb81611706565b156113245760405162461bcd60e51b8152602060048201526024808201527f4120736572756d20697320726571756972656420666f722074686973204772616044820152636e64706160e01b6064820152608401610bf4565b600061132f82612b6d565b905061133a81612ae2565b156113575760405162461bcd60e51b8152600401610bf490613e09565b6113613382612b92565b50506001600b55565b6113743382612bac565b6113905760405162461bcd60e51b8152600401610bf490613e89565b611093838383612c92565b60006113a683611bd8565b82106114085760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610bf4565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6000613aac821061148e5760405162461bcd60e51b815260206004820152602160248201527f746f6b656e4964206f75747369646520636f6c6c656374696f6e20626f756e646044820152607360f81b6064820152608401610bf4565b610e2482612ae2565b600a546001600160a01b031633146114c15760405162461bcd60e51b8152600401610bf490613e54565b60275462010000900460ff161561151a5760405162461bcd60e51b815260206004820152601d60248201527f5075626c69632073616c652068617320616c726561647920626567756e0000006044820152606401610bf4565b602582905560238190554260268190556027805462ff000019166201000017905560405183907fe7a2bd41b03361b062f9a965bb9dab248ea91b878e26faf49eabd35df4a2c4d190600090a35050565b600a546001600160a01b031633146115945760405162461bcd60e51b8152600401610bf490613e54565b476115b06115aa600a546001600160a01b031690565b82612e39565b50565b6110938383836040518060200160405280600081525061205d565b600a546001600160a01b031633146115f85760405162461bcd60e51b8152600401610bf490613e54565b6027805461ff001981166101009182900460ff1615909102179055565b600060245461162360085490565b61162d9190613f5c565b905090565b600061163d60085490565b82106116a05760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610bf4565b600882815481106116b3576116b361406d565b90600052602060002001549050919050565b600a546001600160a01b031633146116ef5760405162461bcd60e51b8152600401610bf490613e54565b805161170290602d906020840190613785565b5050565b6000805b601281101561174a57600c81601281106117265761172661406d565b01548314156117385750600092915050565b8061174281613ffc565b91505061170a565b50600192915050565b600080602654116117a65760405162461bcd60e51b815260206004820152601e60248201527f5075626c69632073616c65206861736e277420737461727465642079657400006044820152606401610bf4565b6025546117b1612a67565b106117bc5750600090565b426025546026546116239190613f11565b600a546001600160a01b031633146117f75760405162461bcd60e51b8152600401610bf490613e54565b601f55565b6000818152600260205260408120546001600160a01b031680610e245760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610bf4565b6002600b5414156118965760405162461bcd60e51b8152600401610bf490613eda565b6002600b5560275460ff6101009091041615156001146118f85760405162461bcd60e51b815260206004820152601e60248201527f57686974656c6973742053616c6520686173206e6f74207374617274656400006044820152606401610bf4565b600085116119485760405162461bcd60e51b815260206004820152601d60248201527f4d757374206d696e74206174206c65617374206f6e65206d7574616e740000006044820152606401610bf4565b6119af8484808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060225460405190925061199491503390602001613c45565b60405160208183030381529060405280519060200120612f52565b151560011480611a0c5750611a068282808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060215460405190925061199491503390602001613c45565b15156001145b611a585760405162461bcd60e51b815260206004820152601e60248201527f5468652061646472657373206973206e6f742077686974656c697374656400006044820152606401610bf4565b600060019050611aaa8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505060215460405190925061199491503390602001613c45565b151560011415611ab8575060055b336000908152601e60205260409020548190611ad5908890613f11565b1115611af35760405162461bcd60e51b8152600401610bf490613d7f565b6000611b0787670214e8348c4f0000613f3d565b905034811115611b595760405162461bcd60e51b815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f7272656374006044820152606401610bf4565b60005b87811015611bc957602454611388811015611bb65760248054906000611b8183613ffc565b9190505550611b903382612b92565b336000908152601e60205260408120805460019290611bb0908490613f11565b90915550505b5080611bc181613ffc565b915050611b5c565b50506001600b55505050505050565b60006001600160a01b038216611c435760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610bf4565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314611c895760405162461bcd60e51b8152600401610bf490613e54565b611c936000612f68565b565b6002600b541415611cb85760405162461bcd60e51b8152600401610bf490613eda565b6002600b5560275460ff161515600114611d205760405162461bcd60e51b815260206004820152602360248201527f467265652057686974656c697374204d696e7420686173206e6f7420737461726044820152621d195960ea1b6064820152608401610bf4565b611d6c84848080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050601f5460405190925061199491503390602001613c45565b151560011480611dc85750611dc282828080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050602080546040519093506119949250339101613c45565b15156001145b611e2d5760405162461bcd60e51b815260206004820152603060248201527f5468652061646472657373206973206e6f742077686974656c6973746564206660448201526f1bdc881d1a1948199c9959481b5a5b9d60821b6064820152608401610bf4565b600060019050611e7e83838080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050602080546040519093506119949250339101613c45565b151560011415611e8c575060055b336000908152601e60205260409020548190611ea9908890613f11565b1115611ec75760405162461bcd60e51b8152600401610bf490613d7f565b60005b86811015611f3757602454611388811015611f245760248054906000611eef83613ffc565b9190505550611efe3382612b92565b336000908152601e60205260408120805460019290611f1e908490613f11565b90915550505b5080611f2f81613ffc565b915050611eca565b50506001600b555050505050565b600a546001600160a01b03163314611f6f5760405162461bcd60e51b8152600401610bf490613e54565b602255565b606060018054610e7790613f9f565b611702338383612fba565b60275460009062010000900460ff16611fb95760405162461bcd60e51b8152600401610bf490613dd2565b6000611fc3612a67565b90506025548110611fdc57662386f26fc1000091505090565b60255460235460009190611ff08483613f5c565b611ffa9190613f3d565b6120049190613f29565b9050662386f26fc10000811161202157662386f26fc10000612023565b805b9250505090565b5090565b600a546001600160a01b031633146120585760405162461bcd60e51b8152600401610bf490613e54565b602155565b6120673383612bac565b6120835760405162461bcd60e51b8152600401610bf490613e89565b61208f84848484613089565b50505050565b60008060458360ff1614156120ff57506000838152602c6020526040902054806120fa5760405162461bcd60e51b8152602060048201526016602482015275125b9d985b1a5908135151d048135d5d185b9d08125960521b6044820152606401610bf4565b61210f565b61210c8360ff16856130bc565b90505b61211881612ae2565b6121645760405162461bcd60e51b815260206004820152601c60248201527f517565727920666f72206e6f6e6578697374656e74206d7574616e74000000006044820152606401610bf4565b9392505050565b60275462010000900460ff166121935760405162461bcd60e51b8152600401610bf490613dd2565b6002600b5414156121b65760405162461bcd60e51b8152600401610bf490613eda565b6002600b55602454611388906121cd908390613f11565b111561221b5760405162461bcd60e51b815260206004820152601f60248201527f4d696e74696e6720776f756c6420657863656564206d617820737570706c79006044820152606401610bf4565b6000811161226b5760405162461bcd60e51b815260206004820152601d60248201527f4d757374206d696e74206174206c65617374206f6e65206d7574616e740000006044820152606401610bf4565b60148111156122bc5760405162461bcd60e51b815260206004820181905260248201527f526571756573746564206e756d6265722065786365656473206d6178696d756d6044820152606401610bf4565b6000816122c7611f8e565b6122d19190613f3d565b9050348111156123235760405162461bcd60e51b815260206004820152601f60248201527f45746865722076616c75652073656e74206973206e6f7420636f7272656374006044820152606401610bf4565b60295461232f57436028555b60005b8281101561237957602454611388811015612366576024805490600061235783613ffc565b91905055506123663382612b92565b508061237181613ffc565b915050612332565b508034111561136157611361336123908334613f5c565b612e39565b60606123a082612ae2565b6124045760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610bf4565b600061240e61313d565b9050600081511161242e5760405180602001604052806000815250612164565b806124388461314c565b604051602001612449929190613c62565b6040516020818303038152906040529392505050565b600a546001600160a01b031633146124895760405162461bcd60e51b8152600401610bf490613e54565b6027805463ff00000019811663010000009182900460ff1615909102179055565b600a546001600160a01b031633146124d45760405162461bcd60e51b8152600401610bf490613e54565b602055565b6002600b5414156124fc5760405162461bcd60e51b8152600401610bf490613eda565b6002600b556027546301000000900460ff1661255a5760405162461bcd60e51b815260206004820152601c60248201527f536572756d204d75746174696f6e206973206e6f7420616374697665000000006044820152606401610bf4565b6040516331a9108f60e11b81526004810182905233906001600160a01b037f0000000000000000000000004b103d07c18798365946e76845edc6b5657794021690636352211e9060240160206040518083038186803b1580156125bc57600080fd5b505afa1580156125d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125f4919061390a565b6001600160a01b03161461261a5760405162461bcd60e51b8152600401610bf490613ce1565b604051627eeac760e11b8152336004820152602481018390526000907f000000000000000000000000b9655f835418fb64b63f934acb745d12d810fedb6001600160a01b03169062fdd58e9060440160206040518083038186803b15801561268157600080fd5b505afa158015612695573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126b99190613b1c565b116127215760405162461bcd60e51b815260206004820152603260248201527f4d757374206f776e206174206c65617374206f6e65206f66207468697320736560448201527172756d207479706520746f206d757461746560701b6064820152608401610bf4565b61272a81611706565b6127825760405162461bcd60e51b8152602060048201526024808201527f4772616e647061206973206e6f7420656c696769626c6520666f72206d7574616044820152633a34b7b760e11b6064820152608401610bf4565b600060458314156128c257602b54613aac61ffff90911611156128035760405162461bcd60e51b815260206004820152603360248201527f576f756c642065786365656420737570706c79206f6620736572756d2d6d7574604482015272617461626c65204d454741204d5554414e545360681b6064820152608401610bf4565b6000828152602c6020526040902054156128745760405162461bcd60e51b815260206004820152602c60248201527f41706520616c7265616479206d7574617465642077697468204d454741204d5560448201526b544154494f4e20534552554d60a01b6064820152608401610bf4565b50602b80546000838152602c6020526040812061ffff9283169081905583549093921691906128a283613fda565b91906101000a81548161ffff021916908361ffff160217905550506128f4565b6128cc83836130bc565b90506128d781612ae2565b156128f45760405162461bcd60e51b8152600401610bf490613e09565b6040516370ff9ea360e01b8152600481018490523360248201527f000000000000000000000000b9655f835418fb64b63f934acb745d12d810fedb6001600160a01b0316906370ff9ea390604401600060405180830381600087803b15801561295c57600080fd5b505af1158015612970573d6000803e3d6000fd5b5050505061297e3382612b92565b50506001600b5550565b600060458360ff1614156129ad57506000818152602c60205260409020541515610e24565b60006129bc8460ff16846130bc565b90506129c781612ae2565b949350505050565b600a546001600160a01b031633146129f95760405162461bcd60e51b8152600401610bf490613e54565b6001600160a01b038116612a5e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610bf4565b6115b081612f68565b60008060265411612a785750600090565b60265461162d9042613f5c565b6000612164828440614017565b60006001600160e01b031982166380ac58cd60e01b1480612ac357506001600160e01b03198216635b5e139f60e01b145b80610e2457506301ffc9a760e01b6001600160e01b0319831614610e24565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612b34826117fc565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000611387612b7d600284613f3d565b612b88906001613f11565b610e249190613f11565b61170282826040518060200160405280600081525061324a565b6000612bb782612ae2565b612c185760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610bf4565b6000612c23836117fc565b9050806001600160a01b0316846001600160a01b03161480612c5e5750836001600160a01b0316612c5384610efa565b6001600160a01b0316145b806129c757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff166129c7565b826001600160a01b0316612ca5826117fc565b6001600160a01b031614612d095760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610bf4565b6001600160a01b038216612d6b5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610bf4565b612d7683838361327d565b612d81600082612aff565b6001600160a01b0383166000908152600360205260408120805460019290612daa908490613f5c565b90915550506001600160a01b0382166000908152600360205260408120805460019290612dd8908490613f11565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b80471015612e895760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610bf4565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612ed6576040519150601f19603f3d011682016040523d82523d6000602084013e612edb565b606091505b50509050806110935760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610bf4565b600082612f5f8584613335565b14949350505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316141561301c5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610bf4565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b613094848484612c92565b6130a0848484846133a9565b61208f5760405162461bcd60e51b8152600401610bf490613d2d565b6000604583141561311a5760405162461bcd60e51b815260206004820152602260248201527f4d656761206d7574616e742049442063616e27742062652063616c63756c6174604482015261195960f21b6064820152608401610bf4565b61138783613129600285613f3d565b6131339190613f11565b6121649190613f11565b6060602d8054610e7790613f9f565b6060816131705750506040805180820190915260018152600360fc1b602082015290565b8160005b811561319a578061318481613ffc565b91506131939050600a83613f29565b9150613174565b60008167ffffffffffffffff8111156131b5576131b5614083565b6040519080825280601f01601f1916602001820160405280156131df576020820181803683370190505b5090505b84156129c7576131f4600183613f5c565b9150613201600a86614017565b61320c906030613f11565b60f81b8183815181106132215761322161406d565b60200101906001600160f81b031916908160001a905350613243600a86613f29565b94506131e3565b61325483836134b6565b61326160008484846133a9565b6110935760405162461bcd60e51b8152600401610bf490613d2d565b6001600160a01b0383166132d8576132d381600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6132fb565b816001600160a01b0316836001600160a01b0316146132fb576132fb83826135f5565b6001600160a01b0382166133125761109381613692565b826001600160a01b0316826001600160a01b031614611093576110938282613741565b600081815b84518110156133a15760008582815181106133575761335761406d565b6020026020010151905080831161337d576000838152602082905260409020925061338e565b600081815260208490526040902092505b508061339981613ffc565b91505061333a565b509392505050565b60006001600160a01b0384163b156134ab57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906133ed903390899088908890600401613c91565b602060405180830381600087803b15801561340757600080fd5b505af1925050508015613437575060408051601f3d908101601f1916820190925261343491810190613ab6565b60015b613491573d808015613465576040519150601f19603f3d011682016040523d82523d6000602084013e61346a565b606091505b5080516134895760405162461bcd60e51b8152600401610bf490613d2d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506129c7565b506001949350505050565b6001600160a01b03821661350c5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610bf4565b61351581612ae2565b156135625760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610bf4565b61356e6000838361327d565b6001600160a01b0382166000908152600360205260408120805460019290613597908490613f11565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000600161360284611bd8565b61360c9190613f5c565b60008381526007602052604090205490915080821461365f576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b6008546000906136a490600190613f5c565b600083815260096020526040812054600880549394509092849081106136cc576136cc61406d565b9060005260206000200154905080600883815481106136ed576136ed61406d565b600091825260208083209091019290925582815260099091526040808220849055858252812055600880548061372557613725614057565b6001900381819060005260206000200160009055905550505050565b600061374c83611bd8565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461379190613f9f565b90600052602060002090601f0160209004810192826137b357600085556137f9565b82601f106137cc57805160ff19168380011785556137f9565b828001600101855582156137f9579182015b828111156137f95782518255916020019190600101906137de565b5061202a9291505b8082111561202a5760008155600101613801565b600067ffffffffffffffff8084111561383057613830614083565b604051601f8501601f19908116603f0116810190828211818310171561385857613858614083565b8160405280935085815286868601111561387157600080fd5b858560208301376000602087830101525050509392505050565b60008083601f84011261389d57600080fd5b50813567ffffffffffffffff8111156138b557600080fd5b6020830191508360208260051b85010111156138d057600080fd5b9250929050565b803560ff811681146138e857600080fd5b919050565b6000602082840312156138ff57600080fd5b813561216481614099565b60006020828403121561391c57600080fd5b815161216481614099565b6000806040838503121561393a57600080fd5b823561394581614099565b9150602083013561395581614099565b809150509250929050565b60008060006060848603121561397557600080fd5b833561398081614099565b9250602084013561399081614099565b929592945050506040919091013590565b600080600080608085870312156139b757600080fd5b84356139c281614099565b935060208501356139d281614099565b925060408501359150606085013567ffffffffffffffff8111156139f557600080fd5b8501601f81018713613a0657600080fd5b613a1587823560208401613815565b91505092959194509250565b60008060408385031215613a3457600080fd5b8235613a3f81614099565b91506020830135801515811461395557600080fd5b60008060408385031215613a6757600080fd5b8235613a7281614099565b946020939093013593505050565b600060208284031215613a9257600080fd5b5035919050565b600060208284031215613aab57600080fd5b8135612164816140ae565b600060208284031215613ac857600080fd5b8151612164816140ae565b600060208284031215613ae557600080fd5b813567ffffffffffffffff811115613afc57600080fd5b8201601f81018413613b0d57600080fd5b6129c784823560208401613815565b600060208284031215613b2e57600080fd5b5051919050565b600080600080600060608688031215613b4d57600080fd5b85359450602086013567ffffffffffffffff80821115613b6c57600080fd5b613b7889838a0161388b565b90965094506040880135915080821115613b9157600080fd5b50613b9e8882890161388b565b969995985093965092949392505050565b60008060408385031215613bc257600080fd5b50508035926020909101359150565b60008060408385031215613be457600080fd5b82359150613bf4602084016138d7565b90509250929050565b60008060408385031215613c1057600080fd5b613a72836138d7565b60008151808452613c31816020860160208601613f73565b601f01601f19169290920160200192915050565b60609190911b6bffffffffffffffffffffffff1916815260140190565b60008351613c74818460208801613f73565b835190830190613c88818360208801613f73565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613cc490830184613c19565b9695505050505050565b6020815260006121646020830184613c19565b6020808252602c908201527f4d757374206f776e207468652061706520796f7527726520617474656d70746960408201526b6e6720746f206d757461746560a01b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526033908201527f5468697320776f756c642065786365656420746865206d6178696d756d20616c6040820152721b1bddd959081c195c881dda1a5d195b1a5cdd606a1b606082015260800190565b60208082526019908201527f5075626c69632073616c65206973206e6f742061637469766500000000000000604082015260600190565b6020808252602b908201527f41706520616c7265616479206d7574617465642077697468207468697320747960408201526a7065206f6620736572756d60a81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115613f2457613f2461402b565b500190565b600082613f3857613f38614041565b500490565b6000816000190483118215151615613f5757613f5761402b565b500290565b600082821015613f6e57613f6e61402b565b500390565b60005b83811015613f8e578181015183820152602001613f76565b8381111561208f5750506000910152565b600181811c90821680613fb357607f821691505b60208210811415613fd457634e487b7160e01b600052602260045260246000fd5b50919050565b600061ffff80831681811415613ff257613ff261402b565b6001019392505050565b60006000198214156140105761401061402b565b5060010190565b60008261402657614026614041565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146115b057600080fd5b6001600160e01b0319811681146115b057600080fdfea2646970667358221220ecb2309dcfc9a8f036d0046003720a60d15212c4e7d7c8c4244a9665f379504464736f6c63430008070033

Verified Source Code Full Match

Compiler: v0.8.7+commit.e28d00a7 EVM: london Optimization: Yes (200 runs)
Gacc.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

abstract contract Gacc {
    function ownerOf(uint256 tokenId) public view virtual returns (address);
}
Gasc.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

abstract contract Gasc {
    function burnSerumForAddress(uint256 typeId, address burnTokenAddress)
        external
        virtual;

    function balanceOf(address account, uint256 id)
        public
        view
        virtual
        returns (uint256);
}
MutantApeCountryClub.sol 500 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./Gacc.sol";
import "./Gasc.sol";


contract MutantApeCountryClub is ERC721Enumerable, Ownable, ReentrancyGuard {

    //    ░██████╗░░█████╗░░█████╗░░█████╗░
    //    ██╔════╝░██╔══██╗██╔══██╗██╔══██╗
    //    ██║░░██╗░███████║██║░░╚═╝██║░░╚═╝
    //    ██║░░╚██╗██╔══██║██║░░██╗██║░░██╗
    //    ╚██████╔╝██║░░██║╚█████╔╝╚█████╔╝
    //    ░╚═════╝░╚═╝░░╚═╝░╚════╝░░╚════╝░
    
    uint256 private constant NUM_MUTANT_TYPES = 2;
    uint256 private constant MEGA_MUTATION_TYPE = 69;
    uint256 public constant NUM_MEGA_MUTANTS = 21;
    uint256 private constant MAX_MEGA_MUTATION_ID = 15020;
    uint256 public constant SERUM_MUTATION_OFFSET = 4999;

    uint256[18] legendaryGrandpas = [0,1,2,3,4,5,6,7,8,9,156,576,1713,2976,3023,3622,3767,3867];

    // Whitelist Constants
    uint256 public constant WL_PRICE = 0.15 ether;
    uint256 public constant WL_MAX_MUTANT_PURCHASE = 1;
    uint256 public constant WL_MAX_MULTI_MUTANT_PURCHASE = 5;
    
    // Public Sale Constants
    uint256 public constant PS_MAX_MUTANT_PURCHASE = 20;
    // // The Public sale final price - 0.01 ETH
    uint256 public constant PS_MUTANT_ENDING_PRICE = 10000000000000000;

    // The max supply of Minted Mutants (WL and PS)
    uint256 public constant MAX_MINTED_MUTANTS = 5000;

    // Whitelists
    mapping(address => uint256) public presaleAddresses;
    bytes32 public wlFreeMerkleRoot;
    bytes32 public wlFreeMultiMerkleRoot;
    bytes32 public wlMultiMerkleRoot;
    bytes32 public wlMerkleRoot;
    // Public sale starting price - mutable, in case we need to pause
    // and restart the sale
    uint256 public publicSaleMutantStartingPrice;

    // Supply of Minted Mutants (not Mutated Apes)
    uint256 public numMutantsMinted;

    // Public sale params
    uint256 public publicSaleDuration;
    uint256 public publicSaleStartTime;

    // Sale switches
    bool public saleFreeWhitelistActive;
    bool public saleWhitelistActive;
    bool public publicSaleActive;
    bool public serumMutationActive;

    // Starting index block for the entire collection
    uint256 public collectionStartingIndexBlock;
    // Starting index for Minted Mutants
    uint256 public mintedMutantsStartingIndex;
    // Starting index for MEGA Mutants
    uint256 public megaMutantsStartingIndex;

    uint16 private currentMegaMutationId = 15000;
    mapping(uint256 => uint256) private megaMutationIdsByApe;

    string private baseURI;
    Gacc private immutable gacc;
    Gasc private immutable gasc;

    event MutantPublicSaleStart(
        uint256 indexed _saleDuration,
        uint256 indexed _saleStartTime
    );
    event MutantPublicSalePaused(
        uint256 indexed _currentPrice,
        uint256 indexed _timeElapsed
    );
    event StartingIndicesSet(
        uint256 indexed _mintedMutantsStartingIndex,
        uint256 indexed _megaMutantsStartingIndex
    );

    modifier whenPublicSaleActive() {
        require(publicSaleActive, "Public sale is not active");
        _;
    }

    modifier whenPreSaleActive() {
        require(saleWhitelistActive, "Whitelist sale is not active");
        _;
    }

    modifier startingIndicesNotSet() {
        require(
            mintedMutantsStartingIndex == 0,
            "Minted Mutants starting index is already set"
        );
        require(
            megaMutantsStartingIndex == 0,
            "Mega Mutants starting index is already set"
        );
        _;
    }

    constructor(
        string memory name,
        string memory symbol,
        address gaccAddress,
        address gascAddress
    ) ERC721(name, symbol) {
        gacc = Gacc(gaccAddress);
        gasc = Gasc(gascAddress);
    }

    function startPublicSale(uint256 saleDuration, uint256 saleStartPrice)
        external
        onlyOwner
    {
        require(!publicSaleActive, "Public sale has already begun");
        publicSaleDuration = saleDuration;
        publicSaleMutantStartingPrice = saleStartPrice;
        publicSaleStartTime = block.timestamp;
        publicSaleActive = true;
        emit MutantPublicSaleStart(saleDuration, publicSaleStartTime);
    }

    function pausePublicSale() external onlyOwner whenPublicSaleActive {
        uint256 currentSalePrice = getMintPrice();
        publicSaleActive = false;
        emit MutantPublicSalePaused(currentSalePrice, getElapsedSaleTime());
    }

    function getElapsedSaleTime() internal view returns (uint256) {
        return
            publicSaleStartTime > 0 ? block.timestamp - publicSaleStartTime : 0;
    }

    function getRemainingSaleTime() external view returns (uint256) {
        require(publicSaleStartTime > 0, "Public sale hasn't started yet");
        if (getElapsedSaleTime() >= publicSaleDuration) {
            return 0;
        }

        return (publicSaleStartTime + publicSaleDuration) - block.timestamp;
    }

    function setWlMerkleRoot(bytes32 _wlMerkleRoot) external onlyOwner {
        wlMerkleRoot = _wlMerkleRoot;
    }

    function setFreeWlMerkleRoot(bytes32 _freeWlMerkleRoot) external onlyOwner {
        wlFreeMerkleRoot = _freeWlMerkleRoot;
    }

    function setFreeMultiWlMerkleRoot(bytes32 _freeMultiWlMerkleRoot) external onlyOwner {
        wlFreeMultiMerkleRoot = _freeMultiWlMerkleRoot;
    }

    function setMultiWlMerkleRoot(bytes32 _multiWlMerkleRoot) external onlyOwner {
        wlMultiMerkleRoot = _multiWlMerkleRoot;
    }

    function getMintPrice() public view whenPublicSaleActive returns (uint256) {
        uint256 elapsed = getElapsedSaleTime();
        if (elapsed >= publicSaleDuration) {
            return PS_MUTANT_ENDING_PRICE;
        } else {
            uint256 currentPrice = ((publicSaleDuration - elapsed) *
                publicSaleMutantStartingPrice) / publicSaleDuration;
            return
                currentPrice > PS_MUTANT_ENDING_PRICE
                    ? currentPrice
                    : PS_MUTANT_ENDING_PRICE;
        }
    }

    function withdraw() external onlyOwner {
        uint256 balance = address(this).balance;
        Address.sendValue(payable(owner()), balance);
    }

    function mintFreeWhitelist(uint256 numMutants, bytes32[] calldata wlFreeMerkleProof, bytes32[] calldata wlFreeMultiMerkleProof) public payable nonReentrant {
        require(saleFreeWhitelistActive == true, "Free Whitelist Mint has not started");
        require(
            (MerkleProof.verify(wlFreeMerkleProof, wlFreeMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true || MerkleProof.verify(wlFreeMultiMerkleProof, wlFreeMultiMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true), 
            "The address is not whitelisted for the free mint");
        uint256 wl_max_mutant = WL_MAX_MUTANT_PURCHASE;
        if (MerkleProof.verify(wlFreeMultiMerkleProof, wlFreeMultiMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true) {
            wl_max_mutant = WL_MAX_MULTI_MUTANT_PURCHASE;
        }
        require(
            presaleAddresses[_msgSender()] + numMutants <= wl_max_mutant,
            "This would exceed the maximum allowed per whitelist"
        );
        for (uint256 i = 0; i < numMutants; i++) {
            uint256 mintIndex = numMutantsMinted;
            if (numMutantsMinted < MAX_MINTED_MUTANTS) {
                numMutantsMinted++;
                _safeMint(msg.sender, mintIndex);
                presaleAddresses[_msgSender()] += 1;
            }
        }
    }

    function mintWhitelist(uint256 numMutants, bytes32[] calldata wlMerkleProof, bytes32[] calldata wlMultiMerkleProof) public payable nonReentrant {
        require(saleWhitelistActive == true, "Whitelist Sale has not started");
        require(numMutants > 0, "Must mint at least one mutant");
        require(
            (MerkleProof.verify(wlMerkleProof, wlMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true || MerkleProof.verify(wlMultiMerkleProof, wlMultiMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true), 
            "The address is not whitelisted");
        uint256 wl_max_mutant = WL_MAX_MUTANT_PURCHASE;
        if (MerkleProof.verify(wlMultiMerkleProof, wlMultiMerkleRoot, keccak256(abi.encodePacked(msg.sender))) == true) {
            wl_max_mutant = WL_MAX_MULTI_MUTANT_PURCHASE;
        }
        require(
            presaleAddresses[_msgSender()] + numMutants <= wl_max_mutant,
            "This would exceed the maximum allowed per whitelist"
        );
        uint256 costToMint = WL_PRICE * numMutants;
        require(costToMint <= msg.value, "Ether value sent is not correct");
        for (uint256 i = 0; i < numMutants; i++) {
            uint256 mintIndex = numMutantsMinted;
            if (numMutantsMinted < MAX_MINTED_MUTANTS) {
                numMutantsMinted++;
                _safeMint(msg.sender, mintIndex);
                presaleAddresses[_msgSender()] += 1;
            }
        }
    }

    function mintMutants(uint256 numMutants)
        external
        payable
        whenPublicSaleActive
        nonReentrant
    {
        require(
            numMutantsMinted + numMutants <= MAX_MINTED_MUTANTS,
            "Minting would exceed max supply"
        );
        require(numMutants > 0, "Must mint at least one mutant");
        require(
            numMutants <= PS_MAX_MUTANT_PURCHASE,
            "Requested number exceeds maximum"
        );

        uint256 costToMint = getMintPrice() * numMutants;
        require(costToMint <= msg.value, "Ether value sent is not correct");
        
        if (mintedMutantsStartingIndex == 0) {
            collectionStartingIndexBlock = block.number;
        }

        for (uint256 i = 0; i < numMutants; i++) {
            uint256 mintIndex = numMutantsMinted;
            if (numMutantsMinted < MAX_MINTED_MUTANTS) {
                numMutantsMinted++;
                _safeMint(msg.sender, mintIndex);
            }
        }

        if (msg.value > costToMint) {
            Address.sendValue(payable(msg.sender), msg.value - costToMint);
        }
    }

    function isApeEligibleForSerumMutation(uint256 apeId) public view returns (bool) {
        // Exclude Legendary Grandpa Apes
        for (uint256 i = 0; i < legendaryGrandpas.length; i++) {
            if (apeId == legendaryGrandpas[i]) {
                return false;
            }
        }
        return true;
    }

    
    function mutateApeWithSerum(uint256 serumTypeId, uint256 apeId)
        external
        nonReentrant
    {
        require(serumMutationActive, "Serum Mutation is not active");
        require(
            gacc.ownerOf(apeId) == msg.sender,
            "Must own the ape you're attempting to mutate"
        );
        require(
            gasc.balanceOf(msg.sender, serumTypeId) > 0,
            "Must own at least one of this serum type to mutate"
        );
        require(isApeEligibleForSerumMutation(apeId), 
        "Grandpa is not eligible for mutation"
        );

        uint256 mutantId;

        if (serumTypeId == MEGA_MUTATION_TYPE) {
            require(
                currentMegaMutationId <= MAX_MEGA_MUTATION_ID,
                "Would exceed supply of serum-mutatable MEGA MUTANTS"
            );
            require(
                megaMutationIdsByApe[apeId] == 0,
                "Ape already mutated with MEGA MUTATION SERUM"
            );

            mutantId = currentMegaMutationId;
            megaMutationIdsByApe[apeId] = mutantId;
            currentMegaMutationId++;
        } else {
            mutantId = getMutantId(serumTypeId, apeId);
            require(
                !_exists(mutantId),
                "Ape already mutated with this type of serum"
            );
        }

        gasc.burnSerumForAddress(serumTypeId, msg.sender);
        _safeMint(msg.sender, mutantId);
    }

    function mutateApeWithoutSerum(uint256 apeId)
        external
        nonReentrant
    {
        require(serumMutationActive, "Serum Mutation is not active");
        require(
            gacc.ownerOf(apeId) == msg.sender,
            "Must own the ape you're attempting to mutate"
        );
        require(
            !isApeEligibleForSerumMutation(apeId), 
            "A serum is required for this Grandpa"
        );

        uint256 mutantId;
        mutantId = getLegendaryMutantId(apeId);
        require(
            !_exists(mutantId),
            "Ape already mutated with this type of serum"
        );
        _safeMint(msg.sender, mutantId);
    }

    function getMutantIdForApeAndSerumCombination(
        uint256 apeId,
        uint8 serumTypeId
    ) external view returns (uint256) {
        uint256 mutantId;
        if (serumTypeId == MEGA_MUTATION_TYPE) {
            mutantId = megaMutationIdsByApe[apeId];
            require(mutantId > 0, "Invalid MEGA Mutant Id");
        } else {
            mutantId = getMutantId(serumTypeId, apeId);
        }

        require(_exists(mutantId), "Query for nonexistent mutant");

        return mutantId;
    }

    function hasApeBeenMutatedWithType(uint8 serumType, uint256 apeId)
        external
        view
        returns (bool)
    {
        if (serumType == MEGA_MUTATION_TYPE) {
            return megaMutationIdsByApe[apeId] > 0;
        }

        uint256 mutantId = getMutantId(serumType, apeId);
        return _exists(mutantId);
    }

    function getMutantId(uint256 serumType, uint256 apeId)
        internal
        pure
        returns (uint256)
    {
        require(
            serumType != MEGA_MUTATION_TYPE,
            "Mega mutant ID can't be calculated"
        );
        return (apeId * NUM_MUTANT_TYPES) + serumType + SERUM_MUTATION_OFFSET;
    }

    function getLegendaryMutantId(uint256 apeId)
        internal
        pure
        returns (uint256)
    {
        return (apeId * NUM_MUTANT_TYPES) + 1 + SERUM_MUTATION_OFFSET;
    }

    function isMinted(uint256 tokenId) external view returns (bool) {
        require(
            tokenId < MAX_MEGA_MUTATION_ID,
            "tokenId outside collection bounds"
        );
        return _exists(tokenId);
    }

    function totalApesMutated() external view returns (uint256) {
        return totalSupply() - numMutantsMinted;
    }

    function apesMinted() external view returns (uint256) {
        return numMutantsMinted;
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function setBaseURI(string memory uri) external onlyOwner {
        baseURI = uri;
    }

    function toggleFreeWhiteListSaleActive() external onlyOwner {
        saleFreeWhitelistActive = !saleFreeWhitelistActive;
    }

    function toggleWhiteListSaleActive() external onlyOwner {
        saleWhitelistActive = !saleWhitelistActive;
    }

    function togglePublicSaleActive() external onlyOwner {
        publicSaleActive = !publicSaleActive;
    }

    function toggleSerumMutationActive() external onlyOwner {
        serumMutationActive = !serumMutationActive;
    }

    function calculateStartingIndex(uint256 blockNumber, uint256 collectionSize)
        internal
        view
        returns (uint256)
    {
        return uint256(blockhash(blockNumber)) % collectionSize;
    }
    
    function setStartingIndices() external startingIndicesNotSet {
        require(
            collectionStartingIndexBlock != 0,
            "Starting index block must be set"
        );
        uint256 elapsed = getElapsedSaleTime();
        require(
            elapsed >= publicSaleDuration && publicSaleStartTime > 0,
            "Invalid setStartingIndices conditions"
        );

        mintedMutantsStartingIndex = calculateStartingIndex(
            collectionStartingIndexBlock,
            MAX_MINTED_MUTANTS
        );

        megaMutantsStartingIndex = calculateStartingIndex(
            collectionStartingIndexBlock,
            NUM_MEGA_MUTANTS
        );
        
        if ((block.number - collectionStartingIndexBlock) > 255) {
            mintedMutantsStartingIndex = calculateStartingIndex(
                block.number - 1,
                MAX_MINTED_MUTANTS
            );

            megaMutantsStartingIndex = calculateStartingIndex(
                block.number - 1,
                NUM_MEGA_MUTANTS
            );
        }

        // Prevent default sequence
        if (mintedMutantsStartingIndex == 0) {
            mintedMutantsStartingIndex++;
        }
        if (megaMutantsStartingIndex == 0) {
            megaMutantsStartingIndex++;
        }

        emit StartingIndicesSet(
            mintedMutantsStartingIndex,
            megaMutantsStartingIndex
        );
    }
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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.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 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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.1 (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);
    }
}
Pausable.sol 91 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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);

        _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 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 {}

    /**
     * @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 v4.4.1 (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;
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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.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 v4.4.1 (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);
}
MerkleProof.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = _efficientHash(computedHash, proofElement);
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = _efficientHash(proofElement, computedHash);
            }
        }
        return computedHash;
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}
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);
}
ERC721Enumerable.sol 163 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // 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;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[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)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (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 add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @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];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the 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 = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

Read Contract

MAX_MINTED_MUTANTS 0x22f76af3 → uint256
NUM_MEGA_MUTANTS 0xc0bb92ea → uint256
PS_MAX_MUTANT_PURCHASE 0x0af7f2b8 → uint256
PS_MUTANT_ENDING_PRICE 0xe3764a8b → uint256
SERUM_MUTATION_OFFSET 0x61169ea8 → uint256
WL_MAX_MULTI_MUTANT_PURCHASE 0x24460778 → uint256
WL_MAX_MUTANT_PURCHASE 0xe3f2f54b → uint256
WL_PRICE 0x31c3c7a0 → uint256
apesMinted 0x22c69fe7 → uint256
balanceOf 0x70a08231 → uint256
collectionStartingIndexBlock 0x2f2eda31 → uint256
getApproved 0x081812fc → address
getMintPrice 0xa7f93ebd → uint256
getMutantIdForApeAndSerumCombination 0xbd5e5e0c → uint256
getRemainingSaleTime 0x567ac4f6 → uint256
hasApeBeenMutatedWithType 0xee211233 → bool
isApeEligibleForSerumMutation 0x565f2bfe → bool
isApprovedForAll 0xe985e9c5 → bool
isMinted 0x33c41a90 → bool
megaMutantsStartingIndex 0xb23142e2 → uint256
mintedMutantsStartingIndex 0x725ae16c → uint256
name 0x06fdde03 → string
numMutantsMinted 0xe43437c8 → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
presaleAddresses 0x66fca980 → uint256
publicSaleActive 0xbc8893b4 → bool
publicSaleDuration 0xfd48354e → uint256
publicSaleMutantStartingPrice 0xc973d72d → uint256
publicSaleStartTime 0x6bb7b1d9 → uint256
saleFreeWhitelistActive 0x9dc40c15 → bool
saleWhitelistActive 0x831fc3b4 → bool
serumMutationActive 0xe1c3ad0c → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalApesMutated 0x48cd4f08 → uint256
totalSupply 0x18160ddd → uint256
wlFreeMerkleRoot 0x5bfa60f6 → bytes32
wlFreeMultiMerkleRoot 0xbdce4bc9 → bytes32
wlMerkleRoot 0x54c06aee → bytes32
wlMultiMerkleRoot 0xd91a0d54 → bytes32

Write Contract 25 functions

These functions modify contract state and require a wallet transaction to execute.

approve 0x095ea7b3
address to
uint256 tokenId
mintFreeWhitelist 0x7565f25f
uint256 numMutants
bytes32[] wlFreeMerkleProof
bytes32[] wlFreeMultiMerkleProof
mintMutants 0xc15e24bc
uint256 numMutants
mintWhitelist 0x67bdeba7
uint256 numMutants
bytes32[] wlMerkleProof
bytes32[] wlMultiMerkleProof
mutateApeWithSerum 0xe73a9a25
uint256 serumTypeId
uint256 apeId
mutateApeWithoutSerum 0x1a895741
uint256 apeId
pausePublicSale 0x0c41f497
No parameters
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
setFreeMultiWlMerkleRoot 0xd7d0b417
bytes32 _freeMultiWlMerkleRoot
setFreeWlMerkleRoot 0x57b8dc04
bytes32 _freeWlMerkleRoot
setMultiWlMerkleRoot 0xaccf4eb1
bytes32 _multiWlMerkleRoot
setStartingIndices 0x00dbabc7
No parameters
setWlMerkleRoot 0x8ac1e161
bytes32 _wlMerkleRoot
startPublicSale 0x3a12e933
uint256 saleDuration
uint256 saleStartPrice
toggleFreeWhiteListSaleActive 0x06851cf1
No parameters
togglePublicSaleActive 0x0c894cfe
No parameters
toggleSerumMutationActive 0xd0b77feb
No parameters
toggleWhiteListSaleActive 0x435f3b8e
No parameters
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters

Recent Transactions

No transactions found for this address