Address Contract Verified
Address
0x3E0B4676B6Fe3356DBDb5d413Ec5D11710219E03
Balance
0 ETH
Nonce
1
Code Size
13556 bytes
Creator
0x58695929...3c49 at tx 0x9b885b9b...216cff
Indexed Transactions
0
Contract Bytecode
13556 bytes
0x6080604052600436106103c8575f3560e01c806375c40018116101f4578063a9fc664e11610113578063da1919b3116100a8578063e3b853c511610078578063e3b853c514610b12578063e7bc820814610b26578063e8a3d48514610b3a578063e985e9c514610b4e578063f30e6e7714610b6d575f5ffd5b8063da1919b314610a80578063dc33e68114610a9f578063e18bc08a14610abe578063e30c397814610af5575f5ffd5b8063b88d4fde116100e3578063b88d4fde14610a0e578063c87b56dd14610a2d578063d146650814610a4c578063d5abeb0114610a6b575f5ffd5b8063a9fc664e14610994578063ab75db1d146109b3578063ad2f852a146109d2578063b0e6a81d146109ef575f5ffd5b806391984dd011610189578063a0712d6811610159578063a0712d681461092e578063a22cb46514610941578063a62f1f4014610960578063a945bf801461097f575f5ffd5b806391984dd0146108c3578063938e3d7b146108e257806395d89b41146109015780639ca89fad14610915575f5ffd5b8063870b9580116101c4578063870b95801461083c57806388924a661461085b5780638da5cb5b146108925780638fedfb51146108ae575f5ffd5b806375c40018146107e757806379ba5097146108065780637d54d0551461080e5780637e4831d314610823575f5ffd5b80632a55205a116102eb578063566c6ad3116102805780636c0360eb116102505780636c0360eb1461076757806370517ed41461077b57806370a082311461079a578063729205e7146107b957806374c28561146107d2575f5ffd5b8063566c6ad3146106f55780635babdd0e1461070a5780636352211e1461072957806363c8f38f14610748575f5ffd5b806342260b5d116102bb57806342260b5d1461067a57806342842e0e1461069e57806346f720d2146106bd57806355f804b3146106d6575f5ffd5b80632a55205a146105d357806334e5a70e146106115780633af32abf146106305780633ccfd60b14610666575f5ffd5b80630a276680116103615780631c098ac3116103315780631c098ac31461056d57806320b600ad1461058b57806323b872dd1461059f5780632549f06c146105be575f5ffd5b80630a276680146104f55780630d705df61461051457806318160ddd1461053a5780631bace9a81461054e575f5ffd5b806306fdde031161039c57806306fdde0314610461578063081812fc14610482578063095ea7b3146104b9578063098144d4146104d8575f5ffd5b8062725dca146103cc57806301ffc9a7146103ff57806302fa7c471461041e5780630561942a1461043f575b5f5ffd5b3480156103d7575f5ffd5b506019546103ea90610100900460ff1681565b60405190151581526020015b60405180910390f35b34801561040a575f5ffd5b506103ea610419366004612d82565b610b8c565b348015610429575f5ffd5b5061043d610438366004612db8565b610c22565b005b34801561044a575f5ffd5b50610453610ce7565b6040519081526020016103f6565b34801561046c575f5ffd5b50610475610d58565b6040516103f69190612e26565b34801561048d575f5ffd5b506104a161049c366004612e38565b610de8565b6040516001600160a01b0390911681526020016103f6565b3480156104c4575f5ffd5b5061043d6104d3366004612e4f565b610e2a565b3480156104e3575f5ffd5b506011546001600160a01b03166104a1565b348015610500575f5ffd5b5061043d61050f366004612e4f565b610eae565b34801561051f575f5ffd5b506040805163657711f560e11b81525f6020820152016103f6565b348015610545575f5ffd5b50610453610f31565b348015610559575f5ffd5b5061043d610568366004612e86565b610f3a565b348015610578575f5ffd5b506027546103ea90610100900460ff1681565b348015610596575f5ffd5b5061043d610f9d565b3480156105aa575f5ffd5b5061043d6105b9366004612eb7565b610fde565b3480156105c9575f5ffd5b50610453601c5481565b3480156105de575f5ffd5b506105f26105ed366004612ef1565b611188565b604080516001600160a01b0390931683526020830191909152016103f6565b34801561061c575f5ffd5b5061043d61062b366004612e86565b6111cd565b34801561063b575f5ffd5b5061064f61064a366004612f11565b611230565b6040805192151583526020830191909152016103f6565b348015610671575f5ffd5b5061043d611273565b348015610685575f5ffd5b50601354600160a01b90046001600160601b0316610453565b3480156106a9575f5ffd5b5061043d6106b8366004612eb7565b6113b2565b3480156106c8575f5ffd5b506003546103ea9060ff1681565b3480156106e1575f5ffd5b5061043d6106f0366004612f2a565b6113d1565b348015610700575f5ffd5b50610453601d5481565b348015610715575f5ffd5b5061043d610724366004612f98565b61145a565b348015610734575f5ffd5b506104a1610743366004612e38565b6114aa565b348015610753575f5ffd5b5061043d610762366004612f11565b6114b4565b348015610772575f5ffd5b5061047561150a565b348015610786575f5ffd5b5061043d610795366004612e38565b611596565b3480156107a5575f5ffd5b506104536107b4366004612f11565b6115a4565b3480156107c4575f5ffd5b50600a546103ea9060ff1681565b3480156107dd575f5ffd5b5061045360215481565b3480156107f2575f5ffd5b5061043d610801366004612fb1565b6115f1565b61043d611611565b348015610819575f5ffd5b50610453601e5481565b34801561082e575f5ffd5b506019546103ea9060ff1681565b348015610847575f5ffd5b5061043d610856366004612f98565b61170c565b348015610866575f5ffd5b506103ea610875366004612f11565b6001600160a01b03165f9081526004602052604090205460ff1690565b34801561089d575f5ffd5b505f546001600160a01b03166104a1565b3480156108b9575f5ffd5b50610453601f5481565b3480156108ce575f5ffd5b506104536108dd366004612e38565b61172f565b3480156108ed575f5ffd5b5061043d6108fc366004612f2a565b6117ae565b34801561090c575f5ffd5b5061047561181f565b348015610920575f5ffd5b506027546103ea9060ff1681565b61043d61093c366004612e38565b61182e565b34801561094c575f5ffd5b5061043d61095b366004612e86565b611af4565b34801561096b575f5ffd5b506025546104a1906001600160a01b031681565b34801561098a575f5ffd5b5061045360205481565b34801561099f575f5ffd5b5061043d6109ae366004612f11565b611cb2565b3480156109be575f5ffd5b5061043d6109cd366004612fe8565b611cc3565b3480156109dd575f5ffd5b506013546001600160a01b03166104a1565b3480156109fa575f5ffd5b506022546104a1906001600160a01b031681565b348015610a19575f5ffd5b5061043d610a28366004613083565b611e26565b348015610a38575f5ffd5b50610475610a47366004612e38565b611e6a565b348015610a57575f5ffd5b5061043d610a66366004612f11565b611eec565b348015610a76575f5ffd5b50610453601a5481565b348015610a8b575f5ffd5b5061043d610a9a366004612e4f565b611efd565b348015610aaa575f5ffd5b50610453610ab9366004612f11565b611fe0565b348015610ac9575f5ffd5b506103ea610ad8366004612f11565b6001600160a01b03165f9081526005602052604090205460ff1690565b348015610b00575f5ffd5b506001546001600160a01b03166104a1565b348015610b1d575f5ffd5b5061043d61200a565b348015610b31575f5ffd5b5061043d6120e2565b348015610b45575f5ffd5b50610475612121565b348015610b59575f5ffd5b506103ea610b68366004613160565b61212e565b348015610b78575f5ffd5b5061043d610b87366004612f98565b6121b4565b5f6001600160e01b031982166301ffc9a760e01b1480610bbc57506001600160e01b0319821663152a902d60e11b145b80610bd757506001600160e01b03198216632b435fdb60e21b145b80610bf257506001600160e01b0319821663503e914d60e11b145b80610c0d5750632483248360e11b6001600160e01b03198316145b80610c1c5750610c1c826121d0565b92915050565b610c2a612204565b506001600160a01b038216610c5257604051631cc0baef60e01b815260040160405180910390fd5b612710816001600160601b03161115610c8e57604051633cadbafb60e01b81526001600160601b03821660048201526024015b60405180910390fd5b610c988282612274565b604080516001600160a01b03841681526001600160601b03831660208201527ff21fccf4d64d86d532c4e4eb86c007b6ad57a460c27d724188625e755ec6cf6d91015b60405180910390a15050565b5f5f610cf1610f31565b9050601d54601c54601b54610d06919061319c565b610d10919061319c565b811115610d1f57505060205490565b601c54601b54610d2f919061319c565b811115610d3e575050601f5490565b601b54811115610d50575050601e5490565b505060205490565b606060078054610d67906131af565b80601f0160208091040260200160405190810160405280929190818152602001828054610d93906131af565b8015610dde5780601f10610db557610100808354040283529160200191610dde565b820191905f5260205f20905b815481529060010190602001808311610dc157829003601f168201915b5050505050905090565b5f610df282612316565b610e0f576040516333d1c03960e21b815260040160405180910390fd5b505f908152600f60205260409020546001600160a01b031690565b610e32612204565b15610eaa575f818152600f6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190610e6b826114aa565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a4610eaa8282612349565b5050565b610eb661250b565b600180546001600160a01b0384166001600160a01b031990911681179091556002829055610eeb5f546001600160a01b031690565b6001600160a01b03167f2ac05566ef5f778eb7c7dc3f0b38cff7ea0add92e735667d6f405cff3a132b7b83604051610f2591815260200190565b60405180910390a35050565b6006545f190190565b610f4261250b565b6001600160a01b0382165f81815260046020908152604091829020805460ff19168515159081179091558251938452908301527fee6f72776cc4e6e5957f9692e86b52e270b1578d343bf9f46351ffab538487ac9101610cdb565b610fa561250b565b6027805461ff0019166101001790556040517fcd419d1c99778024e5d38fbd1171e65ae5db98bef0e26a8b2acd746c93d328a9905f90a1565b5f610fe882612559565b9050836001600160a01b0316816001600160a01b03161461101b5760405162a1148160e81b815260040160405180910390fd5b5f828152600f602052604090208054338082146001600160a01b038816909114176110675761104a863361212e565b61106757604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661108e57604051633a954ecd60e21b815260040160405180910390fd5b61109b86868660016125ca565b80156110a5575f82555b6001600160a01b038681165f908152600e602052604080822080545f19019055918716808252919020805460010190554260a01b17600160e11b175f858152600d6020526040812091909155600160e11b8416900361113257600184015f818152600d60205260408120549003611130576006548114611130575f818152600d602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4611180868686600161267f565b505050505050565b601380545f918291612710906111ae90600160a01b90046001600160601b0316866131e7565b6111b891906131fe565b90546001600160a01b03169590945092505050565b6111d561250b565b6001600160a01b0382165f81815260056020908152604091829020805460ff19168515159081179091558251938452908301527fbc9494536acaf3f702bbec70ff790bb3930056ae9e781e8077097b9de89a8e189101610cdb565b5f8061123d6015846126d1565b1561124d57506001928392509050565b6112586017846126d1565b156112695750600192600292509050565b505f928392509050565b61127b612204565b506024545f906127109061129f90600160a01b90046001600160601b0316476131e7565b6112a991906131fe565b90505f6112b6824761321d565b6024546040519192505f916001600160a01b039091169084908381818185875af1925050503d805f8114611305576040519150601f19603f3d011682016040523d82523d5f602084013e61130a565b606091505b50506023546040519192505f916001600160a01b039091169084908381818185875af1925050503d805f811461135b576040519150601f19603f3d011682016040523d82523d5f602084013e611360565b606091505b5050905081801561136e5750805b6113ac5760405162461bcd60e51b815260206004820152600f60248201526e1dda5d1a191c985dc819985a5b1959608a1b6044820152606401610c85565b50505050565b6113cc83838360405180602001604052805f815250611e26565b505050565b6113d9612204565b5060275460ff16156113fe57604051633514c0f560e11b815260040160405180910390fd5b600961140b828483613274565b50611414610f31565b15610eaa577f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c600161144560065490565b60408051928352602083019190915201610cdb565b61146261250b565b6003805460ff19168215159081179091556040519081527f0efe10ef116fae4939f66482c28a1b970a12ed19dc4ced68d2080c5558106f11906020015b60405180910390a150565b5f610c1c82612559565b6114bc61250b565b602580546001600160a01b0319166001600160a01b0383169081179091556040519081527fd621725e19a0c622a46a440283011c836734d179cde70ddf80b908b8cc848fb09060200161149f565b60098054611517906131af565b80601f0160208091040260200160405190810160405280929190818152602001828054611543906131af565b801561158e5780601f106115655761010080835404028352916020019161158e565b820191905f5260205f20905b81548152906001019060200180831161157157829003601f168201915b505050505081565b61159e612204565b50602155565b5f6001600160a01b0382166115cc576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03165f908152600e602052604090205467ffffffffffffffff1690565b6115f9612204565b50601c94909455601e92909255601d55601f55602055565b60015433906001600160a01b031681146116635760405162461bcd60e51b815260206004820152601360248201527221b0b63632b9103737ba103732bba7bbb732b960691b6044820152606401610c85565b600254341015611671575f5ffd5b5f80546040516001600160a01b039091169034908381818185875af1925050503d805f81146116bb576040519150601f19603f3d011682016040523d82523d5f602084013e6116c0565b606091505b50509050806117035760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610c85565b610eaa826126f2565b611714612204565b50601980549115156101000261ff0019909216919091179055565b5f818152602860205260408120546001600160601b0316810361178d5760405162461bcd60e51b8152602060048201526016602482015275151bdad95b925908191bd95cc81b9bdd08195e1a5cdd60521b6044820152606401610c85565b5f82815260286020526040902054610c1c906001600160601b03164261321d565b6117b6612204565b50602754610100900460ff16156117e057604051633514c0f560e11b815260040160405180910390fd5b60266117ed828483613274565b507f905d981207a7d0b6c62cc46ab0be2a076d0298e4a86d0ab79882dbd01ac373788282604051610cdb92919061332e565b606060088054610d67906131af565b61183661270b565b5f601c54601b54611847919061319c565b9050811580159061185b575060195460ff16155b6118995760405162461bcd60e51b815260206004820152600f60248201526e0c081c5d1e481bdc881c185d5cd959608a1b6044820152606401610c85565b601954610100900460ff1680156118c35750601d546118b8908261319c565b6118c0610f31565b11155b1561196a576118d36015336126d1565b1580156118f2575080826118e5610f31565b6118ef919061319c565b11155b1561196a576119026017336126d1565b801561192c5750601d54611916908261319c565b8261191f610f31565b611929919061319c565b11155b61196a5760405162461bcd60e51b815260206004820152600f60248201526e1b9bdd0815d3081bdc88195b991959608a1b6044820152606401610c85565b601954610100900460ff16156119b25760405162461bcd60e51b815260206004820152600d60248201526c2ba61039ba34b6361027b832b760991b6044820152606401610c85565b602154335f908152600e6020526040908190205484911c67ffffffffffffffff166119dd919061319c565b111580156119fd5750816119ef610ce7565b6119f991906131e7565b3410155b611a495760405162461bcd60e51b815260206004820152601e60248201527f3e2057616c6c6574206c696d6974206f722070616964203c20707269636500006044820152606401610c85565b601a5482611a55610f31565b611a5f919061319c565b1115611a9b5760405162461bcd60e51b815260206004820152600b60248201526a3e206d6178537570706c7960a81b6044820152606401610c85565b611aa53383612764565b60408051338152602081018490527f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe910160405180910390a1611ae661277d565b50611af16001601255565b50565b600a54339060ff16611b375760405162461bcd60e51b815260206004820152600c60248201526b14d85b195cc81c185d5cd95960a21b6044820152606401610c85565b826001600160a01b0316816001600160a01b031603611b885760405162461bcd60e51b815260206004820152600d60248201526c73656c66417070726f76616c3f60981b6044820152606401610c85565b6001600160a01b0383165f908152600b602052604090205460ff1680611bc557506001600160a01b0381165f908152600b602052604090205460ff165b15611be25760405162461bcd60e51b8152600401610c859061335c565b60035460ff1615611c46576001600160a01b0383165f908152600c602052604090205460ff1680611c2a57506001600160a01b0381165f908152600c602052604090205460ff165b611c465760405162461bcd60e51b8152600401610c8590613386565b6001600160a01b038181165f81815260106020908152604080832094881680845294825291829020805460ff191687151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611cba61250b565b611af1816127cf565b611ccb612204565b5080600103611d60575f5b83811015611d5a5760019250611d14858583818110611cf757611cf76133b4565b9050602002016020810190611d0c9190612f11565b601590612857565b508215155f03611d5257611d50858583818110611d3357611d336133b4565b9050602002016020810190611d489190612f11565b60159061286b565b505b600101611cd6565b506113ac565b80600203611dee575f5b83811015611d5a5760019250611da8858583818110611d8b57611d8b6133b4565b9050602002016020810190611da09190612f11565b601790612857565b508215155f03611de657611de4858583818110611dc757611dc76133b4565b9050602002016020810190611ddc9190612f11565b60179061286b565b505b600101611d6a565b60405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420737461676560981b6044820152606401610c85565b611e31848484610fde565b6001600160a01b0383163b156113ac57611e4d8484848461287f565b6113ac576040516368d2bf6b60e11b815260040160405180910390fd5b6060611e7582612316565b611e9257604051630a14c4b560e41b815260040160405180910390fd5b60098054611e9f906131af565b90505f03611ebb5760405180602001604052805f815250610c1c565b6009611ec683612966565b604051602001611ed79291906133c8565b60405160208183030381529060405292915050565b611ef461250b565b611af1816126f2565b611f05612204565b50805f03611f3e5760405162461bcd60e51b81526020600482015260066024820152656d696e20312b60d01b6044820152606401610c85565b601a5481611f4a610f31565b611f54919061319c565b1115611f8c5760405162461bcd60e51b8152602060048201526007602482015266135a5b9d13dd5d60ca1b6044820152606401610c85565b611f968282612764565b604080516001600160a01b0384168152602081018390527f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe910160405180910390a1610eaa61277d565b6001600160a01b0381165f908152600e60205260408082205467ffffffffffffffff911c16610c1c565b6103e8612015610f31565b6120209060056131e7565b61202a91906131fe565b612033336115a4565b11801561205b5750602254612050906001600160a01b03166115a4565b612059336115a4565b115b6120985760405162461bcd60e51b815260206004820152600e60248201526d446f206e6f74207175616c69667960901b6044820152606401610c85565b602280546001600160a01b031916339081179091556040519081527fb72df55e88a477558ba41208164793abce31c9e92a7aa70062e304cc757ebae29060200160405180910390a1565b6120ea61250b565b6027805460ff191660011790556040517fcb8ee1250825b65fb9f9db82cf9039335db3185b4258fa3f81453f21741b4251905f90a1565b60268054611517906131af565b6001600160a01b0381165f908152600b602052604081205460ff161561215557505f610c1c565b60035460ff1615612186576001600160a01b0382165f908152600c602052604090205460ff1661218657505f610c1c565b506001600160a01b039182165f90815260106020908152604080832093909416825291909152205460ff1690565b6121bc612204565b506019805460ff1916911515919091179055565b5f6001600160e01b0319821663152a902d60e11b1480610c1c57506301ffc9a760e01b6001600160e01b0319831614610c1c565b5f80546001600160a01b0316331480159061222a57506025546001600160a01b03163314155b1561226e5760405162461bcd60e51b81526020600482015260146024820152732737ba1027bbb732b91037b91026b0b730b3b2b960611b6044820152606401610c85565b50600190565b6127106001600160601b0382168110156122b357604051636f483d0960e01b81526001600160601b038316600482015260248101829052604401610c85565b6001600160a01b0383166122dc57604051635b6cc80560e11b81525f6004820152602401610c85565b50604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217601355565b5f81600111158015612329575060065482105b8015610c1c5750505f908152600d6020526040902054600160e01b161590565b335f612354836114aa565b600a5490915060ff166123985760405162461bcd60e51b815260206004820152600c60248201526b14d85b195cc81c185d5cd95960a21b6044820152606401610c85565b6001600160a01b0384165f908152600b602052604090205460ff16156123d05760405162461bcd60e51b8152600401610c859061335c565b806001600160a01b0316826001600160a01b0316146124af576001600160a01b0382165f908152600b602052604090205460ff16156124215760405162461bcd60e51b8152600401610c859061335c565b61242b818361212e565b612448576040516367d9dca160e11b815260040160405180910390fd5b60035460ff16156124af576001600160a01b0384165f908152600c602052604090205460ff16158061249257506001600160a01b0382165f908152600c602052604090205460ff16155b156124af5760405162461bcd60e51b8152600401610c8590613386565b5f838152600f602052604080822080546001600160a01b0319166001600160a01b0388811691821790925591518693918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a450505050565b5f546001600160a01b031633146125575760405162461bcd60e51b815260206004820152601060248201526f21b0b63632b9103737ba1037bbb732b960811b6044820152606401610c85565b565b5f81806001116125b1576006548110156125b1575f818152600d602052604081205490600160e01b821690036125af575b805f036125a857505f19015f818152600d602052604090205461258a565b9392505050565b505b604051636f96cda160e11b815260040160405180910390fd5b6001600160a01b038416158015906125ea57506001600160a01b03831615155b156113ac576011546001600160a01b0316801561266c5760405163657711f560e11b81523360048201526001600160a01b03868116602483015285811660448301526064820185905282169063caee23ea906084015f6040518083038186803b158015612655575f5ffd5b505afa158015612667573d5f5f3e3d5ffd5b505050505b612678858585856129a9565b5050505050565b5f5b81811015611d5a574260285f612697848761319c565b815260208101919091526040015f2080546bffffffffffffffffffffffff19166001600160601b0392909216919091179055600101612681565b6001600160a01b0381165f90815260018301602052604081205415156125a8565b600180546001600160a01b0319169055611af181612a7f565b60026012540361275d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c85565b6002601255565b610eaa828260405180602001604052805f815250612ace565b601a54612788610f31565b03612557576040514281527f6de05000f2ce26161656abd29f612de4681eea9bda02a88bfd0705e95197c5c99060200160405180910390a1600a805460ff19166001179055565b6011546001600160a01b0390811690821681036127ff5760405163251dd8cf60e11b815260040160405180910390fd5b601180546001600160a01b0319166001600160a01b0384811691821790925560408051928416835260208301919091527fcc5dc080ff977b3c3a211fa63ab74f90f658f5ba9d3236e92c8f59570f442aac9101610cdb565b5f6125a8836001600160a01b038416612b32565b5f6125a8836001600160a01b038416612b7e565b604051630a85bd0160e11b81525f906001600160a01b0385169063150b7a02906128b3903390899088908890600401613453565b6020604051808303815f875af19250505080156128ed575060408051601f3d908101601f191682019092526128ea9181019061348f565b60015b612949573d80801561291a576040519150601f19603f3d011682016040523d82523d5f602084013e61291f565b606091505b5080515f03612941576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b606060a06040510180604052602081039150505f815280825b600183039250600a81066030018353600a90048061297f5750819003601f19909101908152919050565b6001600160a01b0384161515806129da57506129c4826114aa565b6001600160a01b0316336001600160a01b031614155b156113ac57335f908152600b602052604090205460ff1615612a0e5760405162461bcd60e51b8152600401610c859061335c565b6001600160a01b0383165f908152600b602052604090205460ff1615612a465760405162461bcd60e51b8152600401610c859061335c565b60035460ff16156113ac57335f908152600c602052604090205460ff166113ac5760405162461bcd60e51b8152600401610c8590613386565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f641674195e501e153fbba0a9778a05f0a3f5bae67289429ad99b7c7bbb5660209190a35050565b612ad88383612c61565b6001600160a01b0383163b156113cc576006548281035b612b015f86838060010194508661287f565b612b1e576040516368d2bf6b60e11b815260040160405180910390fd5b818110612aef578160065414612678575f5ffd5b5f818152600183016020526040812054612b7757508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610c1c565b505f610c1c565b5f8181526001830160205260408120548015612c58575f612ba060018361321d565b85549091505f90612bb39060019061321d565b9050808214612c12575f865f018281548110612bd157612bd16133b4565b905f5260205f200154905080875f018481548110612bf157612bf16133b4565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080612c2357612c236134aa565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f905560019350505050610c1c565b5f915050610c1c565b6006545f829003612c855760405163b562e8dd60e01b815260040160405180910390fd5b612c915f8483856125ca565b6001600160a01b0383165f818152600e602090815260408083208054680100000000000000018802019055848352600d90915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612d3d5780835f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f5fa4600101612d07565b50815f03612d5d57604051622e076360e81b815260040160405180910390fd5b600655506113cc5f84838561267f565b6001600160e01b031981168114611af1575f5ffd5b5f60208284031215612d92575f5ffd5b81356125a881612d6d565b80356001600160a01b0381168114612db3575f5ffd5b919050565b5f5f60408385031215612dc9575f5ffd5b612dd283612d9d565b915060208301356001600160601b0381168114612ded575f5ffd5b809150509250929050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6125a86020830184612df8565b5f60208284031215612e48575f5ffd5b5035919050565b5f5f60408385031215612e60575f5ffd5b612e6983612d9d565b946020939093013593505050565b80358015158114612db3575f5ffd5b5f5f60408385031215612e97575f5ffd5b612ea083612d9d565b9150612eae60208401612e77565b90509250929050565b5f5f5f60608486031215612ec9575f5ffd5b612ed284612d9d565b9250612ee060208501612d9d565b929592945050506040919091013590565b5f5f60408385031215612f02575f5ffd5b50508035926020909101359150565b5f60208284031215612f21575f5ffd5b6125a882612d9d565b5f5f60208385031215612f3b575f5ffd5b823567ffffffffffffffff811115612f51575f5ffd5b8301601f81018513612f61575f5ffd5b803567ffffffffffffffff811115612f77575f5ffd5b856020828401011115612f88575f5ffd5b6020919091019590945092505050565b5f60208284031215612fa8575f5ffd5b6125a882612e77565b5f5f5f5f5f60a08688031215612fc5575f5ffd5b505083359560208501359550604085013594606081013594506080013592509050565b5f5f5f5f60608587031215612ffb575f5ffd5b843567ffffffffffffffff811115613011575f5ffd5b8501601f81018713613021575f5ffd5b803567ffffffffffffffff811115613037575f5ffd5b8760208260051b840101111561304b575f5ffd5b60209182019550935061305f908601612e77565b9396929550929360400135925050565b634e487b7160e01b5f52604160045260245ffd5b5f5f5f5f60808587031215613096575f5ffd5b61309f85612d9d565b93506130ad60208601612d9d565b925060408501359150606085013567ffffffffffffffff8111156130cf575f5ffd5b8501601f810187136130df575f5ffd5b803567ffffffffffffffff8111156130f9576130f961306f565b604051601f8201601f19908116603f0116810167ffffffffffffffff811182821017156131285761312861306f565b60405281815282820160200189101561313f575f5ffd5b816020840160208301375f6020838301015280935050505092959194509250565b5f5f60408385031215613171575f5ffd5b61317a83612d9d565b9150612eae60208401612d9d565b634e487b7160e01b5f52601160045260245ffd5b80820180821115610c1c57610c1c613188565b600181811c908216806131c357607f821691505b6020821081036131e157634e487b7160e01b5f52602260045260245ffd5b50919050565b8082028115828204841417610c1c57610c1c613188565b5f8261321857634e487b7160e01b5f52601260045260245ffd5b500490565b81810381811115610c1c57610c1c613188565b601f8211156113cc57805f5260205f20601f840160051c810160208510156132555750805b601f840160051c820191505b81811015612678575f8155600101613261565b67ffffffffffffffff83111561328c5761328c61306f565b6132a08361329a83546131af565b83613230565b5f601f8411600181146132d1575f85156132ba5750838201355b5f19600387901b1c1916600186901b178355612678565b5f83815260208120601f198716915b8281101561330057868501358255602094850194600190920191016132e0565b508682101561331c575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208152816020820152818360408301375f818301604090810191909152601f909201601f19160101919050565b60208082526010908201526f13dc195c985d1bdc88189b1bd8dad95960821b604082015260600190565b60208082526014908201527313dc195c985d1bdc881b9bdd08185b1b1bddd95960621b604082015260600190565b634e487b7160e01b5f52603260045260245ffd5b5f5f84546133d5816131af565b6001821680156133ec57600181146134015761342e565b60ff198316865281151582028601935061342e565b875f5260205f205f5b838110156134265781548882015260019091019060200161340a565b505081860193505b50505083518060208601835e64173539b7b760d91b9101908152600501949350505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f9061348590830184612df8565b9695505050505050565b5f6020828403121561349f575f5ffd5b81516125a881612d6d565b634e487b7160e01b5f52603160045260245ffdfea2646970667358221220e877b249d1e1ed1ccad444370e46cf3bcd790757c5ac5b34c83764bc408ccd5764736f6c634300081d0033
Verified Source Code Full Match
Compiler: v0.8.29+commit.ab55807c
EVM: cancun
Optimization: Yes (200 runs)
IERC2981.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*
* NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the
* royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
ERC2981.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.20;
import {IERC2981} from "../../interfaces/IERC2981.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the ERC. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo internal _defaultRoyaltyInfo;
mapping(uint256 tokenId => RoyaltyInfo) internal _tokenRoyaltyInfo;
/**
* @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
/**
* @dev The default royalty receiver is invalid.
*/
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
/**
* @dev The royalty set for an specific `tokenId` is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
/**
* @dev The royalty receiver for `tokenId` is invalid.
*/
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) public view virtual returns (address receiver, uint256 amount) {
RoyaltyInfo storage _royaltyInfo = _tokenRoyaltyInfo[tokenId];
address royaltyReceiver = _royaltyInfo.receiver;
uint96 royaltyFraction = _royaltyInfo.royaltyFraction;
if (royaltyReceiver == address(0)) {
royaltyReceiver = _defaultRoyaltyInfo.receiver;
royaltyFraction = _defaultRoyaltyInfo.royaltyFraction;
}
uint256 royaltyAmount = (salePrice * royaltyFraction) / _feeDenominator();
return (royaltyReceiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));
}
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));
}
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
//function _resetTokenRoyalty(uint256 tokenId) internal virtual {
// delete _tokenRoyaltyInfo[tokenId];
//}
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 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);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
EnumerableSet.sol 375 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
}
MADCDropErrorsAndEvents.sol 65 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;
interface MADCDropErrorsAndEvents {
/**
* @dev Revert if the royalty basis points is greater than 10_000.
*/
error InvalidRoyaltyBasisPoints(uint256 basisPoints);
/**
* @dev Revert if the royalty address is being set to the zero address.
*/
error RoyaltyAddressCannotBeZeroAddress();
/**
* @dev Failed to claim the MasterCyborg role.
*/
error URIFrozen();
/// @dev emit a mint event for mintFor() and mint()
event Minted(address minter, uint256 mintAmount);
// @dev emit an event for token transfer with holding time update
event TokenHeldTime(address from, uint256 tokenId, uint256 heldTime);
// @dev Emit an event for mintOut
event MintOutAchieved(uint256 mintOutTime);
/**
* @dev Emit an event for token metadata reveals/updates,
* according to EIP-4906.
*
* @param _fromTokenId The start token id.
* @param _toTokenId The end token id.
*/
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
/**
* @dev Emit an event when the URI for the collection-level metadata
* is updated.
*/
event TokenURIUpdated(string newTokentURI);
/**
* @dev Emit an event when the URI for the collection-level metadata
* is updated.
*/
event ContractURIUpdated(string newContractURI);
/**
* @dev Emit an event when the royalties info is updated.
*/
event RoyaltyInfoUpdated(address receiver, uint256 bps);
/**
* @dev Emit an event when Manager Role is granted.
*/
event ContractManagerRoleGranted(address account);
/**
* @dev Emit an event when MasterCyborg position is claimed.
*/
event NewMasterHunter(address EasterEgg);
}
Mad Cyborgs Society.sol 538 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.29;
//-----------------------------------------------------------------//
//-----------------------------------------------------------------//
// _ ___ _ //
// /\/\ __ _ __| | / __\ _| |__ ___ _ __ __ _ ___ //
// / \ / _` |/ _` | / / | | | | '_ \ / _ \| '__/ _` / __| //
// / /\/\ \ (_| | (_| | / /__| |_| | |_) | (_) | | | (_| \__ \ //
// \/ \/\__,_|\__,_| \____/\__, |_.__/ \___/|_| \__, |___/ //
// |___/ |___/ //
// //
//-----------------------------------------------------------------//
//-----------------------------------------------------------------//
import { ERC721AOF } from "lib/ERC721A/contracts/ERC721AOperatorFilters.sol";
import { ReentrancyGuard } from "lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol";
import { ERC721TransferValidator } from "src/lib/ERC721TransferValidator.sol";
import { ICreatorToken, ILegacyCreatorToken } from "src/interfaces/ICreatorToken.sol";
import { ITransferValidator721 } from "src/interfaces/ITransferValidator.sol";
import { ERC2981 } from "@openzeppelin/contracts/token/common/ERC2981.sol";
import { IERC2981 } from "lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol";
import { IERC165 } from "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol";
import { MADCDropErrorsAndEvents } from "MADC/lib/MADCDropErrorsAndEvents.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
/**
* @title Mad Cyborgs (MADC) collection.
* @custom:editor WizArt Labs
* @notice Implements Limit Break's Creator Token Standards transfer
* validation for royalty enforcement.
* @notice Implements Condition to pause secondary sales until mint out.
* Implements premint (mintFor) function (onlyOwner).
* Implements 2 stages allowlist on mint.
* Implements token & wallet holding time tracking.
* Implements query to return tokenIds owned by a wallet.
* Implements freeze contractURI and BaseURI.
* Implements additional operator filters (Blocklist or Allowlist)
* on approvals to further protect from malicious contracts
* and unauthorized protocols (token owners cannot be blocked)
* outside royalty registry - (ERC721AOF).
* @notice ADDED Contract Manager role & an Easter Egg :).
* @notice REMOVED from ERC721A: burn() => no burn of MADCs !!!
* REMOVED from ERC721A: unused mintERC2309
**/
contract MadCyborgs is ERC721AOF, ERC721TransferValidator, ReentrancyGuard, ERC2981, MADCDropErrorsAndEvents {
using EnumerableSet for EnumerableSet.AddressSet;
EnumerableSet.AddressSet private stage1Whitelist;
EnumerableSet.AddressSet private stage2Whitelist;
/// @notice INITIALIZE PARAMETERS
bool public mintPaused = false;
bool public wlMintOpen = true;
uint256 public maxSupply = 5000;
uint256 private preMinted = 1000;
uint256 public stage1Supply = 500;
uint256 public stage2Supply = 1000;
uint256 public stage1Price = 0.1 ether;
uint256 public stage2Price = 0.2 ether;
uint256 public publicPrice = 0.3 ether;
uint256 public walletMintLimit = 1;
address public MasterHunter;
address payable private treasuryAddress;
address payable private salesFeeAddress;
uint96 private salesFeePercent; // SaleFeesPercentage (in basis points, e.g., 500 = 5%)
// @notice CONTRACTMANAGER address.
address public CONTRACT_MANAGER;
/// @notice Track the URI for contract metadata.
string public contractURI;
/// @notice Track if Token metadata is frozen.
/// @dev emit an event when frozen.
bool public isBaseURIFrozen = false;
event BaseURIFrozen();
/// @notice Track if contract metadata is frozen.
/// @dev emit an event when frozen.
bool public isContractURIFrozen = false;
event ContractURIFrozen();
// @dev Mapping from tokenId to tokenData.
mapping(uint256 => uint96) private tokenHoldingStart;
constructor(
string memory name,
string memory symbol,
string memory baseURI,
uint96 _royaltyFeesInBips,
address payable _royaltyAddress,
address payable _salesFeeAddress,
address payable _treasuryAddress,
address _managerAddress,
uint96 _salesFeePercent
) ERC721AOF(name, symbol, baseURI) ERC2981() {
_setDefaultRoyalty(_royaltyAddress, _royaltyFeesInBips);
treasuryAddress = _treasuryAddress;
salesFeePercent = _salesFeePercent;
salesFeeAddress = _salesFeeAddress;
CONTRACT_MANAGER = _managerAddress;
}
/**
* @notice Returns whether the interface is supported.
*
* @param interfaceId The interface id to check against.
*/
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721AOF, ERC2981)
returns (bool)
{
return
interfaceId == type(IERC165).interfaceId ||
interfaceId == type(IERC2981).interfaceId ||
interfaceId == type(ICreatorToken).interfaceId ||
interfaceId == type(ILegacyCreatorToken).interfaceId ||
interfaceId == 0x49064906 || // ERC-4906
super.supportsInterface(interfaceId);
}
/// @notice Public mint function.
function mint(uint256 quantity)
nonReentrant
external
payable {
uint256 supplyStage1 = preMinted + stage1Supply;
require(quantity != 0 && !mintPaused, "0 qty or paused");
if (wlMintOpen && totalSupply() <= supplyStage1 + stage2Supply) {
if(!stage1Whitelist.contains(msg.sender)
&& _totalMinted() + quantity <= supplyStage1) {
require(stage2Whitelist.contains(msg.sender)
&& _totalMinted() + quantity <= supplyStage1 + stage2Supply, "not WL or ended");
}}
require(!wlMintOpen, "WL still Open");
require(_numberMinted(msg.sender) + quantity <= walletMintLimit
&& msg.value >= currentMintPrice() * quantity, "> Wallet limit or paid < price");
require(_totalMinted() + quantity <= maxSupply, "> maxSupply");
_safeMint(msg.sender, quantity);
emit Minted(msg.sender, quantity);
_isMintOut();
}
/**
* @notice Return current mintPrice (related to mintStage).
*/
function currentMintPrice() public view returns (uint256) {
uint256 totalMinted = _totalMinted();
if (totalMinted > preMinted + stage1Supply + stage2Supply) return publicPrice;
if (totalMinted > preMinted + stage1Supply) return stage2Price;
if (totalMinted > preMinted) return stage1Price;
return publicPrice;
}
/**
* @notice Owner & Mananger can set mint stages conditions.
*/
function setStages(uint256 _stage1Supply, uint256 _stage1Price,
uint256 _stage2Supply, uint256 _stage2Price, uint256 _publicPrice) external {
_isManager();
stage1Supply = _stage1Supply;
stage1Price = _stage1Price;
stage2Supply = _stage2Supply;
stage2Price = _stage2Price;
publicPrice = _publicPrice;
}
/**
* @dev Verify if caller is authorized to manage.
*/
function _isManager() private view returns(bool) {
if(msg.sender != owner() && msg.sender != CONTRACT_MANAGER) {
revert ("Not Owner or Manager");
}
return true;
}
/**
* @notice Mint new tokens for an address.
*/
function mintFor(address _wallet, uint256 quantity)
external {
_isManager();
require(quantity != 0, "min 1+");
require(_totalMinted() + quantity <= maxSupply, "MintOut");
_safeMint(_wallet, quantity);
emit Minted(_wallet, quantity);
_isMintOut();
}
/**
* @dev Verify if mintOut and initialize actions if so:
* Allow secondary sales and emit mintout event.
*/
function _isMintOut() internal {
if(_totalMinted() == maxSupply) {
emit MintOutAchieved(block.timestamp);
salesOpen = true;
}
}
/**
* @dev Hook that is called before any token transfer.
* This includes minting. Used to enforce royalties.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal override {
if (from != address(0) && to != address(0)) {
// Call the transfer validator if one is set.
address transferValidator = _transferValidator;
if (transferValidator != address(0)) {
ITransferValidator721(transferValidator).validateTransfer(
msg.sender,
from,
to,
startTokenId
);
}
super._beforeTokenTransfers(from, to, startTokenId, quantity);
}
}
/**
* @dev Override transfer logic to reset token holding time upon transfer.
* Related event: Transfer
*/
function _afterTokenTransfers(address from, address to, uint256 startTokenId,
uint256 quantity) internal override {
//Reset token holdingTime to zero when ownership changes.
for (uint256 i = 0; i < quantity; i++) {
tokenHoldingStart[startTokenId + i] = uint96(block.timestamp);
}
super._afterTokenTransfers(from, to, startTokenId, quantity);
}
/**
* @notice EDITED with Operator Filters in ERC721AOF @MadCyborgs
* @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.
* - Paused until mint Out (Owner/manager can bypass).
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public virtual override {
if(_isManager()) {
_tokenApprovals[tokenId].value = to;
emit Approval(ownerOf(tokenId), to, tokenId);
super.approve(to, tokenId);
}
}
/**
* @notice Get the current holding time of a specific token.
*/
function getTokenHoldingTime(uint256 tokenId) external view returns (uint256) {
require(tokenHoldingStart[tokenId] != 0, "TokenId does not exist");
return block.timestamp - tokenHoldingStart[tokenId];
}
/**
* @notice Get the number of NFTs minted by a wallet.
*/
function numberMinted(address wallet) external view returns (uint256) {
return _numberMinted(wallet);
}
/**
* @notice Pause External public mint function.
*/
function pauseMint(bool _state) external {
_isManager();
mintPaused = _state;
}
/**
* @notice Change max amount of token mintable by address.
*/
function setWalletMintLimit(uint256 _limit) external {
_isManager();
walletMintLimit = _limit;
}
/**
* @notice Cancel whitelisting phase in mint function.
*/
function setWLMintOpen(bool _state) external {
_isManager();
wlMintOpen = _state;
}
/**
* @notice Checks if an address is whitelisted in a specific stage.
* @param account The address to check.
* @return A boolean indicating whether the address is whitelisted and the stage number.
*/
function isWhitelisted(address account) external view returns (bool, uint256) {
if (stage1Whitelist.contains(account)) {
return (true, 1);
}
if (stage2Whitelist.contains(account)) {
return (true, 2);
}
return (false, 0);
}
/**
* @notice Whitelist or remove from the given list of addresses for the specified stage.
* @param add = true to add the address list to WL and false to remove them from it.
* @param accounts The list of addresses to add or remove.
* @param stage The stage (1 or 2) to remove the addresses from.
*/
function addToWhitelist(address[] calldata accounts, bool add, uint256 stage) external {
_isManager();
if (stage == 1) {
for (uint256 i = 0; i < accounts.length; i++) {
if(add = true) {stage1Whitelist.add(accounts[i]);}
if(add == false) {stage1Whitelist.remove(accounts[i]);}
}
} else if (stage == 2) {
for (uint256 i = 0; i < accounts.length; i++) {
if(add = true) {stage2Whitelist.add(accounts[i]);}
if(add == false) {stage2Whitelist.remove(accounts[i]);}
}
} else {
revert("Invalid stage");
}
}
/**
* @notice Sets the base URI for the token metadata and emits an event.
*
* @param newBaseURI The new base URI to set.
*/
function setBaseURI(string calldata newBaseURI) external {
_isManager();
if(isBaseURIFrozen){
revert URIFrozen();
}
// Set the new base URI.
baseURI = newBaseURI;
// Emit an event with the update.
if (totalSupply() != 0) {
emit BatchMetadataUpdate(1, _nextTokenId());
}
}
/**
* @notice For Owner to Freeze tokenURI. This action is irreversible.
*
* @notice emit confirmation event.
*/
function freezeBaseURI() external onlyOwner {
isBaseURIFrozen = true;
emit BaseURIFrozen();
}
/**
* @notice Sets the contract URI for contract metadata.
*
* @param newContractURI The new contract URI.
*/
function setContractURI(string calldata newContractURI) external {
_isManager();
if(isContractURIFrozen){
revert URIFrozen();
}
// Set the new contract URI.
contractURI = newContractURI;
// Emit an event with the update.
emit ContractURIUpdated(newContractURI);
}
/**
* @notice For Owner to Freeze contractURI. This action is irreversible.
* (payable to double confirm).
*
* @notice emit confirmation event.
*/
function freezeContractURI() external onlyOwner {
isContractURIFrozen = true;
emit ContractURIFrozen();
}
/**
* @notice Sets the address and basis points for royalties.
*
*/
function setRoyaltyInfo(address RoyaltyAddress, uint96 RoyaltyFeesInBips) external {
_isManager();
// Revert if the new royalty address is the zero address.
if (RoyaltyAddress == address(0)) {
revert RoyaltyAddressCannotBeZeroAddress();
}
// Revert if the new basis points is greater than 10_000.
if (RoyaltyFeesInBips > 10_000) {
revert InvalidRoyaltyBasisPoints(RoyaltyFeesInBips);
}
// Set the new royalty info.
_setDefaultRoyalty(RoyaltyAddress, RoyaltyFeesInBips);
// Emit an event with the updated params.
emit RoyaltyInfoUpdated(RoyaltyAddress, RoyaltyFeesInBips);
}
/**
* @notice Returns the address that receives royalties.
*/
function royaltyAddress() external view returns (address) {
return _defaultRoyaltyInfo.receiver;
}
/**
* @notice Returns the royalty basis points out of 10_000.
*/
function royaltyBasisPoints() external view returns (uint256) {
return _defaultRoyaltyInfo.royaltyFraction;
}
/**
* @notice Called with the sale price to determine how much royalty
* is owed and to whom.
*
* @ param _tokenId The NFT asset queried for royalty information.
* @param _salePrice The sale price of the NFT asset specified by
* _tokenId.
*
* @return receiver Address of who should be sent the royalty payment.
* @return royaltyAmount The royalty payment amount for _salePrice.
*/
function royaltyInfo(
uint256,
/* _tokenId */
uint256 _salePrice
) public view override returns (address receiver, uint256 royaltyAmount) {
// Put the royalty info on the stack for more efficient access.
RoyaltyInfo storage info = _defaultRoyaltyInfo;
// Set the royalty amount to the sale price times the royalty basis
// points divided by 10_000.
royaltyAmount = (_salePrice * info.royaltyFraction) / 10_000;
// Set the receiver of the royalty.
receiver = info.receiver;
}
/**
* @notice Returns the transfer validation function used.
*/
function getTransferValidationFunction()
external
pure
returns (bytes4 functionSignature, bool isViewFunction)
{
functionSignature = ITransferValidator721.validateTransfer.selector;
isViewFunction = false;
}
/**
* @notice Set the transfer validator. Only callable by the token owner.
*/
function setTransferValidator(address newValidator) external onlyOwner {
// Set the new transfer validator.
_setTransferValidator(newValidator);
}
/**
* @notice Grant the MANAGER role to an address (assign zero address to revoke).
*/
function grantMANAGERRole(address account) external onlyOwner {
CONTRACT_MANAGER = account; // Grant the role to an address
emit ContractManagerRoleGranted(account);
}
/**
* @notice BetterMadThanSorry: Hold >0.5% of the MADC Supply (25MADCs) and more MADCs
* than previous claimer to claim the MasterCyborg Position Onchain :)
*/
function claimMasterHunterPosition() external {
// Claimer must hold >25 MADC and have more MADCs than previous claimer.
require(balanceOf(msg.sender) > totalSupply() * 5/1000
&& balanceOf(msg.sender) > balanceOf(MasterHunter), "Do not qualify");
// Set claimer as the new MasterCyborg.
MasterHunter = msg.sender;
// Emit an event with the updated params.
emit NewMasterHunter(msg.sender);
}
/**
* @notice Split and withdraw ether from contract.
*/
function withdraw() public {
_isManager();
uint256 feesAmount = (address(this).balance * salesFeePercent) / 10000; // Calculate fees in Wei
uint256 salesAmount = address(this).balance - feesAmount; // Remainder goes to Treasury address
// Transfer funds to the respective addresses
(bool feesSuccess, ) = salesFeeAddress.call{value: feesAmount}("");
(bool paymentSuccess, ) = treasuryAddress.call{value: salesAmount}("");
require(feesSuccess && paymentSuccess, "withdraw failed");
}
}
ERC721AOperatorFilters.sol 986 lines
// SPDX-License-Identifier: MIT
// ERC721A-OF Contracts v1.1
// Creator: Chiru Labs
// Edits: WizArt Labs
pragma solidity ^0.8.4;
import { IERC721A } from './IERC721A.sol';
import { OperatorFilters } from "lib/ERC721A/contracts/OperatorFilters.sol";
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721AOF
*
* @custom:editor WizArt Labs
* @custom:edit IMPORTANT: BURN REMOVED COMPLETELY.
* @custom:edit IMPORTANT: ERC2309 REMOVED COMPLETELY.
* @custom:edit IMPORTANT: APPROVALS PAUSED UNDER CONDITION (MINTOUT of MADCDrop)
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721AOF is IERC721A, OperatorFilters {
// Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
// uint256 private _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
/// @notice Track the base URI for token metadata.
string public baseURI;
// Secondary Sales Paused
bool public salesOpen = false;
// Mapping from an address to blocked Operators
mapping(address => bool) private blockedOperators;
// Mapping from an address to allowlisted Operators
mapping(address => bool) private allowlistedOperators;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned.
// See {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - %[224] `burned`%
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - %[128..191] `numberBurned`%
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) internal _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_, string memory initBaseURI__) {
_name = name_;
_symbol = symbol_;
baseURI = initBaseURI__;
_currentIndex = _startTokenId();
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 1;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
unchecked {
return _currentIndex /* - _burnCounter*/ - _startTokenId();
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
return _currentIndex - _startTokenId();
}
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId), ".json")) : '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
// If not burned.
if (packed & _BITMASK_BURNED == 0) {
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `curr` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
//ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @notice EDITED with Operator Filters @MadCyborgs
* @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.
* - Secondary sales must be enabled (mintout).
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public virtual override {
address sender = _msgSenderERC721A();
address owner = ownerOf(tokenId);
require(salesOpen, "Sales paused");
require(!blockedOperators[to], "Operator blocked");
if (sender != owner) {
require(!blockedOperators[sender], "Operator blocked");
if (!isApprovedForAll(owner, sender)) {
revert ApprovalCallerNotOwnerNorApproved();
}
if (isAllowListEnabled) {
if (!allowlistedOperators[to] || !allowlistedOperators[sender]){
revert("Operator not allowed");
}
}
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId].value;
}
/**
* @notice EDITED with Operator Filters @MadCyborgs
* @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.
* - The caller must be an approved operator or not be blocked.
* - Secondary sales must be enabled (mintout).
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
address sender = _msgSenderERC721A();
require(salesOpen, "Sales paused");
require(sender != operator, "selfApproval?");
require(!(blockedOperators[operator] || blockedOperators[sender]), "Operator blocked");
if (isAllowListEnabled) {
require(allowlistedOperators[operator] || allowlistedOperators[sender], "Operator not allowed");
}
_operatorApprovals[sender][operator] = approved;
emit ApprovalForAll(sender, operator, approved);
}
/**
* @notice EDITED with Operator Filters @MadCyborgs
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* - Operator must be approved or not blocked (clear previous approvals).
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
if (blockedOperators[operator]) {return false;}
if (isAllowListEnabled) {
if (!allowlistedOperators[operator]){
return false;
}
}
return _operatorApprovals[owner][operator];
}
/**
* @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. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex && // If within bounds,
_packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) public virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
unchecked {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @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 memory _data
) public virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @notice EDITED with Operator Filters @MadCyborgs
* @dev Hook that is called before a set of serially-ordered token IDs
* are about to be transferred. This includes minting.
* And also called before burning one token.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* 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, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 /** quantity */) internal virtual {
if(from != address(0) || _msgSenderERC721A() != ownerOf(startTokenId)) {
require(!blockedOperators[_msgSenderERC721A()], "Operator blocked");
require(!blockedOperators[to], "Operator blocked");
if (isAllowListEnabled) {
require(allowlistedOperators[_msgSenderERC721A()], "Operator not allowed");
}
}
}
/**
* @dev Hook that is called after a set of serially-ordered token IDs
* have been transferred. This includes minting.
* And also called after one token has been burned.
*
* `startTokenId` - the first token ID to be transferred.
* `quantity` - the amount to be transferred.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 toMasked;
uint256 end = startTokenId + quantity;
// Use assembly to loop and emit the `Transfer` event for gas savings.
// The duplicated `log4` removes an extra check and reduces stack juggling.
// The assembly, together with the surrounding Solidity code, have been
// delicately arranged to nudge the compiler into producing optimized opcodes.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
startTokenId // `tokenId`.
)
// The `iszero(eq(,))` check ensures that large values of `quantity`
// that overflows uint256 will make the loop run out of gas.
// The compiler will optimize the `iszero` away for performance.
for {
let tokenId := add(startTokenId, 1)
} iszero(eq(tokenId, end)) {
tokenId := add(tokenId, 1)
} {
// Emit the `Transfer` event. Similar to above.
log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
}
}
if (toMasked == 0) revert MintToZeroAddress();
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
// Reentrancy protection.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* 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, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
let m := add(mload(0x40), 0xa0)
// Update the free memory pointer to allocate.
mstore(0x40, m)
// Assign the `str` to the end.
str := sub(m, 0x20)
// Zeroize the slot after the string.
mstore(str, 0)
// Cache the end of the memory to calculate the length later.
let end := str
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// prettier-ignore
for { let temp := value } 1 {} {
str := sub(str, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(str, add(48, mod(temp, 10)))
// Keep dividing `temp` until zero.
temp := div(temp, 10)
// prettier-ignore
if iszero(temp) { break }
}
let length := sub(end, str)
// Move the pointer 32 bytes leftwards to make room for the length.
str := sub(str, 0x20)
// Store the length.
mstore(str, length)
}
}
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.2
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
//bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
// function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @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,
bytes calldata data
) external;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom}
* whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the
* zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @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);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
OperatorFilters.sol 54 lines
// SPDX-License-Identifier: MIT
// OperatorFilters Contracts v1.1
// custom:edited @MadCyborgs
pragma solidity ^0.8.4;
import { SellOwnership2Step } from "lib/openzeppelin-contracts/contracts/access/SellOwnership2Step.sol";
abstract contract OperatorFilters is SellOwnership2Step {
bool public isAllowListEnabled = false;
// Mapping from an address to blocked Operators
mapping(address => bool) private blockedOperators;
// Mapping from an address to allowlisted Operators
mapping(address => bool) private allowlistedOperators;
/// @notice events when an Operator is Blocked / allowisted or if allowlist is enabled
event OperatorBlocked(address operator, bool status);
event OperatorAllowlisted(address operator, bool status);
event AllowListEnabled(bool status);
/// @notice Enable AllowList (default: blocklist enabled).
function enableAllowList(bool status) external onlyOwner {
isAllowListEnabled = status;
emit AllowListEnabled(status);
}
/// @notice Add or remove an operator from the allowlist.
function setAllowlistOperator(address operator, bool status) external onlyOwner {
allowlistedOperators[operator] = status;
emit OperatorAllowlisted(operator, status);
}
/// @notice Check if an address is on the Allowlist.
function isAllowedOperator(address operator) public view returns(bool) {
return (allowlistedOperators[operator]);
}
/// @notice Add or remove an operator from the blocklist.
function setBlockedOperator(address operator, bool status) external onlyOwner {
blockedOperators[operator] = status;
emit OperatorBlocked(operator, status);
}
/// @notice Check if an address is on the Blocklist.
function isBlockedOperator(address operator) public view returns(bool) {
return (blockedOperators[operator]);
}
}
Ownable.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event _OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Caller not 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() external virtual onlyOwner {
// _transferOwnership(address(0));
//}
/**
* @notice transfer contract ownership. Set newOwner to address(0) to renounce.
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnershipFree(address newOwner) external virtual onlyOwner {
// require(newOwner != address(0), "newOwner is 0 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);
}
}
SellOwnership2Step.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
// @custom:edits @MadCyborgs
pragma solidity ^0.8.0;
import "./Ownable.sol";
/**
* @dev Contract module which provides 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} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract SellOwnership2Step is Ownable {
address private _pendingOwner;
uint256 private _ownershipPrice;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner, uint256 price);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner, uint256 price) external virtual onlyOwner {
_pendingOwner = newOwner;
_ownershipPrice = price;
emit OwnershipTransferStarted(owner(), newOwner, price);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() external payable {
address sender = _msgSender();
require(pendingOwner() == sender, "Caller not newOwner");
require(msg.value >= _ownershipPrice);
(bool success, ) = payable(owner()).call{value: msg.value}("");
require(success, "Transfer failed");
_transferOwnership(sender);
}
}
IERC2981.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
ReentrancyGuard.sol 69 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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// 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;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
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;
}
}
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);
}
ICreatorToken.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface ICreatorToken {
event TransferValidatorUpdated(address oldValidator, address newValidator);
function getTransferValidator() external view returns (address validator);
function getTransferValidationFunction()
external
view
returns (bytes4 functionSignature, bool isViewFunction);
function setTransferValidator(address validator) external;
}
interface ILegacyCreatorToken {
event TransferValidatorUpdated(address oldValidator, address newValidator);
function getTransferValidator() external view returns (address validator);
function setTransferValidator(address validator) external;
}
ITransferValidator.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface ITransferValidator721 {
/// @notice Ensure that a transfer has been authorized for a specific tokenId
function validateTransfer(
address caller,
address from,
address to,
uint256 tokenId
) external view;
}
interface ITransferValidator1155 {
/// @notice Ensure that a transfer has been authorized for a specific amount of a specific tokenId, and reduce the transferable amount remaining
function validateTransfer(
address caller,
address from,
address to,
uint256 tokenId,
uint256 amount
) external;
}
ERC721TransferValidator.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import { ICreatorToken } from "../interfaces/ICreatorToken.sol";
/**
* @title ERC721TransferValidator
* @notice Functionality to use a transfer validator.
*/
abstract contract ERC721TransferValidator is ICreatorToken {
/// @dev Store the transfer validator. The null address means no transfer validator is set.
address internal _transferValidator;
/// @notice Revert with an error if the transfer validator is being set to the same address.
error SameTransferValidator();
/// @notice Returns the currently active transfer validator.
/// The null address means no transfer validator is set.
function getTransferValidator() external view returns (address) {
return _transferValidator;
}
/// @notice Set the transfer validator.
/// The external method that uses this must include access control.
function _setTransferValidator(address newValidator) internal {
address oldValidator = _transferValidator;
if (oldValidator == newValidator) {
revert SameTransferValidator();
}
_transferValidator = newValidator;
emit TransferValidatorUpdated(oldValidator, newValidator);
}
}
Read Contract
CONTRACT_MANAGER 0xa62f1f40 → address
MasterHunter 0xb0e6a81d → address
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
contractURI 0xe8a3d485 → string
currentMintPrice 0x0561942a → uint256
getApproved 0x081812fc → address
getTokenHoldingTime 0x91984dd0 → uint256
getTransferValidationFunction 0x0d705df6 → bytes4, bool
getTransferValidator 0x098144d4 → address
isAllowListEnabled 0x46f720d2 → bool
isAllowedOperator 0xe18bc08a → bool
isApprovedForAll 0xe985e9c5 → bool
isBaseURIFrozen 0x9ca89fad → bool
isBlockedOperator 0x88924a66 → bool
isContractURIFrozen 0x1c098ac3 → bool
isWhitelisted 0x3af32abf → bool, uint256
maxSupply 0xd5abeb01 → uint256
mintPaused 0x7e4831d3 → bool
name 0x06fdde03 → string
numberMinted 0xdc33e681 → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
pendingOwner 0xe30c3978 → address
publicPrice 0xa945bf80 → uint256
royaltyAddress 0xad2f852a → address
royaltyBasisPoints 0x42260b5d → uint256
royaltyInfo 0x2a55205a → address, uint256
salesOpen 0x729205e7 → bool
stage1Price 0x7d54d055 → uint256
stage1Supply 0x2549f06c → uint256
stage2Price 0x8fedfb51 → uint256
stage2Supply 0x566c6ad3 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletMintLimit 0x74c28561 → uint256
wlMintOpen 0x00725dca → bool
Write Contract 27 functions
These functions modify contract state and require a wallet transaction to execute.
acceptOwnership 0x79ba5097
No parameters
addToWhitelist 0xab75db1d
address[] accounts
bool add
uint256 stage
approve 0x095ea7b3
address to
uint256 tokenId
claimMasterHunterPosition 0xe3b853c5
No parameters
enableAllowList 0x5babdd0e
bool status
freezeBaseURI 0xe7bc8208
No parameters
freezeContractURI 0x20b600ad
No parameters
grantMANAGERRole 0x63c8f38f
address account
mint 0xa0712d68
uint256 quantity
mintFor 0xda1919b3
address _wallet
uint256 quantity
pauseMint 0xf30e6e77
bool _state
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setAllowlistOperator 0x34e5a70e
address operator
bool status
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string newBaseURI
setBlockedOperator 0x1bace9a8
address operator
bool status
setContractURI 0x938e3d7b
string newContractURI
setRoyaltyInfo 0x02fa7c47
address RoyaltyAddress
uint96 RoyaltyFeesInBips
setStages 0x75c40018
uint256 _stage1Supply
uint256 _stage1Price
uint256 _stage2Supply
uint256 _stage2Price
uint256 _publicPrice
setTransferValidator 0xa9fc664e
address newValidator
setWLMintOpen 0x870b9580
bool _state
setWalletMintLimit 0x70517ed4
uint256 _limit
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0x0a276680
address newOwner
uint256 price
transferOwnershipFree 0xd1466508
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address