Address Contract Verified
Address
0x0ad2ec2304117DE6f7375652e4501c5E64ae960c
Balance
0 ETH
Nonce
1
Code Size
15180 bytes
Creator
0x32475DA0...Be58 at tx 0x5680538c...0aae6d
Indexed Transactions
0
Contract Bytecode
15180 bytes
0x6080604052600436106103815760003560e01c806370a08231116101d1578063ad6cb31911610102578063d547741f116100a0578063f2fde38b1161006f578063f2fde38b14610aa3578063f43a22dc14610ac3578063f7b4c18714610ad8578063fb796e6c14610af857600080fd5b8063d547741f14610a0f578063d6492d8114610a2f578063e180bf2014610a45578063e985e9c514610a5a57600080fd5b8063c68861c1116100dc578063c68861c11461099e578063c8788134146109be578063c87b56dd146109d4578063ce69cd20146109f457600080fd5b8063ad6cb31914610955578063b7c0b8e81461096b578063b88d4fde1461098b57600080fd5b806395d89b411161016f578063a217fddf11610149578063a217fddf146108d0578063a22cb465146108e5578063a88fe42d14610905578063acb2faa21461092557600080fd5b806395d89b41146108855780639a48eb511461089a578063a035b1fe146108ba57600080fd5b80638a287e1c116101ab5780638a287e1c146107df5780638da5cb5b146107ff57806391d148541461081d57806394b059ab1461086357600080fd5b806370a082311461077c578063715018a61461079c57806385209ee0146107b157600080fd5b8063248a9ca3116102b65780633ccfd60b116102545780635e1c0746116102235780635e1c07461461071c5780636352211e146107315780636b212908146107515780636c0360eb1461076757600080fd5b80633ccfd60b146106b457806342842e0e146106c95780634fc46b53146106dc57806355f804b3146106fc57600080fd5b80632db11544116102905780632db115441461064b5780632f2ff15d1461065e57806332cb6b0c1461067e57806336568abe1461069457600080fd5b8063248a9ca31461054f5780632a55205a1461057f5780632a9cd076146105be57600080fd5b80630a398b88116103235780631342ff4c116102fd5780631342ff4c146104f757806318160ddd146105175780631998aeef1461053457806323b872dd1461053c57600080fd5b80630a398b881461048a57806311876875146104ce57806312406f61146104e157600080fd5b806306fdde031161035f57806306fdde03146103fd5780630747b8971461041f578063081812fc1461043f578063095ea7b31461047757600080fd5b806301bbb7941461038657806301ffc9a7146103a857806304634d8d146103dd575b600080fd5b34801561039257600080fd5b506103a66103a136600461325a565b610b12565b005b3480156103b457600080fd5b506103c86103c3366004613289565b610b30565b60405190151581526020015b60405180910390f35b3480156103e957600080fd5b506103a66103f83660046132c2565b610b5f565b34801561040957600080fd5b50610412610b86565b6040516103d4919061335a565b34801561042b57600080fd5b506103a661043a3660046133b2565b610c18565b34801561044b57600080fd5b5061045f61045a36600461325a565b610cbf565b6040516001600160a01b0390911681526020016103d4565b6103a66104853660046133f4565b610d1c565b34801561049657600080fd5b506104c06104a536600461341e565b6001600160a01b031660009081526013602052604090205490565b6040519081526020016103d4565b6103a66104dc366004613439565b610d3b565b3480156104ed57600080fd5b506104c060055481565b34801561050357600080fd5b506103a661051236600461325a565b611008565b34801561052357600080fd5b5060085460075403600019016104c0565b6103a661102e565b6103a661054a366004613485565b611170565b34801561055b57600080fd5b506104c061056a36600461325a565b60009081526015602052604090206001015490565b34801561058b57600080fd5b5061059f61059a3660046134c1565b6111a0565b604080516001600160a01b0390931683526020830191909152016103d4565b3480156105ca57600080fd5b506106166105d936600461341e565b6014602052600090815260409020546001600160e01b0381169061ffff600160e01b8204169060ff600160f01b8204811691600160f81b90041684565b604080516001600160e01b03909516855261ffff909316602085015290151591830191909152151560608201526080016103d4565b6103a661065936600461325a565b61125d565b34801561066a57600080fd5b506103a66106793660046134e3565b6113ca565b34801561068a57600080fd5b506104c0611f4081565b3480156106a057600080fd5b506103a66106af3660046134e3565b6113ef565b3480156106c057600080fd5b506103a6611477565b6103a66106d7366004613485565b611625565b3480156106e857600080fd5b506103a66106f73660046133b2565b611655565b34801561070857600080fd5b506103a661071736600461359b565b6116da565b34801561072857600080fd5b506103a66116fe565b34801561073d57600080fd5b5061045f61074c36600461325a565b611708565b34801561075d57600080fd5b506104c060025481565b34801561077357600080fd5b50610412611713565b34801561078857600080fd5b506104c061079736600461341e565b6117a1565b3480156107a857600080fd5b506103a6611809565b3480156107bd57600080fd5b506001546107d290600160a01b900460ff1681565b6040516103d491906135fa565b3480156107eb57600080fd5b506103a66107fa366004613622565b61181b565b34801561080b57600080fd5b506001546001600160a01b031661045f565b34801561082957600080fd5b506103c86108383660046134e3565b60009182526015602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561086f57600080fd5b506104c0600080516020613af783398151915281565b34801561089157600080fd5b506104126118e5565b3480156108a657600080fd5b506103a66108b53660046134c1565b6118f4565b3480156108c657600080fd5b506104c060035481565b3480156108dc57600080fd5b506104c0600081565b3480156108f157600080fd5b506103a661090036600461369e565b611907565b34801561091157600080fd5b506103a66109203660046136c8565b611926565b34801561093157600080fd5b506103c861094036600461341e565b601a6020526000908152604090205460ff1681565b34801561096157600080fd5b506104c060125481565b34801561097757600080fd5b506103a66109863660046136f4565b611949565b6103a661099936600461370f565b611964565b3480156109aa57600080fd5b506103a66109b9366004613622565b61199c565b3480156109ca57600080fd5b506104c060045481565b3480156109e057600080fd5b506104126109ef36600461325a565b611a5e565b348015610a0057600080fd5b506104c0668e1bc9bf04000081565b348015610a1b57600080fd5b506103a6610a2a3660046134e3565b611afb565b348015610a3b57600080fd5b506104c060115481565b348015610a5157600080fd5b506104c0600181565b348015610a6657600080fd5b506103c8610a7536600461378b565b6001600160a01b039182166000908152600e6020908152604080832093909416825291909152205460ff1690565b348015610aaf57600080fd5b506103a6610abe36600461341e565b611b20565b348015610acf57600080fd5b506104c0600281565b348015610ae457600080fd5b506103a6610af33660046137b5565b611bb0565b348015610b0457600080fd5b50600f546103c89060ff1681565b600080516020613af7833981519152610b2a81611bd1565b50600255565b6000610b3b82611bdb565b80610b4a5750610b4a82611c5b565b80610b595750610b5982611c5b565b92915050565b600080516020613af7833981519152610b7781611bd1565b610b818383611c99565b505050565b606060098054610b95906137d6565b80601f0160208091040260200160405190810160405280929190818152602001828054610bc1906137d6565b8015610c0e5780601f10610be357610100808354040283529160200191610c0e565b820191906000526020600020905b815481529060010190602001808311610bf157829003601f168201915b5050505050905090565b600080516020613af7833981519152610c3081611bd1565b600354600003610c775760405162461bcd60e51b815260206004820152600d60248201526c5072696365206d697373696e6760981b60448201526064015b60405180910390fd5b60005b82811015610cb957610cb1848483818110610c9757610c97613810565b9050602002016020810190610cac919061341e565b611db3565b600101610c7a565b50505050565b6000610cca82612034565b610d00576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506000908152600d60205260409020546001600160a01b031690565b81600f5460ff1615610d3157610d3181612069565b610b8183836120ad565b600260005403610d8d5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c6e565b60026000908155600454339103610de65760405162461bcd60e51b815260206004820152601060248201527f446973636f756e74206d697373696e67000000000000000000000000000000006044820152606401610c6e565b600554600003610e385760405162461bcd60e51b815260206004820152601060248201527f4f47205072696365206d697373696e67000000000000000000000000000000006044820152606401610c6e565b6002600154600160a01b900460ff166003811115610e5857610e586135e4565b14610ea55760405162461bcd60e51b815260206004820152601360248201527f50726976617465206d696e7420636c6f736564000000000000000000000000006044820152606401610c6e565b6001600160a01b038116600090815260136020526040902054610ec990600161383c565b841115610f185760405162461bcd60e51b815260206004820152601360248201527f57616c6c6574206d6178206578636565646564000000000000000000000000006044820152606401610c6e565b610f23838383612173565b15610f69576001600160a01b03811660009081526013602052604081208054869290610f5090849061384f565b92505081905550610f6481856005546121fa565b610ffd565b610f748383836122c5565b15610fb5576001600160a01b03811660009081526013602052604081208054869290610fa190849061384f565b92505081905550610f6481856004546121fa565b60405162461bcd60e51b815260206004820152601060248201527f4e6f7420696e2077686974656c697374000000000000000000000000000000006044820152606401610c6e565b505060016000555050565b600080516020613af783398151915261102081611bd1565b61102a3383612342565b5050565b60018054600160a01b900460ff16600381111561104d5761104d6135e4565b1461109a5760405162461bcd60e51b815260206004820152600e60248201527f426964206e6f74206163746976650000000000000000000000000000000000006044820152606401610c6e565b33600090815260146020526040902080546001600160e01b03163401668e1bc9bf04000081101561110d5760405162461bcd60e51b815260206004820152600760248201527f426964206c6f77000000000000000000000000000000000000000000000000006044820152606401610c6e565b81546001600160e01b0319166001600160e01b038216178255604080513381523460208201529081018290524760608201527f4dcc013473324698bfbe263facec4ea4b1bc43624236542deabec62c2122b3059060800160405180910390a15050565b826001600160a01b038116331461119557600f5460ff16156111955761119533612069565b610cb984848461235c565b60008281526017602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046bffffffffffffffffffffffff1692820192909252829161121f5750604080518082019091526016546001600160a01b0381168252600160a01b90046bffffffffffffffffffffffff1660208201525b602081015160009061271090611243906bffffffffffffffffffffffff1687613862565b61124d919061388f565b91519350909150505b9250929050565b6002600054036112af5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610c6e565b6002600090815560035490036112f75760405162461bcd60e51b815260206004820152600d60248201526c5072696365206d697373696e6760981b6044820152606401610c6e565b6003600154600160a01b900460ff166003811115611317576113176135e4565b146113645760405162461bcd60e51b815260206004820152601260248201527f5075626c6963206d696e7420636c6f73656400000000000000000000000000006044820152606401610c6e565b60028111156113b55760405162461bcd60e51b815260206004820152601860248201527f5472616e73616374696f6e206d617820657863656564656400000000000000006044820152606401610c6e565b6113c233826003546121fa565b506001600055565b6000828152601560205260409020600101546113e581611bd1565b610b81838361253d565b6001600160a01b038116331461146d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610c6e565b61102a82826125df565b600080516020613af783398151915261148f81611bd1565b47806114dd5760405162461bcd60e51b815260206004820152601360248201527f496e737566666963656e742062616c616e6365000000000000000000000000006044820152606401610c6e565b732f370e211b6eb193a13f6f92d49557ba630da86c6108fc6103e86115038460af613862565b61150d919061388f565b6040518115909202916000818181858888f19350505050158015611535573d6000803e3d6000fd5b5060065460ff166115e55760328110156115915760405162461bcd60e51b815260206004820152601560248201527f496e73756666696369656e74204c756d702053756d00000000000000000000006044820152606401610c6e565b60405173200083b855baab7607cb07d67cb6380b487807cc906000906802b5e3af16b18800009082818181858883f193505050501580156115d6573d6000803e3d6000fd5b506006805460ff191660011790555b604051730367e5800f7011f008143e453e8f7ad36a85c350904780156108fc02916000818181858888f19350505050158015610b81573d6000803e3d6000fd5b826001600160a01b038116331461164a57600f5460ff161561164a5761164a33612069565b610cb9848484612662565b600080516020613af783398151915261166d81611bd1565b60005b82811015610cb95760006014600086868581811061169057611690613810565b90506020020160208101906116a5919061341e565b6001600160a01b03168152602081019190915260400160002080546001600160f81b0316600160f81b17905550600101611670565b600080516020613af78339815191526116f281611bd1565b6010610b8183826138e9565b61170661267d565b565b6000610b598261269c565b60108054611720906137d6565b80601f016020809104026020016040519081016040528092919081815260200182805461174c906137d6565b80156117995780601f1061176e57610100808354040283529160200191611799565b820191906000526020600020905b81548152906001019060200180831161177c57829003601f168201915b505050505081565b60006001600160a01b0382166117e3576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506001600160a01b03166000908152600c602052604090205467ffffffffffffffff1690565b611811612724565b611706600061277e565b600080516020613af783398151915261183381611bd1565b8382146118825760405162461bcd60e51b815260206004820152601160248201527f4d69736d617463686564206172726179730000000000000000000000000000006044820152606401610c6e565b60005b848110156118dd576118d58686838181106118a2576118a2613810565b90506020020160208101906118b7919061341e565b8585848181106118c9576118c9613810565b905060200201356127dd565b600101611885565b505050505050565b6060600a8054610b95906137d6565b6118fc612724565b601191909155601255565b81600f5460ff161561191c5761191c81612069565b610b81838361288c565b600080516020613af783398151915261193e81611bd1565b610cb98484846128f8565b611951612724565b600f805460ff1916911515919091179055565b836001600160a01b038116331461198957600f5460ff16156119895761198933612069565b61199585858585612972565b5050505050565b600080516020613af78339815191526119b481611bd1565b838214611a035760405162461bcd60e51b815260206004820152601160248201527f4d69736d617463686564206172726179730000000000000000000000000000006044820152606401610c6e565b60005b848110156118dd57611a56868683818110611a2357611a23613810565b9050602002016020810190611a38919061341e565b858584818110611a4a57611a4a613810565b905060200201356129b6565b600101611a06565b6060611a6982612034565b611a9f576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611aa9612a29565b90508051600003611ac95760405180602001604052806000815250611af4565b80611ad384612a38565b604051602001611ae49291906139a9565b6040516020818303038152906040525b9392505050565b600082815260156020526040902060010154611b1681611bd1565b610b8183836125df565b611b28612724565b6001600160a01b038116611ba45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610c6e565b611bad8161277e565b50565b600080516020613af7833981519152611bc881611bd1565b61102a82612a7c565b611bad8133612bf8565b60006301ffc9a760e01b6001600160e01b031983161480611c2557507f80ac58cd000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b80610b595750506001600160e01b0319167f5b5e139f000000000000000000000000000000000000000000000000000000001490565b60006001600160e01b031982167f2a55205a000000000000000000000000000000000000000000000000000000001480610b595750610b5982612c78565b6127106bffffffffffffffffffffffff82161115611d1f5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c655072696365000000000000000000000000000000000000000000006064820152608401610c6e565b6001600160a01b038216611d755760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401610c6e565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff9091166020909201829052600160a01b90910217601655565b6001600160a01b03811660009081526014602052604081208054909190611dee906001600160e01b03811690600160f81b900460ff16612cc6565b905080611dfe6007546000190190565b611e08919061384f565b6002541015611e595760405162461bcd60e51b815260206004820152601860248201527f4578636565646564206d696e742062696420737570706c7900000000000000006044820152606401610c6e565b6001600160a01b038316600090815260146020526040902054600160f01b900460ff1615611ec95760405162461bcd60e51b815260206004820152601060248201527f416c726561647920726566756e646564000000000000000000000000000000006044820152606401610c6e565b815460ff60f01b1916600160f01b1782556000611ee584612cea565b8354909150600160f81b900460ff16611f05575081546001600160e01b03165b6000846001600160a01b03168260405160006040518083038185875af1925050503d8060008114611f52576040519150601f19603f3d011682016040523d82523d6000602084013e611f57565b606091505b5050905080611f985760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b6044820152606401610c6e565b8215611995578354600160e01b900461ffff1615611ff85760405162461bcd60e51b815260206004820152601260248201527f416c72656164792061697264726f7070656400000000000000000000000000006044820152606401610c6e565b83547fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e01b61ffff85160217845561199585846129b6565b600081600111158015612048575060075482105b8015610b595750506000908152600b6020526040902054600160e01b161590565b69c617113400112233445560005230601a5280603a52600080604460166daaeb6d7670e522a718067333cd4e5afa6120a5573d6000803e3d6000fd5b6000603a5250565b60006120b882611708565b9050336001600160a01b0382161461210a576120d48133610a75565b61210a576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000828152600d6020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6040516bffffffffffffffffffffffff19606083901b16602082015260009081906034016040516020818303038152906040528051906020012090506012546121f0868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250869250612d1a915050565b1495945050505050565b6122048282613862565b34146122525760405162461bcd60e51b815260206004820152601060248201527f496e636f727265637420616d6f756e74000000000000000000000000000000006044820152606401610c6e565b611f40826122636007546000190190565b61226d919061384f565b11156122bb5760405162461bcd60e51b815260206004820152600e60248201527f546f74616c2065786365656465640000000000000000000000000000000000006044820152606401610c6e565b610b818383612342565b6040516bffffffffffffffffffffffff19606083901b16602082015260009081906034016040516020818303038152906040528051906020012090506011546121f0868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250869250612d1a915050565b61102a828260405180602001604052806000815250612d67565b60006123678261269c565b9050836001600160a01b0316816001600160a01b0316146123b4576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000828152600d602052604090208054338082146001600160a01b0388169091141761241a576123e48633610a75565b61241a576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03851661245a576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b801561246557600082555b6001600160a01b038681166000908152600c60205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b176000858152600b6020526040812091909155600160e11b841690036124f757600184016000818152600b602052604081205490036124f55760075481146124f5576000818152600b602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46118dd565b60008281526015602090815260408083206001600160a01b038516845290915290205460ff1661102a5760008281526015602090815260408083206001600160a01b03851684529091529020805460ff1916600117905561259b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526015602090815260408083206001600160a01b038516845290915290205460ff161561102a5760008281526015602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b610b8183838360405180602001604052806000815250611964565b611706733cc6cdda760b79bafa08df41ecfa224f810dceb66001612dcd565b600081806001116126f2576007548110156126f2576000818152600b602052604081205490600160e01b821690036126f0575b80600003611af45750600019016000818152600b60205260409020546126cf565b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546001600160a01b031633146117065760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c6e565b600180546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b038216600081815260146020526040808220805460ff60f01b1916600160f01b178155905190929084908381818185875af1925050503d8060008114612846576040519150601f19603f3d011682016040523d82523d6000602084013e61284b565b606091505b5050905080610cb95760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b6044820152606401610c6e565b336000818152600e602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60018054600160a01b900460ff166003811115612917576129176135e4565b036129645760405162461bcd60e51b815260206004820152600e60248201527f42696464696e67206163746976650000000000000000000000000000000000006044820152606401610c6e565b600392909255600455600555565b61297d848484611170565b6001600160a01b0383163b15610cb95761299984848484612e2d565b610cb9576040516368d2bf6b60e11b815260040160405180910390fd5b611f40816129c76007546000190190565b6129d1919061384f565b1115612a1f5760405162461bcd60e51b815260206004820152600c60248201527f4d617820657863656564656400000000000000000000000000000000000000006044820152606401610c6e565b61102a8282612342565b606060108054610b95906137d6565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a900480612a525750819003601f19909101908152919050565b6001816003811115612a9057612a906135e4565b03612aea5760035415612ae55760405162461bcd60e51b815260206004820152600960248201527f50726963652073657400000000000000000000000000000000000000000000006044820152606401610c6e565b612bb0565b6002816003811115612afe57612afe6135e4565b03612b5557600454600003612ae55760405162461bcd60e51b815260206004820152601060248201527f446973636f756e74206d697373696e67000000000000000000000000000000006044820152606401610c6e565b6003816003811115612b6957612b696135e4565b03612bb057600354600003612bb05760405162461bcd60e51b815260206004820152600d60248201526c5072696365206d697373696e6760981b6044820152606401610c6e565b600180548291907fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b836003811115612bf057612bf06135e4565b021790555050565b60008281526015602090815260408083206001600160a01b038516845290915290205460ff1661102a57612c36816001600160a01b03166014612f19565b612c41836020612f19565b604051602001612c529291906139d8565b60408051601f198184030181529082905262461bcd60e51b8252610c6e9160040161335a565b60006001600160e01b031982167f7965db0b000000000000000000000000000000000000000000000000000000001480610b5957506301ffc9a760e01b6001600160e01b0319831614610b59565b60008115612ce257600354612cdb908461388f565b9050610b59565b506000610b59565b6003546001600160a01b0382166000908152601460205260408120549091610b59916001600160e01b0316613a59565b600081815b8451811015612d5f57612d4b82868381518110612d3e57612d3e613810565b60200260200101516130fa565b915080612d5781613a6d565b915050612d1f565b509392505050565b612d718383613129565b6001600160a01b0383163b15610b81576007548281035b612d9b6000868380600101945086612e2d565b612db8576040516368d2bf6b60e11b815260040160405180910390fd5b818110612d8857816007541461199557600080fd5b6001600160a01b0390911690637d3e3dbe81612dfa5782612df35750634420e486612dfa565b5063a0af29035b8060e01b60005250306004528160245260008060446000806daaeb6d7670e522a718067333cd4e5af15060006024525050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612e62903390899088908890600401613a86565b6020604051808303816000875af1925050508015612e9d575060408051601f3d908101601f19168201909252612e9a91810190613ac2565b60015b612efb573d808015612ecb576040519150601f19603f3d011682016040523d82523d6000602084013e612ed0565b606091505b508051600003612ef3576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b60606000612f28836002613862565b612f3390600261384f565b67ffffffffffffffff811115612f4b57612f4b61350f565b6040519080825280601f01601f191660200182016040528015612f75576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612fac57612fac613810565b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612ff757612ff7613810565b60200101906001600160f81b031916908160001a905350600061301b846002613862565b61302690600161384f565b90505b60018111156130ab577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061306757613067613810565b1a60f81b82828151811061307d5761307d613810565b60200101906001600160f81b031916908160001a90535060049490941c936130a481613adf565b9050613029565b508315611af45760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610c6e565b6000818310613116576000828152602084905260409020611af4565b6000838152602083905260409020611af4565b6007546000829003613167576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383166000818152600c602090815260408083208054680100000000000000018802019055848352600b90915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b81811461321657808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a46001016131de565b5081600003613251576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60075550505050565b60006020828403121561326c57600080fd5b5035919050565b6001600160e01b031981168114611bad57600080fd5b60006020828403121561329b57600080fd5b8135611af481613273565b80356001600160a01b03811681146132bd57600080fd5b919050565b600080604083850312156132d557600080fd5b6132de836132a6565b915060208301356bffffffffffffffffffffffff811681146132ff57600080fd5b809150509250929050565b60005b8381101561332557818101518382015260200161330d565b50506000910152565b6000815180845261334681602086016020860161330a565b601f01601f19169290920160200192915050565b602081526000611af4602083018461332e565b60008083601f84011261337f57600080fd5b50813567ffffffffffffffff81111561339757600080fd5b6020830191508360208260051b850101111561125657600080fd5b600080602083850312156133c557600080fd5b823567ffffffffffffffff8111156133dc57600080fd5b6133e88582860161336d565b90969095509350505050565b6000806040838503121561340757600080fd5b613410836132a6565b946020939093013593505050565b60006020828403121561343057600080fd5b611af4826132a6565b60008060006040848603121561344e57600080fd5b83359250602084013567ffffffffffffffff81111561346c57600080fd5b6134788682870161336d565b9497909650939450505050565b60008060006060848603121561349a57600080fd5b6134a3846132a6565b92506134b1602085016132a6565b9150604084013590509250925092565b600080604083850312156134d457600080fd5b50508035926020909101359150565b600080604083850312156134f657600080fd5b82359150613506602084016132a6565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff808411156135405761354061350f565b604051601f8501601f19908116603f011681019082821181831017156135685761356861350f565b8160405280935085815286868601111561358157600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156135ad57600080fd5b813567ffffffffffffffff8111156135c457600080fd5b8201601f810184136135d557600080fd5b612f1184823560208401613525565b634e487b7160e01b600052602160045260246000fd5b602081016004831061361c57634e487b7160e01b600052602160045260246000fd5b91905290565b6000806000806040858703121561363857600080fd5b843567ffffffffffffffff8082111561365057600080fd5b61365c8883890161336d565b9096509450602087013591508082111561367557600080fd5b506136828782880161336d565b95989497509550505050565b803580151581146132bd57600080fd5b600080604083850312156136b157600080fd5b6136ba836132a6565b91506135066020840161368e565b6000806000606084860312156136dd57600080fd5b505081359360208301359350604090920135919050565b60006020828403121561370657600080fd5b611af48261368e565b6000806000806080858703121561372557600080fd5b61372e856132a6565b935061373c602086016132a6565b925060408501359150606085013567ffffffffffffffff81111561375f57600080fd5b8501601f8101871361377057600080fd5b61377f87823560208401613525565b91505092959194509250565b6000806040838503121561379e57600080fd5b6137a7836132a6565b9150613506602084016132a6565b6000602082840312156137c757600080fd5b813560048110611af457600080fd5b600181811c908216806137ea57607f821691505b60208210810361380a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610b5957610b59613826565b80820180821115610b5957610b59613826565b8082028115828204841417610b5957610b59613826565b634e487b7160e01b600052601260045260246000fd5b60008261389e5761389e613879565b500490565b601f821115610b8157600081815260208120601f850160051c810160208610156138ca5750805b601f850160051c820191505b818110156118dd578281556001016138d6565b815167ffffffffffffffff8111156139035761390361350f565b6139178161391184546137d6565b846138a3565b602080601f83116001811461394c57600084156139345750858301515b600019600386901b1c1916600185901b1785556118dd565b600085815260208120601f198616915b8281101561397b5788860151825594840194600190910190840161395c565b50858210156139995787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600083516139bb81846020880161330a565b8351908301906139cf81836020880161330a565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613a1081601785016020880161330a565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613a4d81602884016020880161330a565b01602801949350505050565b600082613a6857613a68613879565b500690565b600060018201613a7f57613a7f613826565b5060010190565b60006001600160a01b03808716835280861660208401525083604083015260806060830152613ab8608083018461332e565b9695505050505050565b600060208284031215613ad457600080fd5b8151611af481613273565b600081613aee57613aee613826565b50600019019056fed8acb51ff3d48f690a25887aaf234c4ae5a66ab9839243cd8e2b639cade0663ba26469706673582212207d90cd3119d1409883de69b32429493da24a3961d418c35777355c8648316cee64736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (1000 runs)
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;
}
}
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
GenkiBid.sol 145 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "./GenkiMint.sol";
/**
* @author @inetdave
* @dev v.01.00.00
*/
contract GenkiBid is GenkiMint{
uint256 public constant MIN_BID = 0.04 ether;
event Bid(
address bidder,
uint256 bidAmount,
uint256 bidderTotal,
uint256 biddingTotal
);
struct Bidder {
/**
* @dev cumulative sum of ETH bids. this is useful incase bidders are increasing their bid
*/
uint224 contribution;
/**
* @dev tracker for claimed tokens
*/
uint16 tokensClaimed;
/**
* @dev has user been refunded yet
*/
bool refundClaimed;
/**
* @dev process winning bid offchain and set with setWinningBids
*/
bool winningBid;
}
/**
* @dev store the bidder per address.
*/
mapping(address => Bidder) public bidderData;
/**
* @notice place a bid in ETH or add to your existing bid. Calling this
* multiple times will increase your bid amount. All bids placed are final
* and cannot be reversed.
*/
function bid() external payable {
require(contractState == ContractState.BID, "Bid not active");
Bidder storage bidder = bidderData[msg.sender];
uint256 contribution = bidder.contribution; // get user's current bid total
unchecked {
// does not overflow
contribution += msg.value;
}
require(contribution >= MIN_BID, "Bid low");
bidder.contribution = uint224(contribution);
emit Bid(msg.sender, msg.value, contribution, address(this).balance);
}
/**
* @notice process a bidder based on an address
* @dev after bidding is stopped and price is set. run processBiddersFromBatch to handle the airdrop and refund from a array of addresses
* calldata is used.
* if for some reason the refund fails you will need to manually call send tokens to address
* the algorithm must take into account timing of the bid incase there are duplicate bids and maxBidSupply is exceeded
* if the bidder has a winning bid but the max supply is already out then we need to refund them their full contribution
*
* there is no max on bids.
* step 0: off-chain we will calculate the winning bid amount and winners
* step 1: update bidderData if the user is a winner
* step 2: process based on the winner flag
* step 3: continue in this way until maxBidSupply is met
* @param _address address to process
*/
function _processBidder(address _address) internal virtual{
//process refunds first
Bidder storage bidder = bidderData[_address];
uint256 totalWon = _totalWonFromBidding(bidder.contribution, bidder.winningBid);
require(maxBidSupply >= _totalMinted()+totalWon, "Exceeded mint bid supply");
require(!bidderData[_address].refundClaimed, "Already refunded");
bidder.refundClaimed = true;
uint256 refundValue = _refundAmount(_address);
//if the bidder is not a winning bid then refund completely
if (!bidder.winningBid){
refundValue = bidder.contribution;
}
(bool success, ) = _address.call{value: refundValue}("");
require(success, "Refund failed");
//airdrop tokens
if (totalWon > 0) {
require(bidder.tokensClaimed == 0, "Already airdropped");
bidder.tokensClaimed = uint16(totalWon);
_airdropMint(_address, totalWon);
}
}
/**
* @notice process refunds incase the refunds from processBidders was unsuccessful
*/
function _processBidderRefunds(address _address, uint256 _sendRefundAmount) internal{
Bidder storage bidder = bidderData[_address];
bidder.refundClaimed = true;
(bool success, ) = _address.call{value: _sendRefundAmount}("");
require(success, "Refund failed");
}
/**
* @notice get the refund amount for an account, after the clearing price
* has been set.
* @dev helper function.
* @param _bidderAddress address to query.
*/
function _refundAmount(address _bidderAddress) internal view
returns (uint256)
{
return bidderData[_bidderAddress].contribution % price;
}
/**
* @notice based on the price set figure out how many tokens the user gets.
* @dev helper function
*/
function _totalWonFromBidding(uint256 _contribution, bool _winningBid ) internal view
returns (uint256)
{
if (_winningBid)
return _contribution / price;
else{
return 0;
}
}
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// 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 payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @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 payable;
/**
* @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 payable;
/**
* @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);
}
GenkiBase.sol 67 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @author @inetdave
* @dev v.01.00.00
*/
contract GenkiBase is ReentrancyGuard, Ownable {
enum ContractState {
PAUSED,
BID,
WHITELIST,
PUBLIC
}
ContractState public contractState = ContractState.PAUSED;
uint256 public constant MAX_SUPPLY = 8000;
uint256 public constant MAX_PER_PRIVATE_WALLET = 1;
uint256 public constant MAX_PER_TX = 2;
uint256 public maxBidSupply = 2500;
uint256 public price;
uint256 public discountedPrice;
uint256 public OGPrice;
address internal constant ANGEL_INVESTOR = 0x200083b855baab7607cB07d67cB6380B487807cc;
address internal constant VOID_ZERO = 0x2f370e211B6EB193A13F6F92D49557Ba630Da86c;
address internal constant OWNER = 0x0367e5800F7011f008143E453e8F7AD36A85c350;
bool internal _hasPaidLumpSum;
/**@notice set contract state
* @param _contractState set the state of the contract
*/
function _setContractState(ContractState _contractState) internal
{
if (_contractState == ContractState.BID) {
require(price == 0, "Price set");
} else if (_contractState == ContractState.WHITELIST) {
require(discountedPrice != 0, "Discount missing");
} else if (_contractState == ContractState.PUBLIC) {
require(price != 0, "Price missing");
}
contractState = _contractState;
}
/**
* @notice set the clearing price and the discounted price for wl after all bids have been placed.
* @dev set this price in wei, not eth! Can't set price if bidding is active
* @param _price new price, set in wei
* @param _discountedPrice new price, set in wei
* @param _OGPrice new price, set in wei
*/
function _setPrices(uint256 _price, uint256 _discountedPrice, uint256 _OGPrice) internal
{
require(contractState != ContractState.BID, "Bidding active");
price = _price;
discountedPrice = _discountedPrice;
OGPrice = _OGPrice;
}
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.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 ERC721A
*
* @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 ERC721A is IERC721A {
// 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;
// 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) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_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 0;
}
/**
* @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 override 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();
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
// =============================================================
// 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 number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _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();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// 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
// =============================================================
/**
* @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) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_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;
}
/**
* @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) public virtual override {
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
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 payable 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 payable 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 payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @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 {}
/**
* @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 Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
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)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_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, '');
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_burn(tokenId, false)`.
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), 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 {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), 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, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// 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)
}
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC2981.sol 111 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
OperatorFilterer.sol 119 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Optimized and flexible operator filterer to abide to OpenSea's
/// mandatory on-chain royalty enforcement in order for new collections to
/// receive royalties.
/// For more information, see:
/// See: https://github.com/ProjectOpenSea/operator-filter-registry
abstract contract OperatorFilterer {
/// @dev The default OpenSea operator blocklist subscription.
address internal constant _DEFAULT_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;
/// @dev The OpenSea operator filter registry.
address internal constant _OPERATOR_FILTER_REGISTRY = 0x000000000000AAeB6D7670E522A718067333cd4E;
/// @dev Registers the current contract to OpenSea's operator filter,
/// and subscribe to the default OpenSea operator blocklist.
/// Note: Will not revert nor update existing settings for repeated registration.
function _registerForOperatorFiltering() internal virtual {
_registerForOperatorFiltering(_DEFAULT_SUBSCRIPTION, true);
}
/// @dev Registers the current contract to OpenSea's operator filter.
/// Note: Will not revert nor update existing settings for repeated registration.
function _registerForOperatorFiltering(address subscriptionOrRegistrantToCopy, bool subscribe)
internal
virtual
{
/// @solidity memory-safe-assembly
assembly {
let functionSelector := 0x7d3e3dbe // `registerAndSubscribe(address,address)`.
// Clean the upper 96 bits of `subscriptionOrRegistrantToCopy` in case they are dirty.
subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))
for {} iszero(subscribe) {} {
if iszero(subscriptionOrRegistrantToCopy) {
functionSelector := 0x4420e486 // `register(address)`.
break
}
functionSelector := 0xa0af2903 // `registerAndCopyEntries(address,address)`.
break
}
// Store the function selector.
mstore(0x00, shl(224, functionSelector))
// Store the `address(this)`.
mstore(0x04, address())
// Store the `subscriptionOrRegistrantToCopy`.
mstore(0x24, subscriptionOrRegistrantToCopy)
// Register into the registry.
pop(call(gas(), _OPERATOR_FILTER_REGISTRY, 0, 0x00, 0x44, 0x00, 0x00))
// Restore the part of the free memory pointer that was overwritten,
// which is guaranteed to be zero, because of Solidity's memory size limits.
mstore(0x24, 0)
}
}
/// @dev Modifier to guard a function and revert if the caller is a blocked operator.
modifier onlyAllowedOperator(address from) virtual {
if (from != msg.sender) {
if (!_isPriorityOperator(msg.sender)) {
if (_operatorFilteringEnabled()) _revertIfBlocked(msg.sender);
}
}
_;
}
/// @dev Modifier to guard a function from approving a blocked operator..
modifier onlyAllowedOperatorApproval(address operator) virtual {
if (!_isPriorityOperator(operator)) {
if (_operatorFilteringEnabled()) _revertIfBlocked(operator);
}
_;
}
/// @dev Helper function that reverts if the `operator` is blocked by the registry.
function _revertIfBlocked(address operator) private view {
/// @solidity memory-safe-assembly
assembly {
// Store the function selector of `isOperatorAllowed(address,address)`,
// shifted left by 6 bytes, which is enough for 8tb of memory.
// We waste 6-3 = 3 bytes to save on 6 runtime gas (PUSH1 0x224 SHL).
mstore(0x00, 0xc6171134001122334455)
// Store the `address(this)`.
mstore(0x1a, address())
// Store the `operator`.
mstore(0x3a, operator)
// `isOperatorAllowed` always returns true if it does not revert.
if iszero(staticcall(gas(), _OPERATOR_FILTER_REGISTRY, 0x16, 0x44, 0x00, 0x00)) {
// Bubble up the revert if the staticcall reverts.
returndatacopy(0x00, 0x00, returndatasize())
revert(0x00, returndatasize())
}
// We'll skip checking if `from` is inside the blacklist.
// Even though that can block transferring out of wrapper contracts,
// we don't want tokens to be stuck.
// Restore the part of the free memory pointer that was overwritten,
// which is guaranteed to be zero, if less than 8tb of memory is used.
mstore(0x3a, 0)
}
}
/// @dev For deriving contracts to override, so that operator filtering
/// can be turned on / off.
/// Returns true by default.
function _operatorFilteringEnabled() internal view virtual returns (bool) {
return true;
}
/// @dev For deriving contracts to override, so that preferred marketplaces can
/// skip operator filtering, helping users save gas.
/// Returns false for all inputs by default.
function _isPriorityOperator(address) internal view virtual returns (bool) {
return false;
}
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
GenkiBidMint.sol 330 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/*
@@@@@@ @@@@@@@@@@@@@@@ @@@@@@. @@@@@@ /@@@@@& @@@@@@ @@@@@@*
@@@@@@@@@@@@@. @@@@@@@@@@@@@@@& /@@@@@@@. @@@@@@@ .@@@@@@ @@@@@@@ %@@@@@@
.@@@@@@@@@@@@@@@@ #@@@@@@@@@@@@@@@ .@@@@@@@@@ #@@@@@@ @@@@@@. %@@@@@& /@@@@@@
@@@@@@ @@@@@@. *@@@@@@ @@@@@@@@@@ @@@@@@ @@@@@@/ @@@@@@@ .@@@@@@
@@@@@@, @@@@@@ @@@@@@@@@@@ @@@@@@* #@@@@@@*@@@@@@/ @@@@@@/
&@@@@@/ @@@@@@@@@ @@@@@@@@@@@@@@ &@@@@@@@@@@@@@@@@@% *@@@@@@@@@@@@@ @@@@@@@
(@@@@@% #@@@@@@@@ &@@@@@@@@@@@@@* @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@* #@@@@@@
,@@@@@@ /@@@@@@ (@@@@@@/////// @@@@@@*@@@@@@@@@@@ @@@@@@(@@@@@@@ .@@@@@@
@@@@@@ @@@@@@, ,@@@@@@ @@@@@@& /@@@@@@@@@ &@@@@@@ @@@@@@@ @@@@@@
@@@@@@@@&@@@@@@@@ @@@@@@@@@@@@@@@/ &@@@@@@ /@@@@@@@@@ (@@@@@@ @@@@@@ @@@@@@@
(@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@& *@@@@@@ /@@@@@@@@ ,@@@@@@ @@@@@@ %@@@@@@
/@@@@@@@&@@@@ %@@@@@@@@@@@@@@@ @@@@@@ @@@@@@@ @@@@@@ @@@@@@ (@@@@@@
*/
/**
* @title A bidding contract with erc721a token implementation
* @author @inetdave (Void Zero Labs)
* @notice Bidding contract developed with mechanisms for airdrops, refunds, private and public mint
* @dev All function calls have been tested.
* v.01.00.00
*/
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./GenkiBid.sol";
contract GenkiBidMint is GenkiBid, AccessControl, ERC2981 {
bytes32 public constant SUPPORT_ROLE = keccak256("SUPPORT");
address private _royaltiesReceiver;
uint256 private _royaltiesPercentage;
mapping(address => bool) public winningBidders;
constructor() {
// set up roles
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(SUPPORT_ROLE, msg.sender);
}
// ERC165
/**
* @dev See {GenkiBase-_setContractState} for implementation.
*/
function setContractState(ContractState _contractState)
external
onlyRole(SUPPORT_ROLE)
{
_setContractState(_contractState);
}
/**
* @dev See {GenkiBase-_setPrices} for implementation.
*/
function setPrices(
uint256 _price,
uint256 _discountedPrice,
uint256 _OGPrice
) external onlyRole(SUPPORT_ROLE) {
_setPrices(_price, _discountedPrice, _OGPrice);
}
/**
* @dev set the max bid supploy on contract GenkiBase
*/
function setMaxBidSupply(uint256 _maxBidSupply)
external
onlyRole(SUPPORT_ROLE)
{
maxBidSupply = _maxBidSupply;
}
/**
* @notice set winning addresses
* @dev this will be used to run processbidders
*/
function setWinningBids(address[] calldata _addresses)
external
onlyRole(SUPPORT_ROLE)
{
for (uint256 i = 0; i < _addresses.length; ) {
Bidder storage bidder = bidderData[_addresses[i]];
bidder.winningBid = true;
unchecked {
++i;
}
}
}
/**
* @notice process bidders from a list of addresses
* @dev after bidding is stopped and price is set. run to handle the airdrop and refund from a array of addresses
* calldata is used
* @param _addresses adresses to process
*/
function processBidders(address[] calldata _addresses)
external
onlyRole(SUPPORT_ROLE)
{
require(price != 0, "Price missing");
for (uint256 i = 0; i < _addresses.length; ) {
_processBidder(_addresses[i]);
unchecked {
++i;
}
}
}
/**
* @notice incase there is a failure on processBidders use this to handle
* @dev this will update the refund claimed to true
* @param _addresses adresses to process
*/
function processBiddersRefunds(address[] calldata _addresses, uint256[] calldata _refundValues)
external
onlyRole(SUPPORT_ROLE)
{
require(_addresses.length == _refundValues.length, "Mismatched arrays");
for (uint256 i = 0; i < _addresses.length; ) {
_processBidderRefunds(_addresses[i], _refundValues[i]);
unchecked {
++i;
}
}
}
// ERC165
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721A, ERC2981, AccessControl)
returns (bool)
{
return ERC721A.supportsInterface(interfaceId) ||
ERC2981.supportsInterface(interfaceId) || super.supportsInterface(interfaceId);
}
// ERC2981
/**
* @dev See {ERC2981-_setDefaultRoyalty}.
*/
function setDefaultRoyalty(address receiver, uint96 feeNumerator)
external
onlyRole(SUPPORT_ROLE)
{
_setDefaultRoyalty(receiver, feeNumerator);
}
//GENKIMINT
/**
* @dev see {GenkiMint - baseURI}
*/
function setBaseURI(string memory _newBaseURI)
public
onlyRole(SUPPORT_ROLE)
{
baseURI = _newBaseURI;
}
/**
* @dev see {GenkiMint - merkleRoot}
*
*/
function setMerkleRoots(bytes32 _merkleRootWL, bytes32 _merkleRootOG)
external
onlyOwner
{
merkleRootWL = _merkleRootWL;
merkleRootOG = _merkleRootOG;
}
/**
* @dev handles minting from airdrop.
* @param _addresses address array to mint tokens to.
* @param _numbers numbers of tokens to mint.
* @dev state of contract should not be paused. if total number of airdrop tokens exceed MAX_SUPPLY the whole txn will fail.
*/
function airdropMintBatch(
address[] calldata _addresses,
uint256[] calldata _numbers
) external onlyRole(SUPPORT_ROLE) {
require(_addresses.length == _numbers.length, "Mismatched arrays");
for (uint256 i; i < _addresses.length; ) {
_airdropMint(_addresses[i], _numbers[i]);
unchecked {
++i;
}
}
}
/**
* @notice after bidding and airdrop open the whitelist mint.
* wl mint should use the discounted price
* @param _quantity number of tokens users would like to mint.
* @param _merkleProof passed in by user to validate the node
*/
function whiteListMint(uint256 _quantity, bytes32[] calldata _merkleProof)
external
payable
nonReentrant
{
address sender = _msgSenderERC721A();
require(discountedPrice != 0, "Discount missing");
require(OGPrice != 0, "OG Price missing");
require(
contractState == ContractState.WHITELIST,
"Private mint closed"
);
require(
_quantity <= MAX_PER_PRIVATE_WALLET - _alreadyMinted[sender],
"Wallet max exceeded"
);
if (_verifyOG(_merkleProof, sender)) {
_alreadyMinted[sender] += _quantity;
_internalMint(sender, _quantity, OGPrice);
} else if (_verifyWL(_merkleProof, sender)) {
_alreadyMinted[sender] += _quantity;
_internalMint(sender, _quantity, discountedPrice);
} else {
revert("Not in whitelist");
}
}
function publicMint(uint256 _quantity)
external
payable
nonReentrant
{
require(price != 0, "Price missing");
require(contractState == ContractState.PUBLIC, "Public mint closed");
require(_quantity <= MAX_PER_TX, "Transaction max exceeded");
_internalMint(msg.sender, _quantity, price);
}
/**
* @notice tokens to reserve mint.
* @param _quantity number of tokens to reserve mint.
*/
function reserveMint(uint256 _quantity) external onlyRole(SUPPORT_ROLE) {
_safeMint(msg.sender, _quantity);
}
function withdraw() public onlyRole(SUPPORT_ROLE) {
uint256 balance = address(this).balance;
require(balance > 0, "Insufficent balance");
//Operator * not compatible with types uint256.
payable(VOID_ZERO).transfer((balance * 175) / 1000);
if (!_hasPaidLumpSum) {
require(balance >= 50, "Insufficient Lump Sum");
payable(ANGEL_INVESTOR).transfer(50 ether);
_hasPaidLumpSum = true;
}
payable(OWNER).transfer(address(this).balance);
}
//OS Operator Filter
function repeatRegistration() public {
_registerForOperatorFiltering();
}
function setApprovalForAll(address operator, bool approved)
public
override
onlyAllowedOperatorApproval(operator)
{
super.setApprovalForAll(operator, approved);
}
function approve(address operator, uint256 tokenId)
public
payable
override
onlyAllowedOperatorApproval(operator)
{
super.approve(operator, tokenId);
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public payable override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public payable override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, data);
}
function setOperatorFilteringEnabled(bool value) public onlyOwner {
operatorFilteringEnabled = value;
}
function _operatorFilteringEnabled()
internal
view
virtual
override
returns (bool)
{
return operatorFilteringEnabled;
}
}
GenkiMint.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "./GenkiBase.sol";
import "./closedsea/src/OperatorFilterer.sol";
/**
* @author @inetdave
* @dev v.01.00.00
*/
contract GenkiMint is GenkiBase, ERC721A, OperatorFilterer {
constructor() ERC721A("GenkiMint", "GENKI") {
_registerForOperatorFiltering();
operatorFilteringEnabled = true;
}
bool public operatorFilteringEnabled;
string public baseURI;
bytes32 public merkleRootWL;
bytes32 public merkleRootOG;
mapping(address => uint256) internal _alreadyMinted;
/**
* @dev handles minting from airdrop.
* @param _to address to mint tokens to.
* @param _number number of tokens to mint.
*/
function _airdropMint(address _to, uint256 _number) internal {
require(_totalMinted() + _number <= MAX_SUPPLY, "Max exceeded");
_safeMint(_to, _number);
}
function _internalMint(
address _to,
uint256 _quantity,
uint256 _price
) internal {
require(msg.value == _price * _quantity, "Incorrect amount");
require(_totalMinted() + _quantity <= MAX_SUPPLY, "Total exceeded");
_safeMint(_to, _quantity);
}
/**
* @notice WL Mint for OGs
* @dev merklerootog should be set
*/
function _verifyOG(bytes32[] calldata _merkleProof, address _sender)
internal
view
returns (bool)
{
bytes32 leaf = keccak256(abi.encodePacked(_sender));
return MerkleProof.processProof(_merkleProof, leaf) == merkleRootOG;
}
/**
* @notice WL Mint
* @dev merklerootWL should be set
*/
function _verifyWL(bytes32[] calldata _merkleProof, address _sender)
internal
view
returns (bool)
{
bytes32 leaf = keccak256(abi.encodePacked(_sender));
return MerkleProof.processProof(_merkleProof, leaf) == merkleRootWL;
}
function _baseURI() internal view override returns (string memory) {
return baseURI;
}
/**
* @notice used to store the whitelist of who has already minted
*/
function alreadyMinted(address addr) public view returns (uint256) {
return _alreadyMinted[addr];
}
// Start tokenid at 1 instead of 0
function _startTokenId() internal view virtual override returns (uint256) {
return 1;
}
}
MerkleProof.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
* consuming from one or the other at each step according to the instructions given by
* `proofFlags`.
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
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);
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MAX_PER_PRIVATE_WALLET 0xe180bf20 → uint256
MAX_PER_TX 0xf43a22dc → uint256
MAX_SUPPLY 0x32cb6b0c → uint256
MIN_BID 0xce69cd20 → uint256
OGPrice 0x12406f61 → uint256
SUPPORT_ROLE 0x94b059ab → bytes32
alreadyMinted 0x0a398b88 → uint256
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
bidderData 0x2a9cd076 → uint224, uint16, bool, bool
contractState 0x85209ee0 → uint8
discountedPrice 0xc8788134 → uint256
getApproved 0x081812fc → address
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
maxBidSupply 0x6b212908 → uint256
merkleRootOG 0xad6cb319 → bytes32
merkleRootWL 0xd6492d81 → bytes32
name 0x06fdde03 → string
operatorFilteringEnabled 0xfb796e6c → bool
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
price 0xa035b1fe → uint256
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
winningBidders 0xacb2faa2 → bool
Write Contract 27 functions
These functions modify contract state and require a wallet transaction to execute.
airdropMintBatch 0xc68861c1
address[] _addresses
uint256[] _numbers
approve 0x095ea7b3
address operator
uint256 tokenId
bid 0x1998aeef
No parameters
grantRole 0x2f2ff15d
bytes32 role
address account
processBidders 0x0747b897
address[] _addresses
processBiddersRefunds 0x8a287e1c
address[] _addresses
uint256[] _refundValues
publicMint 0x2db11544
uint256 _quantity
renounceOwnership 0x715018a6
No parameters
renounceRole 0x36568abe
bytes32 role
address account
repeatRegistration 0x5e1c0746
No parameters
reserveMint 0x1342ff4c
uint256 _quantity
revokeRole 0xd547741f
bytes32 role
address account
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _newBaseURI
setContractState 0xf7b4c187
uint8 _contractState
setDefaultRoyalty 0x04634d8d
address receiver
uint96 feeNumerator
setMaxBidSupply 0x01bbb794
uint256 _maxBidSupply
setMerkleRoots 0x9a48eb51
bytes32 _merkleRootWL
bytes32 _merkleRootOG
setOperatorFilteringEnabled 0xb7c0b8e8
bool value
setPrices 0xa88fe42d
uint256 _price
uint256 _discountedPrice
uint256 _OGPrice
setWinningBids 0x4fc46b53
address[] _addresses
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
whiteListMint 0x11876875
uint256 _quantity
bytes32[] _merkleProof
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address