Address Contract Verified
Address
0xbcdca41219cCBD72381B2748a8B9B96769a9084F
Balance
0 ETH
Nonce
1
Code Size
14267 bytes
Creator
0x6eDbD013...aE9E at tx 0xdb1bf8e9...d6e9ef
Indexed Transactions
0
Contract Bytecode
14267 bytes
0x6080604052600436106102c65760003560e01c80635a3d54b111610179578063a0712d68116100d6578063d547cfb71161008a578063ee99205c11610064578063ee99205c14610757578063f2fde38b14610777578063f3993d111461079757600080fd5b8063d547cfb71461070d578063e28ab14214610722578063e985e9c51461073757600080fd5b8063b88d4fde116100bb578063b88d4fde146106b8578063c6ab67a3146106d8578063c87b56dd146106ed57600080fd5b8063a0712d6814610685578063a22cb4651461069857600080fd5b80638da5cb5b1161012d5780639ab5cb9c116101125780639ab5cb9c146106325780639cbb9bb6146106455780639dd373b91461066557600080fd5b80638da5cb5b146105ff57806395d89b411461061d57600080fd5b80636352211e1161015e5780636352211e146105aa57806370a08231146105ca578063715018a6146105ea57600080fd5b80635a3d54b1146105745780635a4fee301461058a57600080fd5b80632f745c5911610227578063438b6300116101db5780635437988d116101c05780635437988d1461051e57806355f804b31461053e5780635a34d3561461055e57600080fd5b8063438b6300146104d15780634f6ccce7146104fe57600080fd5b80633ccfd60b1161020c5780633ccfd60b1461048657806340461d9d1461049b57806342842e0e146104b157600080fd5b80632f745c591461044c57806333d9d5fd1461046c57600080fd5b8063109695231161027e5780631b8e384c116102635780631b8e384c146103f957806323b872dd1461040c5780632abb934e1461042c57600080fd5b8063109695231461039c57806318160ddd146103bc57600080fd5b8063081812fc116102af578063081812fc1461032257806308fd9f0b1461035a578063095ea7b31461037c57600080fd5b806301ffc9a7146102cb57806306fdde0314610300575b600080fd5b3480156102d757600080fd5b506102eb6102e6366004613362565b6107b7565b60405190151581526020015b60405180910390f35b34801561030c57600080fd5b50610315610888565b6040516102f79190613597565b34801561032e57600080fd5b5061034261033d3660046133e5565b61091a565b6040516001600160a01b0390911681526020016102f7565b34801561036657600080fd5b5061037a610375366004613328565b610977565b005b34801561038857600080fd5b5061037a6103973660046132fe565b6109d7565b3480156103a857600080fd5b5061037a6103b736600461339c565b610a97565b3480156103c857600080fd5b506103eb6000546001600160801b03600160801b82048116918116919091031690565b6040519081526020016102f7565b61037a610407366004613417565b610af6565b34801561041857600080fd5b5061037a61042736600461322f565b610f37565b34801561043857600080fd5b5061037a61044736600461349a565b610f42565b34801561045857600080fd5b506103eb6104673660046132fe565b611015565b34801561047857600080fd5b50600b546102eb9060ff1681565b34801561049257600080fd5b5061037a61112b565b3480156104a757600080fd5b506103eb60115481565b3480156104bd57600080fd5b5061037a6104cc36600461322f565b6111e9565b3480156104dd57600080fd5b506104f16104ec3660046130fe565b611204565b6040516102f79190613553565b34801561050a57600080fd5b506103eb6105193660046133e5565b6112a6565b34801561052a57600080fd5b5061037a6105393660046130fe565b61136a565b34801561054a57600080fd5b5061037a61055936600461339c565b6113e1565b34801561056a57600080fd5b506103eb600a5481565b34801561058057600080fd5b506103eb60105481565b34801561059657600080fd5b5061037a6105a53660046131aa565b61143c565b3480156105b657600080fd5b506103426105c53660046133e5565b611486565b3480156105d657600080fd5b506103eb6105e53660046130fe565b611498565b3480156105f657600080fd5b5061037a611500565b34801561060b57600080fd5b506007546001600160a01b0316610342565b34801561062957600080fd5b50610315611552565b61037a6106403660046133e5565b611561565b34801561065157600080fd5b5061037a6106603660046133e5565b61187c565b34801561067157600080fd5b5061037a6106803660046130fe565b611a8f565b61037a6106933660046133e5565b611b06565b3480156106a457600080fd5b5061037a6106b33660046132c7565b611d87565b3480156106c457600080fd5b5061037a6106d336600461326b565b611e36565b3480156106e457600080fd5b50610315611e70565b3480156106f957600080fd5b506103156107083660046133e5565b611efe565b34801561071957600080fd5b50610315611f9c565b34801561072e57600080fd5b5061037a611fa9565b34801561074357600080fd5b506102eb610752366004613119565b612073565b34801561076357600080fd5b50601654610342906001600160a01b031681565b34801561078357600080fd5b5061037a6107923660046130fe565b6120c2565b3480156107a357600080fd5b5061037a6107b236600461314c565b61218f565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061081a57506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061084e57506001600160e01b031982167f780e9d6300000000000000000000000000000000000000000000000000000000145b8061088257507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b60606001805461089790613669565b80601f01602080910402602001604051908101604052809291908181526020018280546108c390613669565b80156109105780601f106108e557610100808354040283529160200191610910565b820191906000526020600020905b8154815290600101906020018083116108f357829003601f168201915b5050505050905090565b6000610925826121d1565b61095b576040517fcf4700e400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506000908152600560205260409020546001600160a01b031690565b6007546001600160a01b031633146109c45760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064015b60405180910390fd5b600b805460ff1916911515919091179055565b60006109e282611486565b9050806001600160a01b0316836001600160a01b03161415610a30576040517f943f7b8c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b03821614801590610a505750610a4e8133612073565b155b15610a87576040517fcfb3b94200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610a92838383612205565b505050565b6007546001600160a01b03163314610adf5760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b8051610af2906009906020840190612f09565b5050565b6000610b1a6000546001600160801b03600160801b82048116918116919091031690565b9050323314610b915760405162461bcd60e51b815260206004820152602f60248201527f50757263686173652063616e6e6f742062652063616c6c65642066726f6d206160448201527f6e6f7468657220636f6e7472616374000000000000000000000000000000000060648201526084016109bb565b601454601354610ba191906135db565b610bab88836135db565b1115610bf95760405162461bcd60e51b815260206004820152601660248201527f45786365656473206d6178696d756d20737570706c790000000000000000000060448201526064016109bb565b60135487601154610c0a91906135db565b1115610c6b5760405162461bcd60e51b815260206004820152602a60248201527f45786365656473206d6178696d756d20737570706c79206d696e7461626c65206044820152693bb4ba341032ba3432b960b11b60648201526084016109bb565b336000908152600d60205260409020548490610c889089906135db565b1115610cfc5760405162461bcd60e51b815260206004820152603160248201527f45786365656473206d6178696d756d20616c6c6f77206c69737420737570706c60448201527f7920666f7220746869732077616c6c657400000000000000000000000000000060648201526084016109bb565b86600e54610d0a9190613607565b341015610d595760405162461bcd60e51b815260206004820152601960248201527f45746865722073656e74206973206e6f7420636f72726563740000000000000060448201526064016109bb565b6000610d9c338989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061226e92505050565b6015549091506001600160a01b03808316911614610dfc5760405162461bcd60e51b815260206004820152601660248201527f556e7665726966696564207472616e73616374696f6e0000000000000000000060448201526064016109bb565b610e3d338686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061226e92505050565b6015549091506001600160a01b03808316911614610ec35760405162461bcd60e51b815260206004820152602260248201527f556e7665726966696564206d617820616c6c6f776c697374207369676e61747560448201527f726500000000000000000000000000000000000000000000000000000000000060648201526084016109bb565b8760116000828254610ed591906135db565b9091555050336000908152600d6020526040812080548a9290610ef99084906135db565b90915550610f1b90503389604051806020016040528060008152506000612316565b610f2d610f2889846135db565b6124e4565b5050505050505050565b610a9283838361253a565b6007546001600160a01b03163314610f8a5760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b601254610f9782846135db565b1461100a5760405162461bcd60e51b815260206004820152602160248201527f416d6f756e7473206d7573742061646420757020746f206d617820737570706c60448201527f790000000000000000000000000000000000000000000000000000000000000060648201526084016109bb565b601391909155601455565b600061102083611498565b8210611058576040517f0ddac30e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080546001600160801b03169080805b8381101561112557600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b810467ffffffffffffffff1692820192909252600160e01b90910460ff1615801592820192909252906110d1575061111d565b80516001600160a01b0316156110e657805192505b876001600160a01b0316836001600160a01b0316141561111b57868414156111145750935061088292505050565b6001909301925b505b600101611069565b50600080fd5b6007546001600160a01b031633146111735760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b6007546040516001600160a01b03909116904780156108fc02916000818181858888f193505050506111e75760405162461bcd60e51b815260206004820152601560248201527f576974686472617720756e7375636365737366756c000000000000000000000060448201526064016109bb565b565b610a9283838360405180602001604052806000815250611e36565b6060600061121183611498565b905060008167ffffffffffffffff81111561122e5761122e61372b565b604051908082528060200260200182016040528015611257578160200160208202803683370190505b50905060005b8281101561129e5761126f8582611015565b82828151811061128157611281613715565b602090810291909101015280611296816136a4565b91505061125d565b509392505050565b600080546001600160801b031681805b8281101561133757600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b810467ffffffffffffffff1692820192909252600160e01b90910460ff1615159181018290529061132e57858314156113275750949350505050565b6001909201915b506001016112b6565b506040517fa723001c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6007546001600160a01b031633146113b25760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b6015805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6007546001600160a01b031633146114295760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b8051610af2906008906020840190612f09565b60005b825181101561147f5761146d858585848151811061145f5761145f613715565b602002602001015185611e36565b80611477816136a4565b91505061143f565b5050505050565b6000611491826127a2565b5192915050565b60006001600160a01b0382166114da576040517f8f4eb60400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506001600160a01b031660009081526004602052604090205467ffffffffffffffff1690565b6007546001600160a01b031633146115485760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b6111e760006128df565b60606002805461089790613669565b60006115856000546001600160801b03600160801b82048116918116919091031690565b600b5490915060ff16156115db5760405162461bcd60e51b815260206004820152600e60248201527f4d696e74696e672070617573656400000000000000000000000000000000000060448201526064016109bb565b601454826010546115ec91906135db565b11156116605760405162461bcd60e51b815260206004820152602960248201527f45786365656473206d6178696d756d20737570706c79206d696e7461626c652060448201527f776974682065676773000000000000000000000000000000000000000000000060648201526084016109bb565b6000600f54836116709190613607565b600b546040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815233600482015230602482015291925082916101009091046001600160a01b03169063dd62ed3e9060440160206040518083038186803b1580156116db57600080fd5b505afa1580156116ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171391906133fe565b10156117615760405162461bcd60e51b815260206004820152601660248201527f496e73756666696369656e7420416c6c6f77616e63650000000000000000000060448201526064016109bb565b600b546040516323b872dd60e01b8152336004820152306024820152604481018390526101009091046001600160a01b0316906323b872dd90606401602060405180830381600087803b1580156117b757600080fd5b505af11580156117cb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ef9190613345565b61183b5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572204661696c6564000000000000000000000000000000000060448201526064016109bb565b826010600082825461184d91906135db565b9091555061186f90503384604051806020016040528060008152506000612316565b610a92610f2884846135db565b6007546001600160a01b031633146118c45760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b600b546040517f095ea7b3000000000000000000000000000000000000000000000000000000008152306004820152602481018390526101009091046001600160a01b03169063095ea7b390604401602060405180830381600087803b15801561192d57600080fd5b505af1158015611941573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119659190613345565b6119b15760405162461bcd60e51b815260206004820152601560248201527f417070726f76616c20756e7375636365737366756c000000000000000000000060448201526064016109bb565b600b546040516323b872dd60e01b81523060048201526101009091046001600160a01b03166024820181905260448201839052906323b872dd90606401602060405180830381600087803b158015611a0857600080fd5b505af1158015611a1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a409190613345565b611a8c5760405162461bcd60e51b815260206004820152601960248201527f57697468647261774567677320756e7375636365737366756c0000000000000060448201526064016109bb565b50565b6007546001600160a01b03163314611ad75760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b6016805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000611b2a6000546001600160801b03600160801b82048116918116919091031690565b600b5490915060ff1615611b805760405162461bcd60e51b815260206004820152600e60248201527f4d696e74696e672070617573656400000000000000000000000000000000000060448201526064016109bb565b601454601354611b9091906135db565b611b9a83836135db565b1115611be85760405162461bcd60e51b815260206004820152601660248201527f45786365656473206d6178696d756d20737570706c790000000000000000000060448201526064016109bb565b60135482601154611bf991906135db565b1115611c5a5760405162461bcd60e51b815260206004820152602a60248201527f45786365656473206d6178696d756d20737570706c79206d696e7461626c65206044820152693bb4ba341032ba3432b960b11b60648201526084016109bb565b336000908152600c6020526040902054600690611c789084906135db565b10611cc55760405162461bcd60e51b815260206004820152601860248201527f4d6178206d696e74207065722077616c6c65742069732035000000000000000060448201526064016109bb565b81600e54611cd39190613607565b341015611d225760405162461bcd60e51b815260206004820152601960248201527f45746865722073656e74206973206e6f7420636f72726563740000000000000060448201526064016109bb565b8160116000828254611d3491906135db565b9091555050336000908152600c602052604081208054849290611d589084906135db565b90915550611d7a90503383604051806020016040528060008152506000612316565b610af2610f2883836135db565b6001600160a01b038216331415611dca576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360008181526006602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b611e4184848461253a565b611e4d8484848461293e565b611e6a576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b60098054611e7d90613669565b80601f0160208091040260200160405190810160405280929190818152602001828054611ea990613669565b8015611ef65780601f10611ecb57610100808354040283529160200191611ef6565b820191906000526020600020905b815481529060010190602001808311611ed957829003601f168201915b505050505081565b6060611f09826121d1565b611f3f576040517fa14c4b5000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611f49612a4c565b9050805160001415611f6a5760405180602001604052806000815250611f95565b80611f7484612a5b565b604051602001611f859291906134e8565b6040516020818303038152906040525b9392505050565b60088054611e7d90613669565b6007546001600160a01b03163314611ff15760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b600a54156120415760405162461bcd60e51b815260206004820152601360248201527f5365656420697320616c7265616479207365740000000000000000000000000060448201526064016109bb565b60408051446020820152429181019190915260600160408051601f198184030181529190528051602090910120600a55565b6016546000906001600160a01b038381169116141561209457506001610882565b6001600160a01b0380841660009081526006602090815260408083209386168352929052205460ff16611f95565b6007546001600160a01b0316331461210a5760405162461bcd60e51b8152602060048201819052602482015260008051602061376683398151915260448201526064016109bb565b6001600160a01b0381166121865760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109bb565b611a8c816128df565b60005b8151811015611e6a576121bf84848484815181106121b2576121b2613715565b6020026020010151610f37565b806121c9816136a4565b915050612192565b600080546001600160801b031682108015610882575050600090815260036020526040902054600160e01b900460ff161590565b600082815260056020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6040516bffffffffffffffffffffffff19606085901b1660208201526034810183905260009061230e9061230890605401604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b83612b8d565b949350505050565b6000546001600160801b03166001600160a01b038516612362576040517f2e07630000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b83612399576040517fb562e8dd00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038516600081815260046020908152604080832080546fffffffffffffffffffffffffffffffff19811667ffffffffffffffff8083168c0181169182176801000000000000000067ffffffffffffffff1990941690921783900481168c018116909202179091558584526003909252822080546001600160e01b031916909317600160a01b42909216919091021790915581905b858110156124b55760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a483801561248b5750612489600088848861293e565b155b156124a9576040516368d2bf6b60e11b815260040160405180910390fd5b60019182019101612434565b50600080546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905561147f565b600a5415801561250257506014546013546124ff91906135db565b81145b15611a8c5760408051446020820152429181019190915260600160408051601f198184030181529190528051602090910120600a5550565b6000612545826127a2565b80519091506000906001600160a01b0316336001600160a01b03161480612573575081516125739033612073565b8061258e5750336125838461091a565b6001600160a01b0316145b9050806125c7576040517f59c896be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b846001600160a01b031682600001516001600160a01b031614612616576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038416612656576040517fea553b3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6126666000848460000151612205565b6001600160a01b038581166000908152600460209081526040808320805467ffffffffffffffff1980821667ffffffffffffffff92831660001901831617909255898616808652838620805493841693831660019081018416949094179055898652600390945282852080546001600160e01b031916909417600160a01b42909216919091021790925590860180835291205490911661275b576000546001600160801b031681101561275b578251600082815260036020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461147f565b60408051606081018252600080825260208201819052918101829052905482906001600160801b03168110156128ad57600081815260036020908152604091829020825160608101845290546001600160a01b0381168252600160a01b810467ffffffffffffffff1692820192909252600160e01b90910460ff161515918101829052906128ab5780516001600160a01b031615612841579392505050565b5060001901600081815260036020908152604091829020825160608101845290546001600160a01b038116808352600160a01b820467ffffffffffffffff1693830193909352600160e01b900460ff16151592810192909252156128a6579392505050565b612841565b505b6040517fdf2d9b4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600780546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160a01b0384163b15612a4157604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612982903390899088908890600401613517565b602060405180830381600087803b15801561299c57600080fd5b505af19250505080156129cc575060408051601f3d908101601f191682019092526129c99181019061337f565b60015b612a27573d8080156129fa576040519150601f19603f3d011682016040523d82523d6000602084013e6129ff565b606091505b508051612a1f576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061230e565b506001949350505050565b60606008805461089790613669565b606081612a9b57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612ac55780612aaf816136a4565b9150612abe9050600a836135f3565b9150612a9f565b60008167ffffffffffffffff811115612ae057612ae061372b565b6040519080825280601f01601f191660200182016040528015612b0a576020820181803683370190505b5090505b841561230e57612b1f600183613626565b9150612b2c600a866136bf565b612b379060306135db565b60f81b818381518110612b4c57612b4c613715565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612b86600a866135f3565b9450612b0e565b6000806000612b9c8585612ba9565b9150915061129e81612c19565b600080825160411415612be05760208301516040840151606085015160001a612bd487828585612dd4565b94509450505050612c12565b825160401415612c0a5760208301516040840151612bff868383612ec1565b935093505050612c12565b506000905060025b9250929050565b6000816004811115612c2d57612c2d6136ff565b1415612c365750565b6001816004811115612c4a57612c4a6136ff565b1415612c985760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016109bb565b6002816004811115612cac57612cac6136ff565b1415612cfa5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016109bb565b6003816004811115612d0e57612d0e6136ff565b1415612d675760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016109bb565b6004816004811115612d7b57612d7b6136ff565b1415611a8c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016109bb565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612e0b5750600090506003612eb8565b8460ff16601b14158015612e2357508460ff16601c14155b15612e345750600090506004612eb8565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612e88573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612eb157600060019250925050612eb8565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831660ff84901c601b01612efb87828885612dd4565b935093505050935093915050565b828054612f1590613669565b90600052602060002090601f016020900481019282612f375760008555612f7d565b82601f10612f5057805160ff1916838001178555612f7d565b82800160010185558215612f7d579182015b82811115612f7d578251825591602001919060010190612f62565b50612f89929150612f8d565b5090565b5b80821115612f895760008155600101612f8e565b600067ffffffffffffffff831115612fbc57612fbc61372b565b612fcf601f8401601f19166020016135aa565b9050828152838383011115612fe357600080fd5b828260208301376000602084830101529392505050565b80356001600160a01b038116811461301157600080fd5b919050565b600082601f83011261302757600080fd5b8135602067ffffffffffffffff8211156130435761304361372b565b8160051b6130528282016135aa565b83815282810190868401838801850189101561306d57600080fd5b600093505b85841015613090578035835260019390930192918401918401613072565b50979650505050505050565b60008083601f8401126130ae57600080fd5b50813567ffffffffffffffff8111156130c657600080fd5b602083019150836020828501011115612c1257600080fd5b600082601f8301126130ef57600080fd5b611f9583833560208501612fa2565b60006020828403121561311057600080fd5b611f9582612ffa565b6000806040838503121561312c57600080fd5b61313583612ffa565b915061314360208401612ffa565b90509250929050565b60008060006060848603121561316157600080fd5b61316a84612ffa565b925061317860208501612ffa565b9150604084013567ffffffffffffffff81111561319457600080fd5b6131a086828701613016565b9150509250925092565b600080600080608085870312156131c057600080fd5b6131c985612ffa565b93506131d760208601612ffa565b9250604085013567ffffffffffffffff808211156131f457600080fd5b61320088838901613016565b9350606087013591508082111561321657600080fd5b50613223878288016130de565b91505092959194509250565b60008060006060848603121561324457600080fd5b61324d84612ffa565b925061325b60208501612ffa565b9150604084013590509250925092565b6000806000806080858703121561328157600080fd5b61328a85612ffa565b935061329860208601612ffa565b925060408501359150606085013567ffffffffffffffff8111156132bb57600080fd5b613223878288016130de565b600080604083850312156132da57600080fd5b6132e383612ffa565b915060208301356132f381613741565b809150509250929050565b6000806040838503121561331157600080fd5b61331a83612ffa565b946020939093013593505050565b60006020828403121561333a57600080fd5b8135611f9581613741565b60006020828403121561335757600080fd5b8151611f9581613741565b60006020828403121561337457600080fd5b8135611f958161374f565b60006020828403121561339157600080fd5b8151611f958161374f565b6000602082840312156133ae57600080fd5b813567ffffffffffffffff8111156133c557600080fd5b8201601f810184136133d657600080fd5b61230e84823560208401612fa2565b6000602082840312156133f757600080fd5b5035919050565b60006020828403121561341057600080fd5b5051919050565b6000806000806000806080878903121561343057600080fd5b86359550602087013567ffffffffffffffff8082111561344f57600080fd5b61345b8a838b0161309c565b909750955060408901359450606089013591508082111561347b57600080fd5b5061348889828a0161309c565b979a9699509497509295939492505050565b600080604083850312156134ad57600080fd5b50508035926020909101359150565b600081518084526134d481602086016020860161363d565b601f01601f19169290920160200192915050565b600083516134fa81846020880161363d565b83519083019061350e81836020880161363d565b01949350505050565b60006001600160a01b0380871683528086166020840152508360408301526080606083015261354960808301846134bc565b9695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561358b5783518352928401929184019160010161356f565b50909695505050505050565b602081526000611f9560208301846134bc565b604051601f8201601f1916810167ffffffffffffffff811182821017156135d3576135d361372b565b604052919050565b600082198211156135ee576135ee6136d3565b500190565b600082613602576136026136e9565b500490565b6000816000190483118215151615613621576136216136d3565b500290565b600082821015613638576136386136d3565b500390565b60005b83811015613658578181015183820152602001613640565b83811115611e6a5750506000910152565b600181811c9082168061367d57607f821691505b6020821081141561369e57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156136b8576136b86136d3565b5060010190565b6000826136ce576136ce6136e9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114611a8c57600080fd5b6001600160e01b031981168114611a8c57600080fdfe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212201db40a16fc6778dee7ae76281fb0a9b4629b18fd823d8285afae083b246e052664736f6c63430008070033
Verified Source Code Full Match
Compiler: v0.8.7+commit.e28d00a7
EVM: london
Optimization: Yes (1000 runs)
Pirates.sol 209 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
contract Pirates is ERC721A, Ownable {
string public baseTokenURI;
string public provenanceHash = "";
uint256 public _seed = 0;
bool public publicMintPaused = true;
IERC20 private eggsContract;
mapping(address => uint256) private publicMintWalletCount;
mapping(address => uint256) private allowListWalletCount;
uint256 private _price = 0.07 ether; // 70000000000000000
uint256 private _priceEggs = 56 ether; // 56000000000000000000
uint256 public numMintedWithEggs = 0;
uint256 public numMintedWithEth = 0;
uint256 private _maxSupply = 8888;
uint256 private _maxEthSupply = 5500;
uint256 private _maxEggSupply = 3388;
address private _verifier = 0xcFe5cb192f8E2B10dCc3a3618b9b936Eac26B4C4;
address public stakingContract = 0x244938DAd845F5ffA30618b20c526359e18D2E34;
constructor(address eggsAddress, string memory baseURI) ERC721A("Pirates", "PIRATES") {
eggsContract = IERC20(eggsAddress);
setBaseURI(baseURI);
}
function _recoverWallet(
address _wallet,
uint256 _num,
bytes memory _signature
) internal pure returns (address) {
return
ECDSA.recover(
ECDSA.toEthSignedMessageHash(
keccak256(abi.encodePacked(_wallet, _num))
),
_signature
);
}
function _maybeSetSeed(uint256 totalSupply) internal {
if (_seed == 0 && totalSupply == (_maxEthSupply + _maxEggSupply)) {
_seed = uint256(
keccak256(abi.encodePacked(block.difficulty, block.timestamp))
);
}
}
function mint(uint256 _num) external payable {
uint256 totalSupply = totalSupply();
require(!publicMintPaused, "Minting paused");
require(totalSupply + _num <= (_maxEthSupply + _maxEggSupply), "Exceeds maximum supply");
require(numMintedWithEth + _num <= _maxEthSupply, "Exceeds maximum supply mintable with ether");
require(publicMintWalletCount[_msgSender()] + _num < 6, "Max mint per wallet is 5");
require(msg.value >= _price * _num, "Ether sent is not correct");
numMintedWithEth += _num;
publicMintWalletCount[_msgSender()] += _num;
_mint(_msgSender(), _num, '', false);
_maybeSetSeed(totalSupply + _num);
}
function allowListMint(uint256 _num, bytes calldata _signature, uint256 _max, bytes calldata _maxSignature) external payable {
uint256 totalSupply = totalSupply();
require(
tx.origin == msg.sender,
"Purchase cannot be called from another contract"
);
require(totalSupply + _num <= (_maxEthSupply + _maxEggSupply), "Exceeds maximum supply");
require(numMintedWithEth + _num <= _maxEthSupply, "Exceeds maximum supply mintable with ether");
require(allowListWalletCount[_msgSender()] + _num <= _max, "Exceeds maximum allow list supply for this wallet");
require(msg.value >= _price * _num, "Ether sent is not correct");
address signer = _recoverWallet(_msgSender(), _num, _signature);
require(signer == _verifier, "Unverified transaction");
signer = _recoverWallet(_msgSender(), _max, _maxSignature);
require(signer == _verifier, "Unverified max allowlist signature");
numMintedWithEth += _num;
allowListWalletCount[_msgSender()] += _num;
_mint(_msgSender(), _num, '', false);
_maybeSetSeed(totalSupply + _num);
}
function mintWithEggs(uint256 _num) external payable {
uint256 totalSupply = totalSupply();
require(!publicMintPaused, "Minting paused");
require(numMintedWithEggs + _num <= _maxEggSupply, "Exceeds maximum supply mintable with eggs");
uint256 amountToPay = _num * _priceEggs;
require(eggsContract.allowance(msg.sender, address(this)) >= amountToPay, "Insufficient Allowance");
require(eggsContract.transferFrom(msg.sender, address(this), amountToPay), "Transfer Failed");
numMintedWithEggs += _num;
_mint(_msgSender(), _num, '', false);
_maybeSetSeed(totalSupply + _num);
}
function isApprovedForAll(address _owner, address _operator) public view override returns (bool) {
// Allow the staking contract to transfer without require user to approve first (to save gas)
if (stakingContract == _operator) {
return true;
}
return super.isApprovedForAll(_owner, _operator);
}
function batchTransferFrom(
address _from,
address _to,
uint256[] memory _tokenIds
) public {
for (uint256 i; i < _tokenIds.length; i++) {
transferFrom(_from, _to, _tokenIds[i]);
}
}
function batchSafeTransferFrom(
address _from,
address _to,
uint256[] memory _tokenIds,
bytes memory _data
) public {
for (uint256 i; i < _tokenIds.length; i++) {
safeTransferFrom(_from, _to, _tokenIds[i], _data);
}
}
function _baseURI() internal view virtual override returns (string memory) {
return baseTokenURI;
}
function walletOfOwner(address owner)
external
view
returns (uint256[] memory)
{
uint256 tokenCount = balanceOf(owner);
uint256[] memory tokensId = new uint256[](tokenCount);
for (uint256 i; i < tokenCount; i++) {
tokensId[i] = tokenOfOwnerByIndex(owner, i);
}
return tokensId;
}
function setBaseURI(string memory _baseTokenURI) public onlyOwner {
baseTokenURI = _baseTokenURI;
}
function setVerifier(address _newVerifier) external onlyOwner {
_verifier = _newVerifier;
}
function setStakingContract(address _stakingContract) external onlyOwner {
stakingContract = _stakingContract;
}
function setSupplies(uint256 _newEthAmount, uint256 _newEggAmount) external onlyOwner {
require(_newEthAmount + _newEggAmount == _maxSupply, "Amounts must add up to max supply");
_maxEthSupply = _newEthAmount;
_maxEggSupply = _newEggAmount;
}
function setProvenanceHash(string memory _provenanceHash) external onlyOwner {
provenanceHash = _provenanceHash;
}
function publicMintPause(bool _state) public onlyOwner {
publicMintPaused = _state;
}
function emergencySetSeed() external onlyOwner {
require(_seed == 0, "Seed is already set");
_seed = uint256(
keccak256(abi.encodePacked(block.difficulty, block.timestamp))
);
}
function withdraw() external onlyOwner {
require(
payable(owner()).send(address(this).balance),
"Withdraw unsuccessful"
);
}
function withdrawEggs(uint256 _amount) external onlyOwner {
require(eggsContract.approve(address(this), _amount), "Approval unsuccessful");
require(eggsContract.transferFrom(address(this), address(eggsContract), _amount), "WithdrawEggs unsuccessful");
}
}
ERC721A.sol 628 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintedQueryForZeroAddress();
error BurnedQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerIndexOutOfBounds();
error OwnerQueryForNonexistentToken();
error TokenIndexOutOfBounds();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**128 - 1 (max value of uint128).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
}
// Compiler will pack the following
// _currentIndex and _burnCounter into a single 256bit word.
// The tokenId of the next token to be minted.
uint128 internal _currentIndex;
// The number of tokens burned.
uint128 internal _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 ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex times
unchecked {
return _currentIndex - _burnCounter;
}
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
uint256 numMintedSoFar = _currentIndex;
uint256 tokenIdsIdx;
// Counter overflow is impossible as the loop breaks when
// uint256 i is equal to another uint256 numMintedSoFar.
unchecked {
for (uint256 i; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (!ownership.burned) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
}
revert TokenIndexOutOfBounds();
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
if (index >= balanceOf(owner)) revert OwnerIndexOutOfBounds();
uint256 numMintedSoFar = _currentIndex;
uint256 tokenIdsIdx;
address currOwnershipAddr;
// Counter overflow is impossible as the loop breaks when
// uint256 i is equal to another uint256 numMintedSoFar.
unchecked {
for (uint256 i; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
}
// Execution should never reach this point.
revert();
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
if (owner == address(0)) revert MintedQueryForZeroAddress();
return uint256(_addressData[owner].numberMinted);
}
function _numberBurned(address owner) internal view returns (uint256) {
if (owner == address(0)) revert BurnedQueryForZeroAddress();
return uint256(_addressData[owner].numberBurned);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (!_checkOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < _currentIndex && !_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, 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.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @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.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1
// updatedIndex overflows if _currentIndex + quantity > 3.4e38 (2**128) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe && !_checkOnERC721Received(address(0), to, updatedIndex, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
updatedIndex++;
}
_currentIndex = uint128(updatedIndex);
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
isApprovedForAll(prevOwnership.addr, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// 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**128.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
_beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// 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**128.
unchecked {
_addressData[prevOwnership.addr].balance -= 1;
_addressData[prevOwnership.addr].numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
_ownerships[tokenId].addr = prevOwnership.addr;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
_ownerships[tokenId].burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(prevOwnership.addr, address(0), tokenId);
_afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @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 {}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
ECDSA.sol 234 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
_seed 0x5a34d356 → uint256
balanceOf 0x70a08231 → uint256
baseTokenURI 0xd547cfb7 → string
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
numMintedWithEggs 0x5a3d54b1 → uint256
numMintedWithEth 0x40461d9d → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
provenanceHash 0xc6ab67a3 → string
publicMintPaused 0x33d9d5fd → bool
stakingContract 0xee99205c → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
walletOfOwner 0x438b6300 → uint256[]
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
allowListMint 0x1b8e384c
uint256 _num
bytes _signature
uint256 _max
bytes _maxSignature
approve 0x095ea7b3
address to
uint256 tokenId
batchSafeTransferFrom 0x5a4fee30
address _from
address _to
uint256[] _tokenIds
bytes _data
batchTransferFrom 0xf3993d11
address _from
address _to
uint256[] _tokenIds
emergencySetSeed 0xe28ab142
No parameters
mint 0xa0712d68
uint256 _num
mintWithEggs 0x9ab5cb9c
uint256 _num
publicMintPause 0x08fd9f0b
bool _state
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string _baseTokenURI
setProvenanceHash 0x10969523
string _provenanceHash
setStakingContract 0x9dd373b9
address _stakingContract
setSupplies 0x2abb934e
uint256 _newEthAmount
uint256 _newEggAmount
setVerifier 0x5437988d
address _newVerifier
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
withdrawEggs 0x9cbb9bb6
uint256 _amount
Recent Transactions
No transactions found for this address