Forkchoice Ethereum Mainnet

Address Contract Verified

Address 0x8C6eBfC76199f379e706af27AD68f5340CC5B4e2
Balance 0 ETH
Nonce 1
Code Size 12632 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

12632 bytes
0x6080604052600436106102345760003560e01c80636050f48e1161012e578063b0abd457116100ab578063cd5ad4c51161006f578063cd5ad4c5146107d7578063db465a7a146107f7578063e8ac653314610817578063e985e9c514610837578063f851a4401461088057610286565b8063b0abd457146106f6578063b88d4fde1461070c578063bb2fcfbb1461072c578063c0d880321461074c578063c87b56dd146107b757610286565b806392e80eb4116100f257806392e80eb41461063057806395d89b41146106505780639a81fb29146106655780639b3d270a146106b6578063a22cb465146106d657610286565b80636050f48e146105a65780636352211e146105c65780636c0360eb146105e657806370a08231146105fb5780638bad0c0a1461061b57610286565b80634025feb2116101bc5780634782f779116101805780634782f779146104c75780634f558e79146104e757806351ff48471461050757806355f804b31461051c5780635615d8fd1461053c57610286565b80634025feb21461042757806342842e0e1461044757806342966c6814610467578063432643471461048757806344004cc1146104a757610286565b80630e18b681116102035780630e18b6811461037f5780631249c58b1461039457806318160ddd146103a957806323b872dd146103c85780632a55205a146103e857610286565b806301ffc9a7146102ce57806306fdde0314610303578063081812fc14610325578063095ea7b31461035d57610286565b366102865760405162461bcd60e51b815260206004820152601b60248201527f526563656976696e6720455448206e6f74207065726d6974746564000000000060448201526064015b60405180910390fd5b60405162461bcd60e51b815260206004820152601f60248201527f46616c6c6261636b2066756e6374696f6e206e6f74207065726d697474656400604482015260640161027d565b3480156102da57600080fd5b506102ee6102e9366004612a94565b6108a5565b60405190151581526020015b60405180910390f35b34801561030f57600080fd5b506103186108b6565b6040516102fa9190612b0d565b34801561033157600080fd5b50610345610340366004612b20565b610948565b6040516001600160a01b0390911681526020016102fa565b34801561036957600080fd5b5061037d610378366004612b4e565b6109ca565b005b34801561038b57600080fd5b5061037d610ab5565b3480156103a057600080fd5b5061037d610b23565b3480156103b557600080fd5b506011545b6040519081526020016102fa565b3480156103d457600080fd5b5061037d6103e3366004612b7a565b610b9e565b3480156103f457600080fd5b50610408610403366004612bbb565b610c11565b604080516001600160a01b0390931683526020830191909152016102fa565b34801561043357600080fd5b5061037d610442366004612b7a565b610c78565b34801561045357600080fd5b5061037d610462366004612b7a565b610cfb565b34801561047357600080fd5b5061037d610482366004612b20565b610d16565b34801561049357600080fd5b5061037d6104a2366004612bdd565b610d32565b3480156104b357600080fd5b5061037d6104c2366004612b7a565b610dbb565b3480156104d357600080fd5b5061037d6104e2366004612b4e565b610e98565b3480156104f357600080fd5b506102ee610502366004612b20565b61102a565b34801561051357600080fd5b50610318611049565b34801561052857600080fd5b5061037d610537366004612c3c565b6110d7565b34801561054857600080fd5b50600c54600d546105759160ff808216926101008304909116916201000090046001600160a01b03169084565b6040516102fa9493929190931515845291151560208401526001600160a01b03166040830152606082015260800190565b3480156105b257600080fd5b5061037d6105c1366004612d2a565b611122565b3480156105d257600080fd5b506103456105e1366004612b20565b6111bf565b3480156105f257600080fd5b5061031861122d565b34801561060757600080fd5b506103ba610616366004612bdd565b61123c565b34801561062757600080fd5b5061037d6112b0565b34801561063c57600080fd5b5061037d61064b366004612b4e565b6112c4565b34801561065c57600080fd5b5061031861140a565b34801561067157600080fd5b50610685610680366004612b4e565b611419565b6040805182511515815260208084015161ffff1690820152918101516001600160a01b0316908201526060016102fa565b3480156106c257600080fd5b5061037d6106d1366004612db2565b611548565b3480156106e257600080fd5b5061037d6106f1366004612e0c565b61182e565b34801561070257600080fd5b506103ba61271081565b34801561071857600080fd5b5061037d610727366004612e45565b6118ed565b34801561073857600080fd5b5061037d610747366004612ec5565b611950565b34801561075857600080fd5b5061068560408051606081018252600080825260208201819052918101919091525060408051606081018252600b5460ff811615158252610100810461ffff166020830152630100000090046001600160a01b03169181019190915290565b3480156107c357600080fd5b506103186107d2366004612b20565b61196b565b3480156107e357600080fd5b5061037d6107f2366004612bdd565b611976565b34801561080357600080fd5b5061037d610812366004612b20565b6119a0565b34801561082357600080fd5b50600954610345906001600160a01b031681565b34801561084357600080fd5b506102ee610852366004612ee2565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b34801561088c57600080fd5b506008546103459061010090046001600160a01b031681565b60006108b082611ab8565b92915050565b6060600180546108c590612f10565b80601f01602080910402602001604051908101604052809291908181526020018280546108f190612f10565b801561093e5780601f106109135761010080835404028352916020019161093e565b820191906000526020600020905b81548152906001019060200180831161092157829003601f168201915b5050505050905090565b6000818152600460205260408120546001600160a01b0316151560405180604001604052806014815260200173151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b815250906109ad5760405162461bcd60e51b815260040161027d9190612b0d565b50506000908152600660205260409020546001600160a01b031690565b60006109d5826111bf565b9050806001600160a01b0316836001600160a01b031614156040518060400160405280601681526020017510dd5c9c995b9d081bdddb995c88185c1c1c9bdd985b60521b81525090610a3a5760405162461bcd60e51b815260040161027d9190612b0d565b50336001600160a01b0382161480610a575750610a578133610852565b60405180604001604052806016815260200175139bdd081bdddb995c881b9bdc88185c1c1c9bdd995960521b81525090610aa45760405162461bcd60e51b815260040161027d9190612b0d565b50610ab0818484611add565b505050565b6009546001600160a01b031680336001600160a01b0316146040518060400160405280601281526020017124b73b30b634b21036b9b39739b2b73232b960711b81525090610b165760405162461bcd60e51b815260040161027d9190612b0d565b50610b2081611b39565b50565b610b2b611ba3565b60006010546103e9610b3d9190612f61565b9050610b697f000000000000000000000000e052113bd7d7700d623414a0a4585bcae754e9d582611cdd565b600160116000828254610b7c9190612f61565b92505081905550600160106000828254610b969190612f61565b909155505050565b600080610bab3384611e7a565b915091508060405180604001604052806016815260200175139bdd081bdddb995c881b9bdc88185c1c1c9bdd995960521b81525090610bfd5760405162461bcd60e51b815260040161027d9190612b0d565b50610c0a82868686611f55565b5050505050565b600b546000908190630100000090046001600160a01b031615610c6857600b54630100000081046001600160a01b03169061271090610c5990610100900461ffff1686612f79565b610c639190612fae565b610c6c565b6000805b915091505b9250929050565b610c80611ba3565b604051635c46a7ef60e11b81523060048201526001600160a01b03838116602483015260448201839052608060648301526000608483015284169063b88d4fde9060a401600060405180830381600087803b158015610cde57600080fd5b505af1158015610cf2573d6000803e3d6000fd5b50505050505050565b610ab0838383604051806020016040528060008152506118ed565b610d1f816120ea565b600160116000828254610b969190612fc2565b60085460408051808201909152601f81527f52652d696e697469616c697a6174696f6e206e6f74207065726d69747465640060208201529060ff1615610d8b5760405162461bcd60e51b815260040161027d9190612b0d565b50600a80546001600160a01b0319166001600160a01b03929092169190911790556008805460ff19166001179055565b610dc3611ba3565b60405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390526000919085169063a9059cbb90604401602060405180830381600087803b158015610e1157600080fd5b505af1158015610e25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e499190612fd9565b9050806040518060400160405280601581526020017415da5d1a191c985dc81d5b9cdd58d8d95cdcd99d5b605a1b81525090610c0a5760405162461bcd60e51b815260040161027d9190612b0d565b610ea0611ba3565b6040805180820190915260118152702d32b9379022aa24102a3930b739b332b960791b602082015281610ee65760405162461bcd60e51b815260040161027d9190612b0d565b506001600160a01b038216610f385760405162461bcd60e51b81526020600482015260186024820152775472616e7366657220746f207a65726f206164647265737360401b604482015260640161027d565b604080518082019091526014815273496e73756666696369656e742062616c616e636560601b6020820152479081831115610f865760405162461bcd60e51b815260040161027d9190612b0d565b506000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114610fd4576040519150601f19603f3d011682016040523d82523d6000602084013e610fd9565b606091505b50509050806040518060400160405280601581526020017415da5d1a191c985dc81d5b9cdd58d8d95cdcd99d5b605a1b81525090610c0a5760405162461bcd60e51b815260040161027d9190612b0d565b6000818152600460205260408120546001600160a01b031615156108b0565b600e805461105690612f10565b80601f016020809104026020016040519081016040528092919081815260200182805461108290612f10565b80156110cf5780601f106110a4576101008083540402835291602001916110cf565b820191906000526020600020905b8154815290600101906020018083116110b257829003601f168201915b505050505081565b6110df611ba3565b61111e82828080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061221592505050565b5050565b60005460408051808201909152601f81527f52652d696e697469616c697a6174696f6e206e6f74207065726d69747465640060208201529060ff161561117b5760405162461bcd60e51b815260040161027d9190612b0d565b50825161118f906001906020860190612971565b5081516111a3906002906020850190612971565b506111ad81612215565b50506000805460ff1916600117905550565b60008181526004602090815260408083205481518083019092526014825273151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b928201929092526001600160a01b0390911690816112265760405162461bcd60e51b815260040161027d9190612b0d565b5092915050565b6060600380546108c590612f10565b604080518082019091526016815275517565727920666f72207a65726f206164647265737360501b60208201526000906001600160a01b0383166112935760405162461bcd60e51b815260040161027d9190612b0d565b50506001600160a01b031660009081526005602052604090205490565b6112b8611ba3565b6112c26000611b39565b565b6112cc611ba3565b60408051808201909152601a81527f5369676e65722073657420746f207a65726f206164647265737300000000000060208201526001600160a01b0383166113275760405162461bcd60e51b815260040161027d9190612b0d565b5060408051808201909152601781527f53616c74656420686173682073657420746f207a65726f00000000000000000060208201528161137a5760405162461bcd60e51b815260040161027d9190612b0d565b50600c5460408051808201909152601781527610dbdb9d1c9858dd08185b1c9958591e481cda59db9959604a1b602082015290610100900460ff16156113d35760405162461bcd60e51b815260040161027d9190612b0d565b50600c8054600d9290925560ff196001600160a01b0390931662010000029290921661ff01600160b01b0319909116176001179055565b6060600280546108c590612f10565b604080516060810182526000808252602082018190529181019190915261143e611ba3565b60408051808201909152600e81526d42697073206f766572203130302560901b60208201526127108311156114865760405162461bcd60e51b815260040161027d9190612b0d565b50600b8054610100600160b81b0319811663010000006001600160a01b03878116820262ffff0019169290921761010061ffff881602179384905560408051938290048316808552919094049091166020830152917f67b490a6eb879b67b91826b576ca0a1ba79f82484d43c4e330e3948dac8182d7910160405180910390a1505060408051606081018252600b5460ff811615158252610100810461ffff166020830152630100000090046001600160a01b03169181019190915292915050565b600c5460408051808201909152601781527610dbdb9d1c9858dd08185b1c9958591e481cda59db9959604a1b602082015290610100900460ff16156115a05760405162461bcd60e51b815260040161027d9190612b0d565b50600c5460408051808201909152601381527210dbdb9d1c9858dd081b9bdd081cd85b1d1959606a1b60208201529060ff166115ef5760405162461bcd60e51b815260040161027d9190612b0d565b50600c54600d54620100009091046001600160a01b03169081336001600160a01b0316146040518060400160405280601281526020017124b73b30b634b21036b9b39739b2b73232b960711b8152509061165c5760405162461bcd60e51b815260040161027d9190612b0d565b50808560405160200161167191815260200190565b604051602081830303815290604052805190602001201460405180604001604052806015815260200174125b98dbdc9c9958dd081cd958dc995d081cd85b1d605a1b815250906116d45760405162461bcd60e51b815260040161027d9190612b0d565b50816001600160a01b0316611775611739836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b86868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061222892505050565b6001600160a01b031614604051806040016040528060168152602001752ab732bc3832b1ba32b2103230ba309039b4b3b732b960511b815250906117cc5760405162461bcd60e51b815260040161027d9190612b0d565b506117d9600e85856129f5565b50600c805461ff0019166101001790556040517f955fd8871b091d05a1f766f82ece6ba4d9c55e65e065d4459b26740f2e698e709061181f908490849088908890612ff6565b60405180910390a15050505050565b60408051808201909152601181527020b8383937bb32903a379031b0b63632b960791b60208201526001600160a01b0383163314156118805760405162461bcd60e51b815260040161027d9190612b0d565b503360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6118f8848484610b9e565b6119048484848461224c565b604051806040016040528060158152602001742737ba1030b71022a9219b9918a932b1b2b4bb32b960591b81525090610c0a5760405162461bcd60e51b815260040161027d9190612b0d565b611958611ba3565b600f805460ff1916911515919091179055565b60606108b082612385565b61197e611ba3565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b600f5460ff166119f25760405162461bcd60e51b815260206004820152601d60248201527f4275726e20547261697473206e6f742079657420617661696c61626c65000000604482015260640161027d565b6119fb81610d16565b60006010546103e9611a0d9190612f61565b9050611a193382611cdd565b611a35600033836040518060200160405280600081525061224c565b604051806040016040528060158152602001742737ba1030b71022a9219b9918a932b1b2b4bb32b960591b81525090611a815760405162461bcd60e51b815260040161027d9190612b0d565b50600160106000828254611a959190612f61565b92505081905550600160116000828254611aaf9190612f61565b90915550505050565b60006001600160e01b0319821663152a902d60e11b14806108b057506108b08261244a565b60008181526006602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b600880546001600160a01b03838116610100818102610100600160a81b0319851617909455600980546001600160a01b031916905560405193909204169182907ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec690600090a35050565b60085461010090046001600160a01b031680611c8b57600a546001600160a01b031663e37ce6fa336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015611c0a57600080fd5b505afa158015611c1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c429190612fd9565b6040518060400160405280601281526020017124b73b30b634b21036b9b39739b2b73232b960711b8152509061111e5760405162461bcd60e51b815260040161027d9190612b0d565b60408051808201909152601281527124b73b30b634b21036b9b39739b2b73232b960711b6020820152336001600160a01b0383161461111e5760405162461bcd60e51b815260040161027d9190612b0d565b6040805180820190915260188152775472616e7366657220746f207a65726f206164647265737360401b60208201526001600160a01b038316611d335760405162461bcd60e51b815260040161027d9190612b0d565b506000818152600460205260409020546001600160a01b031615151560405180604001604052806014815260200173151bdad95b88185b1c9958591e481b5a5b9d195960621b81525090611d9a5760405162461bcd60e51b815260040161027d9190612b0d565b5060646011546001611dac9190612f61565b1115611df35760405162461bcd60e51b815260206004820152601660248201527545786365656473204d6178696d756d20537570706c7960501b604482015260640161027d565b6001600160a01b0382166000908152600560205260408120805460019290611e1c908490612f61565b909155505060008181526004602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60008181526004602090815260408083205481518083019092526014825273151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b928201929092526001600160a01b03909116919082611ee25760405162461bcd60e51b815260040161027d9190612b0d565b50816001600160a01b0316846001600160a01b03161480611f1c57506000838152600660205260409020546001600160a01b038581169116145b80611f4c57506001600160a01b0380831660009081526007602090815260408083209388168352929052205460ff165b90509250929050565b826001600160a01b0316846001600160a01b0316146040518060400160405280601d81526020017f5472616e736665722066726f6d20696e636f7272656374206f776e657200000081525090611fbe5760405162461bcd60e51b815260040161027d9190612b0d565b506040805180820190915260188152775472616e7366657220746f207a65726f206164647265737360401b60208201526001600160a01b0383166120155760405162461bcd60e51b815260040161027d9190612b0d565b50612020848261246f565b6001600160a01b0383166000908152600560205260408120805460019290612049908490612fc2565b90915550506001600160a01b0382166000908152600560205260408120805460019290612077908490612f61565b9091555050600081815260046020526040902080546001600160a01b0319166001600160a01b03841617905580826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a450505050565b60006120f5826111bf565b90506000336001600160a01b038316148061212657506000838152600660205260409020546001600160a01b031633145b8061213657506121368233610852565b90508060405180604001604052806016815260200175139bdd081bdddb995c881b9bdc88185c1c1c9bdd995960521b815250906121865760405162461bcd60e51b815260040161027d9190612b0d565b50612191828461246f565b6001600160a01b03821660009081526005602052604081208054600192906121ba908490612fc2565b909155505060008381526004602052604080822080546001600160a01b0319169055518491906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4505050565b805161111e906003906020840190612971565b600080600061223785856124c4565b9150915061224481612531565b509392505050565b60006001600160a01b0384163b1561237957604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061229090339089908890889060040161303e565b602060405180830381600087803b1580156122aa57600080fd5b505af19250505080156122da575060408051601f3d908101601f191682019092526122d79181019061307b565b60015b61235f573d808015612308576040519150601f19603f3d011682016040523d82523d6000602084013e61230d565b606091505b5080516123575760408051808201825260158152742737ba1030b71022a9219b9918a932b1b2b4bb32b960591b6020820152905162461bcd60e51b815261027d9190600401612b0d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061237d565b5060015b949350505050565b6000818152600460205260409020546060906001600160a01b0316151560405180604001604052806014815260200173151bdad95b88191bd95cc81b9bdd08195e1a5cdd60621b815250906123ed5760405162461bcd60e51b815260040161027d9190612b0d565b5060006123f861122d565b905060008151116124185760405180602001604052806000815250612443565b80612422846126ec565b604051602001612433929190613098565b6040516020818303038152906040525b9392505050565b60006001600160e01b03198216634326434760e01b14806108b057506108b0826127ea565b60008181526006602052604080822080546001600160a01b0319169055518291906001600160a01b038516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925908390a45050565b6000808251604114156124fb5760208301516040840151606085015160001a6124ef87828585612855565b94509450505050610c71565b825160401415612525576020830151604084015161251a868383612942565b935093505050610c71565b50600090506002610c71565b6000816004811115612545576125456130c7565b141561254e5750565b6001816004811115612562576125626130c7565b14156125b05760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161027d565b60028160048111156125c4576125c46130c7565b14156126125760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161027d565b6003816004811115612626576126266130c7565b141561267f5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161027d565b6004816004811115612693576126936130c7565b1415610b205760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161027d565b6060816127105750506040805180820190915260018152600360fc1b602082015290565b8160005b811561273a5780612724816130dd565b91506127339050600a83612fae565b9150612714565b60008167ffffffffffffffff81111561275557612755612c7e565b6040519080825280601f01601f19166020018201604052801561277f576020820181803683370190505b5090505b841561237d57612794600183612fc2565b91506127a1600a866130f8565b6127ac906030612f61565b60f81b8183815181106127c1576127c161310c565b60200101906001600160f81b031916908160001a9053506127e3600a86612fae565b9450612783565b60006001600160e01b031982166380ac58cd60e01b148061281b57506001600160e01b03198216635b5e139f60e01b145b8061283657506001600160e01b031982166330287a4760e11b145b806108b057506301ffc9a760e01b6001600160e01b03198316146108b0565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561288c5750600090506003612939565b8460ff16601b141580156128a457508460ff16601c14155b156128b55750600090506004612939565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612909573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661293257600060019250925050612939565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161296387828885612855565b935093505050935093915050565b82805461297d90612f10565b90600052602060002090601f01602090048101928261299f57600085556129e5565b82601f106129b857805160ff19168380011785556129e5565b828001600101855582156129e5579182015b828111156129e55782518255916020019190600101906129ca565b506129f1929150612a69565b5090565b828054612a0190612f10565b90600052602060002090601f016020900481019282612a2357600085556129e5565b82601f10612a3c5782800160ff198235161785556129e5565b828001600101855582156129e5579182015b828111156129e5578235825591602001919060010190612a4e565b5b808211156129f15760008155600101612a6a565b6001600160e01b031981168114610b2057600080fd5b600060208284031215612aa657600080fd5b813561244381612a7e565b60005b83811015612acc578181015183820152602001612ab4565b83811115612adb576000848401525b50505050565b60008151808452612af9816020860160208601612ab1565b601f01601f19169290920160200192915050565b6020815260006124436020830184612ae1565b600060208284031215612b3257600080fd5b5035919050565b6001600160a01b0381168114610b2057600080fd5b60008060408385031215612b6157600080fd5b8235612b6c81612b39565b946020939093013593505050565b600080600060608486031215612b8f57600080fd5b8335612b9a81612b39565b92506020840135612baa81612b39565b929592945050506040919091013590565b60008060408385031215612bce57600080fd5b50508035926020909101359150565b600060208284031215612bef57600080fd5b813561244381612b39565b60008083601f840112612c0c57600080fd5b50813567ffffffffffffffff811115612c2457600080fd5b602083019150836020828501011115610c7157600080fd5b60008060208385031215612c4f57600080fd5b823567ffffffffffffffff811115612c6657600080fd5b612c7285828601612bfa565b90969095509350505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612caf57612caf612c7e565b604051601f8501601f19908116603f01168101908282118183101715612cd757612cd7612c7e565b81604052809350858152868686011115612cf057600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112612d1b57600080fd5b61244383833560208501612c94565b600080600060608486031215612d3f57600080fd5b833567ffffffffffffffff80821115612d5757600080fd5b612d6387838801612d0a565b94506020860135915080821115612d7957600080fd5b612d8587838801612d0a565b93506040860135915080821115612d9b57600080fd5b50612da886828701612d0a565b9150509250925092565b600080600060408486031215612dc757600080fd5b83359250602084013567ffffffffffffffff811115612de557600080fd5b612df186828701612bfa565b9497909650939450505050565b8015158114610b2057600080fd5b60008060408385031215612e1f57600080fd5b8235612e2a81612b39565b91506020830135612e3a81612dfe565b809150509250929050565b60008060008060808587031215612e5b57600080fd5b8435612e6681612b39565b93506020850135612e7681612b39565b925060408501359150606085013567ffffffffffffffff811115612e9957600080fd5b8501601f81018713612eaa57600080fd5b612eb987823560208401612c94565b91505092959194509250565b600060208284031215612ed757600080fd5b813561244381612dfe565b60008060408385031215612ef557600080fd5b8235612f0081612b39565b91506020830135612e3a81612b39565b600181811c90821680612f2457607f821691505b60208210811415612f4557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115612f7457612f74612f4b565b500190565b6000816000190483118215151615612f9357612f93612f4b565b500290565b634e487b7160e01b600052601260045260246000fd5b600082612fbd57612fbd612f98565b500490565b600082821015612fd457612fd4612f4b565b500390565b600060208284031215612feb57600080fd5b815161244381612dfe565b6001600160a01b0385168152602081018490526060604082018190528101829052818360808301376000818301608090810191909152601f909201601f191601019392505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061307190830184612ae1565b9695505050505050565b60006020828403121561308d57600080fd5b815161244381612a7e565b600083516130aa818460208801612ab1565b8351908301906130be818360208801612ab1565b01949350505050565b634e487b7160e01b600052602160045260246000fd5b60006000198214156130f1576130f1612f4b565b5060010190565b60008261310757613107612f98565b500690565b634e487b7160e01b600052603260045260246000fdfea26469706673582212208c726375c33cb7d67db361f1e18b78e2d7fabd77ae21ed525e8ccce55834579d64736f6c63430008090033

Verified Source Code Full Match

Compiler: v0.8.9+commit.e5eed63a EVM: london Optimization: Yes (200 runs)
ERC721.sol 318 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./ERC721Errors.sol";
import "../interfaces/IERC721.sol";
import "../interfaces/IERC721Receiver.sol";
import "../interfaces/IERC721Metadata.sol";
import "../interfaces/IERC721Cloneable.sol";
import "../libraries/Address.sol";
import "../libraries/Context.sol";
import "../libraries/Strings.sol";
import "../utils/ERC165.sol";
import "../utils/GenericErrors.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
abstract contract ERC721 is Context, ERC165, ERC721Errors, GenericErrors, IERC721Metadata, IERC721Cloneable {
    using Address for address;
    using Strings for uint256;

    // Only allow ERC721 to be initialized once
    bool internal initializedERC721;

    // Token name
    string internal tokenName;

    // Token symbol
    string internal tokenSymbol;

    // Base URI For Offchain Metadata
    string internal baseMetadataURI; 

    // Mapping from token ID to owner address
    mapping(uint256 => address) internal owners;

    // Mapping owner address to token count
    mapping(address => uint256) internal balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) internal tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) internal operatorApprovals;    

    function initializeERC721(string memory name_, string memory symbol_, string memory baseURI_) public override {
        require(!initializedERC721, ERROR_REINITIALIZATION_NOT_PERMITTED);
        tokenName = name_;
        tokenSymbol = symbol_;
        _setBaseURI(baseURI_);
        initializedERC721 = true;
    }

    /**
     * @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(IERC721Cloneable).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */    
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), ERROR_QUERY_FOR_ZERO_ADDRESS);
        return balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = owners[tokenId];
        require(owner != address(0), ERROR_QUERY_FOR_NONEXISTENT_TOKEN);
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */    
    function name() public view virtual override returns (string memory) {
        return tokenName;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */    
    function symbol() public view virtual override returns (string memory) {
        return tokenSymbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */     
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), ERROR_QUERY_FOR_NONEXISTENT_TOKEN);

        string memory uriBase = baseURI();
        return bytes(uriBase).length > 0 ? string(abi.encodePacked(uriBase, tokenId.toString())) : "";
    }

    function baseURI() public view virtual returns (string memory) {
        return baseMetadataURI;
    }

    /**
     * @dev Internal function to set the base URI
     */
    function _setBaseURI(string memory uri) internal {
        baseMetadataURI = uri;        
    }

    /**
     * @dev See {IERC721-approve}.
     */    
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ownerOf(tokenId);
        require(to != owner, ERROR_APPROVAL_TO_CURRENT_OWNER);

        require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), ERROR_NOT_OWNER_NOR_APPROVED);

        _approve(owner, to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */    
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), ERROR_QUERY_FOR_NONEXISTENT_TOKEN);
        return tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */    
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), ERROR_APPROVE_TO_CALLER);
        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 {        
        (address owner, bool isApprovedOrOwner) = _isApprovedOrOwner(_msgSender(), tokenId);
        require(isApprovedOrOwner, ERROR_NOT_OWNER_NOR_APPROVED);
        _transfer(owner, 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 {
        transferFrom(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, data), ERROR_NOT_AN_ERC721_RECEIVER);
    }    

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */    
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (address owner, bool isApprovedOrOwner) {
        owner = owners[tokenId];
        require(owner != address(0), ERROR_QUERY_FOR_NONEXISTENT_TOKEN);
        isApprovedOrOwner = (spender == owner || tokenApprovals[tokenId] == spender || isApprovedForAll(owner, spender));
    }   
    
    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ownerOf(tokenId);
        bool isApprovedOrOwner = (_msgSender() == owner || tokenApprovals[tokenId] == _msgSender() || isApprovedForAll(owner, _msgSender()));
        require(isApprovedOrOwner, ERROR_NOT_OWNER_NOR_APPROVED);

        // Clear approvals        
        _clearApproval(owner, tokenId);

        balances[owner] -= 1;
        _clearOwnership(tokenId);

        emit Transfer(owner, address(0), tokenId);
    }    

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address owner, address from, address to, uint256 tokenId) internal virtual {
        require(owner == from, ERROR_TRANSFER_FROM_INCORRECT_OWNER);
        require(to != address(0), ERROR_TRANSFER_TO_ZERO_ADDRESS);        

        // Clear approvals from the previous owner        
        _clearApproval(owner, tokenId);

        balances[from] -= 1;
        balances[to] += 1;
        _setOwnership(to, tokenId);
        
        emit Transfer(from, to, tokenId);        
    }

    /**
     * @dev Equivalent to approving address(0), but more gas efficient
     *
     * Emits a {Approval} event.
     */
    function _clearApproval(address owner, uint256 tokenId) internal virtual {
        delete tokenApprovals[tokenId];
        emit Approval(owner, address(0), tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address owner, address to, uint256 tokenId) internal virtual {
        tokenApprovals[tokenId] = to;
        emit Approval(owner, to, tokenId);
    }    

    function _clearOwnership(uint256 tokenId) internal virtual {
        delete owners[tokenId];
    }

    function _setOwnership(address to, uint256 tokenId) internal virtual {
        owners[tokenId] = to;
    }

    /**
     * @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
     *
     * @dev Slither identifies an issue with unused return value.
     * Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#unused-return
     * This should be a non-issue.  It is the standard OpenZeppelin implementation which has been heavily used and audited.
     */     
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal returns (bool) {
        if (to.isContract()) {            
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert(ERROR_NOT_AN_ERC721_RECEIVER);
                } else {                    
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }    
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "../interfaces/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;
    }
}
Signable.sol 50 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./NiftyPermissions.sol";
import "../libraries/ECDSA.sol";
import "../structs/SignatureStatus.sol";

abstract contract Signable is NiftyPermissions {        

    event ContractSigned(address signer, bytes32 data, bytes signature);

    SignatureStatus public signatureStatus;
    bytes public signature;

    string internal constant ERROR_CONTRACT_ALREADY_SIGNED = "Contract already signed";
    string internal constant ERROR_CONTRACT_NOT_SALTED = "Contract not salted";
    string internal constant ERROR_INCORRECT_SECRET_SALT = "Incorrect secret salt";
    string internal constant ERROR_SALTED_HASH_SET_TO_ZERO = "Salted hash set to zero";
    string internal constant ERROR_SIGNER_SET_TO_ZERO = "Signer set to zero address";

    function setSigner(address signer_, bytes32 saltedHash_) external {
        _requireOnlyValidSender();

        require(signer_ != address(0), ERROR_SIGNER_SET_TO_ZERO);
        require(saltedHash_ != bytes32(0), ERROR_SALTED_HASH_SET_TO_ZERO);
        require(!signatureStatus.isVerified, ERROR_CONTRACT_ALREADY_SIGNED);
        
        signatureStatus.signer = signer_;
        signatureStatus.saltedHash = saltedHash_;
        signatureStatus.isSalted = true;
    }

    function sign(uint256 salt, bytes calldata signature_) external {
        require(!signatureStatus.isVerified, ERROR_CONTRACT_ALREADY_SIGNED);        
        require(signatureStatus.isSalted, ERROR_CONTRACT_NOT_SALTED);
        
        address expectedSigner = signatureStatus.signer;
        bytes32 expectedSaltedHash = signatureStatus.saltedHash;

        require(_msgSender() == expectedSigner, ERROR_INVALID_MSG_SENDER);
        require(keccak256(abi.encodePacked(salt)) == expectedSaltedHash, ERROR_INCORRECT_SECRET_SALT);
        require(ECDSA.recover(ECDSA.toEthSignedMessageHash(expectedSaltedHash), signature_) == expectedSigner, ERROR_UNEXPECTED_DATA_SIGNER);
        
        signature = signature_;        
        signatureStatus.isVerified = true;

        emit ContractSigned(expectedSigner, expectedSaltedHash, signature_);
    }
}
ECDSA.sol 234 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity 0.8.9;

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));
    }
}
Royalties.sol 45 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./NiftyPermissions.sol";
import "../libraries/Clones.sol";
import "../interfaces/IERC20.sol";
import "../interfaces/IERC721.sol";
import "../interfaces/IERC2981.sol";
import "../structs/RoyaltyRecipient.sol";

abstract contract Royalties is NiftyPermissions, IERC2981 {

    event RoyaltyReceiverUpdated(address previousReceiver, address newReceiver);

    uint256 constant public BIPS_PERCENTAGE_TOTAL = 10000;

    RoyaltyRecipient internal royaltyRecipient;

    function supportsInterface(bytes4 interfaceId) public view virtual override(NiftyPermissions, IERC165) returns (bool) {
        return
            interfaceId == type(IERC2981).interfaceId ||            
            super.supportsInterface(interfaceId);
    }

    function getRoyaltySettings() public view returns (RoyaltyRecipient memory) {
        return royaltyRecipient;
    }

    function royaltyInfo(uint256 tokenId, uint256 salePrice) public virtual override view returns (address, uint256) {                        
        return royaltyRecipient.recipient == address(0) ? 
            (address(0), 0) :
            (royaltyRecipient.recipient, (salePrice * royaltyRecipient.bips) / BIPS_PERCENTAGE_TOTAL);
    }

    function initializeRoyalties(address payee, uint256 bips) external returns (RoyaltyRecipient memory) {
        _requireOnlyValidSender();
        require(bips <= BIPS_PERCENTAGE_TOTAL, ERROR_BIPS_OVER_100_PERCENT);
        address previousReceiver = royaltyRecipient.recipient;
        royaltyRecipient.recipient = payee;
        royaltyRecipient.bips = uint16(bips);
        emit RoyaltyReceiverUpdated(previousReceiver, royaltyRecipient.recipient);
        return royaltyRecipient;
    }
}
Clones.sol 82 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 */
library Clones {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @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);
}
Address.sol 221 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @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 66 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @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);
    }
}
NiftyType.sol 10 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

struct NiftyType {
    bool isMinted; // 1 bytes
    uint72 niftyType; // 9 bytes
    uint88 idFirst; // 11 bytes
    uint88 idLast; // 11 bytes
}
Thr33zi3zNG.sol 85 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "./ERC721.sol";
import "../structs/NiftyType.sol";
import "../utils/Signable.sol";
import "../utils/Withdrawable.sol";
import "../utils/Royalties.sol";

contract Thr33zi3sNG is ERC721, Royalties, Signable, Withdrawable {
    using Address for address;        

    address immutable defaultOwner;
    bool burnAndReplaceOpen;
    uint256 counter;
    uint256 extantSupply;

    constructor(address niftyRegistryContract_, address defaultOwner_) {
        initializeERC721("thr33zi3sNG", "333NG", "https://api.thr33zi3s.com/token/");
        initializeNiftyEntity(niftyRegistryContract_);
        defaultOwner = defaultOwner_;
        admin = msg.sender;
    }

    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, Royalties, NiftyPermissions) returns (bool) {
        return          
        super.supportsInterface(interfaceId);
    }                                     

    function tokenURI(uint256 tokenId) public virtual view override returns (string memory) {
        return super.tokenURI(tokenId);
    }

    function setBaseURI(string calldata uri) external {
        _requireOnlyValidSender();
        _setBaseURI(uri);        
    }

    function exists(uint256 tokenId) public view returns (bool) {
        return _exists(tokenId);
    }    

    function burn(uint256 tokenId) public {
        _burn(tokenId);
        extantSupply -= 1;
    }

    function mint() public {
        _requireOnlyValidSender();
        uint256 tokenId = counter + 1001; //Start at 1001
        _mint(defaultOwner, tokenId);
        extantSupply += 1;
        counter += 1;
    }

    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), ERROR_TRANSFER_TO_ZERO_ADDRESS);
        require(!_exists(tokenId), ERROR_ALREADY_MINTED);
        require(extantSupply + 1 <= 100, "Exceeds Maximum Supply");
        balances[to] += 1;
        owners[tokenId] = to; 

        emit Transfer(address(0), to, tokenId);

    }

    function burnAndReplace(uint256 initialTokenId) public {
        require(burnAndReplaceOpen, "Burn Traits not yet available");
        burn(initialTokenId); // calls require(isApprovedOrOwner, ERROR_NOT_OWNER_NOR_APPROVED);
        uint256 newTokenId = counter + 1001;
        _mint(_msgSender(), newTokenId);
        require(_checkOnERC721Received(address(0), _msgSender(), newTokenId,""), ERROR_NOT_AN_ERC721_RECEIVER); //i.e. safe mint
        counter += 1;
        extantSupply += 1;
    }

    function toggleBurnWindow(bool active) public {
        _requireOnlyValidSender();
        burnAndReplaceOpen = active;
    }
    
    function totalSupply() public view returns (uint256) {
        return extantSupply;
    }
}
RejectEther.sol 30 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @title A base contract that may be inherited in order to protect a contract from having its fallback function 
 * invoked and to block the receipt of ETH by a contract.
 * @author Nathan Gang
 * @notice This contract bestows on inheritors the ability to block ETH transfers into the contract
 * @dev ETH may still be forced into the contract - it is impossible to block certain attacks, but this protects from accidental ETH deposits
 */
 // For more info, see: "https://medium.com/@alexsherbuck/two-ways-to-force-ether-into-a-contract-1543c1311c56"
abstract contract RejectEther {    

    /**
     * @dev For most contracts, it is safest to explicitly restrict the use of the fallback function
     * This would generally be invoked if sending ETH to this contract with a 'data' value provided
     */
    fallback() external payable {        
        revert("Fallback function not permitted");
    }

    /**
     * @dev This is the standard path where ETH would land if sending ETH to this contract without a 'data' value
     * In our case, we don't want our contract to receive ETH, so we restrict it here
     */
    receive() external payable {
        revert("Receiving ETH not permitted");
    }    
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @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);
}
IERC721.sol 142 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./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;
}
ERC721Errors.sol 16 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

abstract contract ERC721Errors {
    string internal constant ERROR_QUERY_FOR_ZERO_ADDRESS = "Query for zero address";
    string internal constant ERROR_QUERY_FOR_NONEXISTENT_TOKEN = "Token does not exist";
    string internal constant ERROR_APPROVAL_TO_CURRENT_OWNER = "Current owner approval";
    string internal constant ERROR_APPROVE_TO_CALLER = "Approve to caller";
    string internal constant ERROR_NOT_OWNER_NOR_APPROVED = "Not owner nor approved";
    string internal constant ERROR_NOT_AN_ERC721_RECEIVER = "Not an ERC721Receiver";
    string internal constant ERROR_TRANSFER_FROM_INCORRECT_OWNER = "Transfer from incorrect owner";
    string internal constant ERROR_TRANSFER_TO_ZERO_ADDRESS = "Transfer to zero address";    
    string internal constant ERROR_ALREADY_MINTED = "Token already minted";    
    string internal constant ERROR_NO_TOKENS_MINTED = "No tokens minted";    
}
Withdrawable.sol 42 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./RejectEther.sol";
import "./NiftyPermissions.sol";
import "../interfaces/IERC20.sol";
import "../interfaces/IERC721.sol";

abstract contract Withdrawable is RejectEther, NiftyPermissions {

    /**
     * @dev Slither identifies an issue with sending ETH to an arbitrary destianation.
     * https://github.com/crytic/slither/wiki/Detector-Documentation#functions-that-send-ether-to-arbitrary-destinations
     * Recommended mitigation is to "Ensure that an arbitrary user cannot withdraw unauthorized funds."
     * This mitigation has been performed, as only the contract admin can call 'withdrawETH' and they should
     * verify the recipient should receive the ETH first.
     */
    function withdrawETH(address payable recipient, uint256 amount) external {
        _requireOnlyValidSender();
        require(amount > 0, ERROR_ZERO_ETH_TRANSFER);
        require(recipient != address(0), "Transfer to zero address");

        uint256 currentBalance = address(this).balance;
        require(amount <= currentBalance, ERROR_INSUFFICIENT_BALANCE);

        //slither-disable-next-line arbitrary-send        
        (bool success,) = recipient.call{value: amount}("");
        require(success, ERROR_WITHDRAW_UNSUCCESSFUL);
    }
        
    function withdrawERC20(address tokenContract, address recipient, uint256 amount) external {
        _requireOnlyValidSender();
        bool success = IERC20(tokenContract).transfer(recipient, amount);
        require(success, ERROR_WITHDRAW_UNSUCCESSFUL);
    }
    
    function withdrawERC721(address tokenContract, address recipient, uint256 tokenId) external {
        _requireOnlyValidSender();
        IERC721(tokenContract).safeTransferFrom(address(this), recipient, tokenId, "");
    }    
}
IERC2981.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IERC165.sol";

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be payed in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}
GenericErrors.sol 19 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

abstract contract GenericErrors {
    string internal constant ERROR_INPUT_ARRAY_EMPTY = "Input array empty";
    string internal constant ERROR_INPUT_ARRAY_SIZE_MISMATCH = "Input array size mismatch";
    string internal constant ERROR_INVALID_MSG_SENDER = "Invalid msg.sender";
    string internal constant ERROR_UNEXPECTED_DATA_SIGNER = "Unexpected data signer";
    string internal constant ERROR_INSUFFICIENT_BALANCE = "Insufficient balance";
    string internal constant ERROR_WITHDRAW_UNSUCCESSFUL = "Withdraw unsuccessful";
    string internal constant ERROR_CONTRACT_IS_FINALIZED = "Contract is finalized";
    string internal constant ERROR_CANNOT_CHANGE_DEFAULT_OWNER = "Cannot change default owner";
    string internal constant ERROR_UNCLONEABLE_REFERENCE_CONTRACT = "Uncloneable reference contract";
    string internal constant ERROR_BIPS_OVER_100_PERCENT = "Bips over 100%";
    string internal constant ERROR_NO_ROYALTY_RECEIVER = "No royalty receiver";
    string internal constant ERROR_REINITIALIZATION_NOT_PERMITTED = "Re-initialization not permitted";
    string internal constant ERROR_ZERO_ETH_TRANSFER = "Zero ETH Transfer";
}
NiftyPermissions.sol 72 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./ERC165.sol";
import "./GenericErrors.sol";
import "../interfaces/INiftyEntityCloneable.sol";
import "../interfaces/INiftyRegistry.sol";
import "../libraries/Context.sol";

abstract contract NiftyPermissions is Context, ERC165, GenericErrors, INiftyEntityCloneable {    

    event AdminTransferred(address indexed previousAdmin, address indexed newAdmin);

    // Only allow Nifty Entity to be initialized once
    bool internal initializedNiftyEntity;

    // If address(0), use enable Nifty Gateway permissions - otherwise, specifies the address with permissions
    address public admin;

    // To prevent a mistake, transferring admin rights will be a two step process
    // First, the current admin nominates a new admin
    // Second, the nominee accepts admin
    address public nominatedAdmin;

    // Nifty Registry Contract
    INiftyRegistry internal permissionsRegistry;    

    function initializeNiftyEntity(address niftyRegistryContract_) public {
        require(!initializedNiftyEntity, ERROR_REINITIALIZATION_NOT_PERMITTED);
        permissionsRegistry = INiftyRegistry(niftyRegistryContract_);
        initializedNiftyEntity = true;
    }       
    
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return         
        interfaceId == type(INiftyEntityCloneable).interfaceId ||
        super.supportsInterface(interfaceId);
    }        

    function renounceAdmin() external {
        _requireOnlyValidSender();
        _transferAdmin(address(0));
    }    

    function nominateAdmin(address nominee) external {
        _requireOnlyValidSender();
        nominatedAdmin = nominee;
    }

    function acceptAdmin() external {
        address nominee = nominatedAdmin;
        require(_msgSender() == nominee, ERROR_INVALID_MSG_SENDER);
        _transferAdmin(nominee);
    }
    
    function _requireOnlyValidSender() internal view {       
        address currentAdmin = admin;     
        if(currentAdmin == address(0)) {
            require(permissionsRegistry.isValidNiftySender(_msgSender()), ERROR_INVALID_MSG_SENDER);
        } else {
            require(_msgSender() == currentAdmin, ERROR_INVALID_MSG_SENDER);
        }
    }        

    function _transferAdmin(address newAdmin) internal {
        address oldAdmin = admin;
        admin = newAdmin;
        delete nominatedAdmin;        
        emit AdminTransferred(oldAdmin, newAdmin);
    }
}
SignatureStatus.sol 10 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

struct SignatureStatus {
    bool isSalted;
    bool isVerified;
    address signer;
    bytes32 saltedHash;
}
RoyaltyRecipient.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

struct RoyaltyRecipient {
    bool isPaymentSplitter; // 1 byte
    uint16 bips; // 2 bytes
    address recipient; // 20 bytes
}
INiftyRegistry.sol 7 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

interface INiftyRegistry {
   function isValidNiftySender(address sendingKey) external view returns (bool);
}
IERC721Metadata.sol 26 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

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);
}
IERC721Receiver.sol 26 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

/**
 * @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);
}
IERC721Cloneable.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IERC721.sol";

interface IERC721Cloneable is IERC721 {
    function initializeERC721(string calldata name_, string calldata symbol_, string calldata baseURI_) external;    
}
INiftyEntityCloneable.sol 9 lines
// SPDX-License-Identifier: MIT

pragma solidity 0.8.9;

import "./IERC165.sol";

interface INiftyEntityCloneable is IERC165 {
    function initializeNiftyEntity(address niftyRegistryContract_) external;
}

Read Contract

BIPS_PERCENTAGE_TOTAL 0xb0abd457 → uint256
admin 0xf851a440 → address
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
exists 0x4f558e79 → bool
getApproved 0x081812fc → address
getRoyaltySettings 0xc0d88032 → tuple
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
nominatedAdmin 0xe8ac6533 → address
ownerOf 0x6352211e → address
royaltyInfo 0x2a55205a → address, uint256
signature 0x51ff4847 → bytes
signatureStatus 0x5615d8fd → bool, bool, address, bytes32
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256

Write Contract 21 functions

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

acceptAdmin 0x0e18b681
No parameters
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
burnAndReplace 0xdb465a7a
uint256 initialTokenId
initializeERC721 0x6050f48e
string name_
string symbol_
string baseURI_
initializeNiftyEntity 0x43264347
address niftyRegistryContract_
initializeRoyalties 0x9a81fb29
address payee
uint256 bips
returns: tuple
mint 0x1249c58b
No parameters
nominateAdmin 0xcd5ad4c5
address nominee
renounceAdmin 0x8bad0c0a
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string uri
setSigner 0x92e80eb4
address signer_
bytes32 saltedHash_
sign 0x9b3d270a
uint256 salt
bytes signature_
toggleBurnWindow 0xbb2fcfbb
bool active
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
withdrawERC20 0x44004cc1
address tokenContract
address recipient
uint256 amount
withdrawERC721 0x4025feb2
address tokenContract
address recipient
uint256 tokenId
withdrawETH 0x4782f779
address recipient
uint256 amount

Recent Transactions

No transactions found for this address