Address Contract Partially Verified
Address
0xA027942Abd42c0098C11A84DF44Cce58546cfb69
Balance
0 ETH
Nonce
1
Code Size
11054 bytes
Creator
0x9a6422f2...3Bda at tx 0xc02a6c93...16da99
Indexed Transactions
0
Contract Bytecode
11054 bytes
0x608060405260043610610392575f3560e01c806370a08231116101de578063ab2dbe4c11610108578063da3ef23f1161009d578063e985e9c51161006d578063e985e9c514610a70578063f1aacdfd14610a8f578063f2c4ce1e14610ab0578063f2fde38b14610acf575f80fd5b8063da3ef23f146109e3578063e060127514610a02578063e6d9e56e14610a17578063e7dad4f914610a39575f80fd5b8063c6682862116100d8578063c66828621461097c578063c87b56dd14610990578063d111515d146109af578063d5abeb01146109c3575f80fd5b8063ab2dbe4c1461090c578063b6f50fe61461092b578063b88d4fde1461094a578063bc497af014610969575f80fd5b80638da5cb5b1161017e57806394a10f781161014e57806394a10f781461088d57806395d89b41146108a1578063a22cb465146108b5578063a9748289146108d4575f80fd5b80638da5cb5b1461081d5780639196f7611461083a578063920577701461085957806392d5011f1461086e575f80fd5b806372250380116101b957806372250380146107b65780637c0c32b7146107ca5780637eedcfd0146107e95780638529ccad146107fd575f80fd5b806370a0823114610770578063715018a61461078f578063718445da146107a3575f80fd5b806323b872dd116102bf5780634cd50b601161025f5780635c975abb1161022f5780635c975abb146107095780636352211e146107295780636373a6b1146107485780636c0360eb1461075c575f80fd5b80634cd50b60146106a457806354214f69146106c357806354c98403146106d75780635a23dd99146106ea575f80fd5b80633966fa0f1161029a5780633966fa0f146106495780633ccfd60b1461065e57806342842e0e146106665780634c26124714610685575f80fd5b806323b872dd146105c95780632a55205a146105e85780632eb4a7ab14610626575f80fd5b80630fe4fb6b1161033557806317881cbf1161030557806317881cbf1461053f57806318160ddd146105715780631b60a0721461058b5780631c0af178146105aa575f80fd5b80630fe4fb6b146104ce57806310969523146104e2578063136621971461050157806316c38b3c14610520575f80fd5b806306fdde031161037057806306fdde031461041f578063081812fc14610440578063095ea7b3146104775780630a93a05814610496575f80fd5b806301ffc9a7146103965780630311bbd3146103ca57806304634d8d146103fe575b5f80fd5b3480156103a1575f80fd5b506103b56103b0366004612376565b610aee565b60405190151581526020015b60405180910390f35b3480156103d5575f80fd5b506014546103eb90600160401b900461ffff1681565b60405161ffff90911681526020016103c1565b348015610409575f80fd5b5061041d6104183660046123ac565b610afe565b005b34801561042a575f80fd5b50610433610b14565b6040516103c1919061241a565b34801561044b575f80fd5b5061045f61045a36600461242c565b610ba4565b6040516001600160a01b0390911681526020016103c1565b348015610482575f80fd5b5061041d610491366004612443565b610bcb565b3480156104a1575f80fd5b506103eb6104b036600461246b565b6001600160a01b03165f9081526010602052604090205461ffff1690565b3480156104d9575f80fd5b5061041d610c42565b3480156104ed575f80fd5b5061041d6104fc36600461250b565b610c5f565b34801561050c575f80fd5b5061041d61051b36600461242c565b610c73565b34801561052b575f80fd5b5061041d61053a36600461255f565b610c80565b34801561054a575f80fd5b5060145461055f90600160601b900460ff1681565b60405160ff90911681526020016103c1565b34801561057c575f80fd5b506014546103eb9061ffff1681565b348015610596575f80fd5b5061041d6105a536600461242c565b610ca6565b3480156105b5575f80fd5b5061041d6105c4366004612589565b610cb3565b3480156105d4575f80fd5b5061041d6105e33660046125a2565b610ce2565b3480156105f3575f80fd5b506106076106023660046125db565b610d6b565b604080516001600160a01b0390931683526020830191909152016103c1565b348015610631575f80fd5b5061063b600e5481565b6040519081526020016103c1565b348015610654575f80fd5b5061063b60135481565b61041d610e16565b348015610671575f80fd5b5061041d6106803660046125a2565b610f7e565b348015610690575f80fd5b5061041d61069f36600461250b565b610f9d565b3480156106af575f80fd5b5061041d6106be366004612589565b611000565b3480156106ce575f80fd5b506103b5611014565b61041d6106e5366004612589565b61102b565b3480156106f5575f80fd5b506103b561070436600461263c565b611102565b348015610714575f80fd5b506014546103b590600160501b900460ff1681565b348015610734575f80fd5b5061045f61074336600461242c565b611186565b348015610753575f80fd5b50610433611190565b348015610767575f80fd5b5061043361121c565b34801561077b575f80fd5b5061063b61078a36600461246b565b611229565b34801561079a575f80fd5b5061041d61126e565b61041d6107b136600461268b565b61127f565b3480156107c1575f80fd5b506104336113c0565b3480156107d5575f80fd5b5061041d6107e4366004612589565b6113cd565b3480156107f4575f80fd5b5061041d6113fa565b348015610808575f80fd5b506014546103b590600160581b900460ff1681565b348015610828575f80fd5b506008546001600160a01b031661045f565b348015610845575f80fd5b5061041d61085436600461242c565b611417565b348015610864575f80fd5b5061063b60115481565b348015610879575f80fd5b5061041d6108883660046126a6565b611424565b348015610898575f80fd5b5061041d611456565b3480156108ac575f80fd5b50610433611473565b3480156108c0575f80fd5b5061041d6108cf3660046126a6565b611482565b3480156108df575f80fd5b506103eb6108ee36600461246b565b6001600160a01b03165f908152600f602052604090205461ffff1690565b348015610917575f80fd5b5061041d61092636600461242c565b6114f4565b348015610936575f80fd5b5061041d610945366004612589565b611501565b348015610955575f80fd5b5061041d6109643660046126d7565b61152d565b61041d61097736600461268b565b611544565b348015610987575f80fd5b50610433611663565b34801561099b575f80fd5b506104336109aa36600461242c565b611670565b3480156109ba575f80fd5b5061041d6117c8565b3480156109ce575f80fd5b506014546103eb9062010000900461ffff1681565b3480156109ee575f80fd5b5061041d6109fd36600461250b565b61182f565b348015610a0d575f80fd5b5061063b60125481565b348015610a22575f80fd5b506014546103eb90640100000000900461ffff1681565b348015610a44575f80fd5b506103b5610a5336600461246b565b6001600160a01b03165f9081526015602052604090205460ff1690565b348015610a7b575f80fd5b506103b5610a8a36600461274e565b611843565b348015610a9a575f80fd5b506014546103eb90600160301b900461ffff1681565b348015610abb575f80fd5b5061041d610aca36600461250b565b611870565b348015610ada575f80fd5b5061041d610ae936600461246b565b611884565b5f610af8826118be565b92915050565b610b066118fd565b610b10828261192a565b5050565b606060028054610b2390612776565b80601f0160208091040260200160405190810160405280929190818152602001828054610b4f90612776565b8015610b9a5780601f10610b7157610100808354040283529160200191610b9a565b820191905f5260205f20905b815481529060010190602001808311610b7d57829003601f168201915b5050505050905090565b5f610bae826119cb565b505f828152600660205260409020546001600160a01b0316610af8565b6001600160a01b0382165f9081526015602052604090205460ff1615610c385760405162461bcd60e51b815260206004820152601f60248201527f4164647265737320697320626c6f636b656420666f7220617070726f76616c0060448201526064015b60405180910390fd5b610b108282611a03565b610c4a6118fd565b6014805460ff60601b1916600160611b179055565b610c676118fd565b600c610b1082826127f2565b610c7b6118fd565b601255565b610c886118fd565b60148054911515600160501b0260ff60501b19909216919091179055565b610cae6118fd565b600e55565b610cbb6118fd565b6014805461ffff909216600160401b0269ffff000000000000000019909216919091179055565b6001600160a01b038216610d0b57604051633250574960e11b81525f6004820152602401610c2f565b5f610d17838333611a0e565b9050836001600160a01b0316816001600160a01b031614610d65576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610c2f565b50505050565b5f8281526001602090815260408083208151808301909252546001600160a01b038116808352600160a01b9091046001600160601b0316928201929092528291610dde5750604080518082019091525f546001600160a01b0381168252600160a01b90046001600160601b031660208201525b60208101515f9061271090610dfc906001600160601b0316876128c6565b610e0691906128dd565b91519350909150505b9250929050565b610e1e6118fd565b610e26611b00565b5f73beab247e6ec95133a991a05a516a1b923fb70f7c6064610e494760146128c6565b610e5391906128dd565b6040515f81818185875af1925050503d805f8114610e8c576040519150601f19603f3d011682016040523d82523d5f602084013e610e91565b606091505b5050905080610e9e575f80fd5b6040515f90735aa333d43ee39f412b0c2a3f0b28aa580c87ac509047908381818185875af1925050503d805f8114610ef1576040519150601f19603f3d011682016040523d82523d5f602084013e610ef6565b606091505b5050905080610f03575f80fd5b5f610f166008546001600160a01b031690565b6001600160a01b0316476040515f6040518083038185875af1925050503d805f8114610f5d576040519150601f19603f3d011682016040523d82523d5f602084013e610f62565b606091505b5050905080610f6f575f80fd5b505050610f7c6001600955565b565b610f9883838360405180602001604052805f81525061152d565b505050565b610fa56118fd565b601454600160581b900460ff1615610ff45760405162461bcd60e51b815260206004820152601260248201527126b2ba30b230ba309034b990333937bd32b760711b6044820152606401610c2f565b600a610b1082826127f2565b6110086118fd565b61101181611b2a565b50565b5f80600a805461102390612776565b905011905090565b601454600160601b900460ff166003146110575760405162461bcd60e51b8152600401610c2f906128fc565b60145461ffff600160401b909104811690821611156110d15760405162461bcd60e51b815260206004820152603060248201527f4d617820616c6c6f776564206d696e7420616d6f756e7420657863656564656460448201526f20666f72207075626c69632073616c6560801b6064820152608401610c2f565b8061ffff166013546110e391906128c6565b3410156110085760405162461bcd60e51b8152600401610c2f90612933565b6040516bffffffffffffffffffffffff19606085901b1660208201525f90819060340160405160208183030381529060405280519060200120905061117d8484808060200260200160405190810160405280939291908181526020018383602002808284375f9201919091525050600e549150849050611c82565b95945050505050565b5f610af8826119cb565b600c805461119d90612776565b80601f01602080910402602001604051908101604052809291908181526020018280546111c990612776565b80156112145780601f106111eb57610100808354040283529160200191611214565b820191905f5260205f20905b8154815290600101906020018083116111f757829003601f168201915b505050505081565b600a805461119d90612776565b5f6001600160a01b038216611253576040516322718ad960e21b81525f6004820152602401610c2f565b506001600160a01b03165f9081526005602052604090205490565b6112766118fd565b610f7c5f611c97565b601454600160601b900460ff166002146112ab5760405162461bcd60e51b8152600401610c2f906128fc565b6112b6338383611102565b6112fc5760405162461bcd60e51b8152602060048201526017602482015276165bdd48185c99481b9bdd081dda1a5d195b1a5cdd1959604a1b6044820152606401610c2f565b335f9081526010602052604090205460145461ffff91821691600160301b90910416611328858361296a565b61ffff16111561134a5760405162461bcd60e51b8152600401610c2f9061298c565b8361ffff1660125461135c91906128c6565b34101561137b5760405162461bcd60e51b8152600401610c2f90612933565b335f908152601060205260408120805486929061139d90849061ffff1661296a565b92506101000a81548161ffff021916908361ffff160217905550610d6584611b2a565b600b805461119d90612776565b6113d56118fd565b6014805461ffff909216600160301b0267ffff00000000000019909216919091179055565b6114026118fd565b6014805460ff60601b1916600360601b179055565b61141f6118fd565b601355565b61142c6118fd565b6001600160a01b03919091165f908152601560205260409020805460ff1916911515919091179055565b61145e6118fd565b6014805460ff60601b1916600160601b179055565b606060038054610b2390612776565b6001600160a01b0382165f9081526015602052604090205460ff16156114ea5760405162461bcd60e51b815260206004820181905260248201527f4f70657261746f7220697320626c6f636b656420666f7220617070726f76616c6044820152606401610c2f565b610b108282611ce8565b6114fc6118fd565b601155565b6115096118fd565b6014805461ffff9092166401000000000265ffff0000000019909216919091179055565b611538848484610ce2565b610d6584848484611cf3565b601454600160601b900460ff166001146115705760405162461bcd60e51b8152600401610c2f906128fc565b61157b338383611102565b6115c15760405162461bcd60e51b8152602060048201526017602482015276165bdd48185c99481b9bdd081dda1a5d195b1a5cdd1959604a1b6044820152606401610c2f565b335f908152600f602052604090205460145461ffff91821691640100000000909104166115ee858361296a565b61ffff1611156116105760405162461bcd60e51b8152600401610c2f9061298c565b8361ffff1660115461162291906128c6565b3410156116415760405162461bcd60e51b8152600401610c2f90612933565b335f908152600f60205260408120805486929061139d90849061ffff1661296a565b600d805461119d90612776565b5f818152600460205260409020546060906001600160a01b03166116cf5760405162461bcd60e51b81526020600482015260166024820152751d1bdad95b925908191bd95cc81b9bdd08195e1a5cdd60521b6044820152606401610c2f565b6116d7611014565b61176b57600b80546116e890612776565b80601f016020809104026020016040519081016040528092919081815260200182805461171490612776565b801561175f5780601f106117365761010080835404028352916020019161175f565b820191905f5260205f20905b81548152906001019060200180831161174257829003601f168201915b50505050509050919050565b5f600a805461177990612776565b9050116117945760405180602001604052805f815250610af8565b600a61179f83611e19565b600d6040516020016117b393929190612a49565b60405160208183030381529060405292915050565b6117d06118fd565b6117d8611014565b61181a5760405162461bcd60e51b815260206004820152601360248201527210985cd948155492481a5cc81b9bdd081cd95d606a1b6044820152606401610c2f565b6014805460ff60581b1916600160581b179055565b6118376118fd565b600d610b1082826127f2565b6001600160a01b039182165f90815260076020908152604080832093909416825291909152205460ff1690565b6118786118fd565b600b610b1082826127f2565b61188c6118fd565b6001600160a01b0381166118b557604051631e4fbdf760e01b81525f6004820152602401610c2f565b61101181611c97565b5f6001600160e01b031982166380ac58cd60e01b14806118ee57506001600160e01b03198216635b5e139f60e01b145b80610af85750610af882611ea9565b6008546001600160a01b03163314610f7c5760405163118cdaa760e01b8152336004820152602401610c2f565b6127106001600160601b03821681101561196957604051636f483d0960e01b81526001600160601b038316600482015260248101829052604401610c2f565b6001600160a01b03831661199257604051635b6cc80560e11b81525f6004820152602401610c2f565b50604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b909102175f55565b5f818152600460205260408120546001600160a01b031680610af857604051637e27328960e01b815260048101849052602401610c2f565b610b10828233611edd565b5f828152600460205260408120546001600160a01b0390811690831615611a3a57611a3a818486611eea565b6001600160a01b03811615611a7457611a555f855f80611f4e565b6001600160a01b0381165f90815260056020526040902080545f190190555b6001600160a01b03851615611aa2576001600160a01b0385165f908152600560205260409020805460010190555b5f8481526004602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b600260095403611b2357604051633ee5aeb560e01b815260040160405180910390fd5b6002600955565b601454600160501b900460ff1615611b845760405162461bcd60e51b815260206004820152601a60248201527f506c65617365207761697420756e74696c20756e7061757365640000000000006044820152606401610c2f565b5f8161ffff1611611bd75760405162461bcd60e51b815260206004820152601860248201527f4e65656420746f206d696e74206d6f7265207468616e203000000000000000006044820152606401610c2f565b60145461ffff620100008204811691611bf29184911661296a565b61ffff161115611c445760405162461bcd60e51b815260206004820152601b60248201527f4d617820616c6c6f77656420737570706c7920657863656564656400000000006044820152606401610c2f565b60015b8161ffff168161ffff1611610b1057611c5e612052565b601454611c7090339061ffff16612087565b80611c7a81612a77565b915050611c47565b5f82611c8e85846120a0565b14949350505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b610b103383836120e2565b6001600160a01b0383163b15610d6557604051630a85bd0160e11b81526001600160a01b0384169063150b7a0290611d35903390889087908790600401612a97565b6020604051808303815f875af1925050508015611d6f575060408051601f3d908101601f19168201909252611d6c91810190612ac9565b60015b611dd6573d808015611d9c576040519150601f19603f3d011682016040523d82523d5f602084013e611da1565b606091505b5080515f03611dce57604051633250574960e11b81526001600160a01b0385166004820152602401610c2f565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14611e1257604051633250574960e11b81526001600160a01b0385166004820152602401610c2f565b5050505050565b60605f611e2583612180565b60010190505f8167ffffffffffffffff811115611e4457611e44612484565b6040519080825280601f01601f191660200182016040528015611e6e576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611e7857509392505050565b5f6001600160e01b0319821663152a902d60e11b1480610af857506301ffc9a760e01b6001600160e01b0319831614610af8565b610f988383836001611f4e565b611ef5838383612257565b610f98576001600160a01b038316611f2357604051637e27328960e01b815260048101829052602401610c2f565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610c2f565b8080611f6257506001600160a01b03821615155b15612023575f611f71846119cb565b90506001600160a01b03831615801590611f9d5750826001600160a01b0316816001600160a01b031614155b8015611fb05750611fae8184611843565b155b15611fd95760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610c2f565b81156120215783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260066020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b60148054600191905f9061206b90849061ffff1661296a565b92506101000a81548161ffff021916908361ffff160217905550565b610b10828260405180602001604052805f8152506122bb565b5f81815b84518110156120da576120d0828683815181106120c3576120c3612ae4565b60200260200101516122d1565b91506001016120a4565b509392505050565b6001600160a01b03821661211457604051630b61174360e31b81526001600160a01b0383166004820152602401610c2f565b6001600160a01b038381165f81815260076020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106121be5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106121ea576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061220857662386f26fc10000830492506010015b6305f5e1008310612220576305f5e100830492506008015b612710831061223457612710830492506004015b60648310612246576064830492506002015b600a8310610af85760010192915050565b5f6001600160a01b038316158015906122b35750826001600160a01b0316846001600160a01b0316148061229057506122908484611843565b806122b357505f828152600660205260409020546001600160a01b038481169116145b949350505050565b6122c58383612300565b610f985f848484611cf3565b5f8183106122eb575f8281526020849052604090206122f9565b5f8381526020839052604090205b9392505050565b6001600160a01b03821661232957604051633250574960e11b81525f6004820152602401610c2f565b5f61233583835f611a0e565b90506001600160a01b03811615610f98576040516339e3563760e11b81525f6004820152602401610c2f565b6001600160e01b031981168114611011575f80fd5b5f60208284031215612386575f80fd5b81356122f981612361565b80356001600160a01b03811681146123a7575f80fd5b919050565b5f80604083850312156123bd575f80fd5b6123c683612391565b915060208301356001600160601b03811681146123e1575f80fd5b809150509250929050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6122f960208301846123ec565b5f6020828403121561243c575f80fd5b5035919050565b5f8060408385031215612454575f80fd5b61245d83612391565b946020939093013593505050565b5f6020828403121561247b575f80fd5b6122f982612391565b634e487b7160e01b5f52604160045260245ffd5b5f67ffffffffffffffff808411156124b2576124b2612484565b604051601f8501601f19908116603f011681019082821181831017156124da576124da612484565b816040528093508581528686860111156124f2575f80fd5b858560208301375f602087830101525050509392505050565b5f6020828403121561251b575f80fd5b813567ffffffffffffffff811115612531575f80fd5b8201601f81018413612541575f80fd5b6122b384823560208401612498565b803580151581146123a7575f80fd5b5f6020828403121561256f575f80fd5b6122f982612550565b803561ffff811681146123a7575f80fd5b5f60208284031215612599575f80fd5b6122f982612578565b5f805f606084860312156125b4575f80fd5b6125bd84612391565b92506125cb60208501612391565b9150604084013590509250925092565b5f80604083850312156125ec575f80fd5b50508035926020909101359150565b5f8083601f84011261260b575f80fd5b50813567ffffffffffffffff811115612622575f80fd5b6020830191508360208260051b8501011115610e0f575f80fd5b5f805f6040848603121561264e575f80fd5b61265784612391565b9250602084013567ffffffffffffffff811115612672575f80fd5b61267e868287016125fb565b9497909650939450505050565b5f805f6040848603121561269d575f80fd5b61265784612578565b5f80604083850312156126b7575f80fd5b6126c083612391565b91506126ce60208401612550565b90509250929050565b5f805f80608085870312156126ea575f80fd5b6126f385612391565b935061270160208601612391565b925060408501359150606085013567ffffffffffffffff811115612723575f80fd5b8501601f81018713612733575f80fd5b61274287823560208401612498565b91505092959194509250565b5f806040838503121561275f575f80fd5b61276883612391565b91506126ce60208401612391565b600181811c9082168061278a57607f821691505b6020821081036127a857634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115610f9857805f5260205f20601f840160051c810160208510156127d35750805b601f840160051c820191505b81811015611e12575f81556001016127df565b815167ffffffffffffffff81111561280c5761280c612484565b6128208161281a8454612776565b846127ae565b602080601f831160018114612853575f841561283c5750858301515b5f19600386901b1c1916600185901b1785556128aa565b5f85815260208120601f198616915b8281101561288157888601518255948401946001909101908401612862565b508582101561289e57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52601160045260245ffd5b8082028115828204841417610af857610af86128b2565b5f826128f757634e487b7160e01b5f52601260045260245ffd5b500490565b6020808252601d908201527f54686973206d696e74207068617365206973206e6f7420616374697665000000604082015260600190565b60208082526017908201527f496e73756666696369656e742045544820616d6f756e74000000000000000000604082015260600190565b61ffff818116838216019080821115612985576129856128b2565b5092915050565b6020808252602e908201527f4d617820616c6c6f776564206d696e7420616d6f756e7420657863656564656460408201526d08199bdc881dda1a5d195b1a5cdd60921b606082015260800190565b5f81546129e681612776565b600182811680156129fe5760018114612a1357612a3f565b60ff1984168752821515830287019450612a3f565b855f526020805f205f5b85811015612a365781548a820152908401908201612a1d565b50505082870194505b5050505092915050565b5f612a5482866129da565b84518060208701835e5f9101908152612a6d81856129da565b9695505050505050565b5f61ffff808316818103612a8d57612a8d6128b2565b6001019392505050565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f90612a6d908301846123ec565b5f60208284031215612ad9575f80fd5b81516122f981612361565b634e487b7160e01b5f52603260045260245ffdfea26469706673582212205f774f6d1f742a473008c951eebc272f5e11f8f0861328bafeb48ecc9d42168d64736f6c63430008190033
Verified Source Code Partial Match
Compiler: v0.8.25+commit.b61c2a91
EVM: cancun
Optimization: Yes (200 runs)
NodeRunners.sol 273 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9 <0.9.0;
/*
_____ _____
/\ \ /\ \
/::\____\ /::\ \
/::::| | /::::\ \
/:::::| | /::::::\ \
/::::::| | /:::/\:::\ \
/:::/|::| | /:::/__\:::\ \
/:::/ |::| | /::::\ \:::\ \
/:::/ |::| | _____ /::::::\ \:::\ \
/:::/ |::| |/\ \ /:::/\:::\ \:::\____\
/:: / |::| /::\____\/:::/ \:::\ \:::| |
\::/ /|::| /:::/ /\::/ |::::\ /:::|____|
\/____/ |::| /:::/ / \/____|:::::\/:::/ /
|::|/:::/ / |:::::::::/ /
|::::::/ / |::|\::::/ /
|:::::/ / |::| \::/____/
|::::/ / |::| ~|
/:::/ / |::| |
/:::/ / \::| |
\::/ / \:| |
\/____/ \|___|
*/
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Royalty.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract NodeRunners is ERC721Royalty, Ownable, ReentrancyGuard {
using Strings for uint256;
string public baseURI;
string public notRevealedURI;
string public PROVENANCE;
string public baseExtension = ".json";
bytes32 public merkleRoot;
mapping(address => uint16) amountMintedWhitelist_1;
mapping(address => uint16) amountMintedWhitelist_2;
uint256 public costWhitelist_1 = 0.069 ether;
uint256 public costWhitelist_2 = 0.069 ether;
uint256 public costPublicSale = 0.069 ether;
uint16 public totalSupply = 0;
uint16 public maxSupply = 3333;
uint16 public maxMintAmountWhitelist_1 = 2;
uint16 public maxMintAmountWhitelist_2 = 2;
uint16 public maxMintAmountPublicSale = 2;
bool public paused = false;
bool public frozenMetadata = false;
uint8 public mintPhase = 1;
mapping(address => bool) private blockedAddresses;
constructor(
string memory _name, //NodeRunners
string memory _symbol, //NRT
string memory _initNotRevealedURI,
address _receiver,
uint96 feeNumerator
) ERC721(_name, _symbol) Ownable(msg.sender) {
_setDefaultRoyalty(_receiver, feeNumerator);
setNotRevealedURI(_initNotRevealedURI);
}
function mintWhitelist_1(uint16 _mintAmount, bytes32[] calldata _merkleProof) external payable {
require(mintPhase == 1, "This mint phase is not active");
require(isWhitelisted(msg.sender, _merkleProof), "You are not whitelisted");
uint16 amountMinted = amountMintedWhitelist_1[msg.sender];
require(amountMinted + _mintAmount <= maxMintAmountWhitelist_1, "Max allowed mint amount exceeded for whitelist");
require(msg.value >= costWhitelist_1 * _mintAmount, "Insufficient ETH amount");
amountMintedWhitelist_1[msg.sender] += _mintAmount;
_mint(_mintAmount);
}
function mintWhitelist_2(uint16 _mintAmount, bytes32[] calldata _merkleProof) external payable {
require(mintPhase == 2, "This mint phase is not active");
require(isWhitelisted(msg.sender, _merkleProof), "You are not whitelisted");
uint16 amountMinted = amountMintedWhitelist_2[msg.sender];
require(amountMinted + _mintAmount <= maxMintAmountWhitelist_2, "Max allowed mint amount exceeded for whitelist");
require(msg.value >= costWhitelist_2 * _mintAmount, "Insufficient ETH amount");
amountMintedWhitelist_2[msg.sender] += _mintAmount;
_mint(_mintAmount);
}
function mintPublicSale(uint16 _mintAmount) external payable {
require(mintPhase == 3, "This mint phase is not active");
require(_mintAmount <= maxMintAmountPublicSale, "Max allowed mint amount exceeded for public sale");
require(msg.value >= costPublicSale * _mintAmount, "Insufficient ETH amount");
_mint(_mintAmount);
}
//MINTING FOR ONLY THE OWNER
function mintOnlyOwner(uint16 _mintAmount) external onlyOwner {
_mint(_mintAmount);
}
//---------INTERNAL-----------//
function _mint(uint16 _mintAmount) internal {
require(!paused, "Please wait until unpaused");
require(_mintAmount > 0, "Need to mint more than 0");
require(totalSupply + _mintAmount <= maxSupply, "Max allowed supply exceeded");
for (uint16 i = 1; i <= _mintAmount; i++) {
incrementTotalSupply();
_safeMint(msg.sender, totalSupply);
}
}
function incrementTotalSupply() internal {
totalSupply += 1;
}
function isWhitelisted(address _user, bytes32[] calldata _merkleProof) public view returns (bool) {
bytes32 leaf = keccak256(abi.encodePacked(_user));
return MerkleProof.verify(_merkleProof, merkleRoot, leaf);
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_ownerOf(tokenId) != address(0), "tokenId does not exist");
if (!isRevealed()) {
return notRevealedURI;
}
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString(), baseExtension)) : "";
}
//--------ONLY OWNER--------//
function reveal(string memory _newBaseURI) public onlyOwner {
require(!frozenMetadata, "Metadata is frozen");
baseURI = _newBaseURI;
}
function isRevealed() public view returns (bool) {
return bytes(baseURI).length > 0;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedURI = _notRevealedURI;
}
function setProvenanceHash(string memory _provenanceHash) public onlyOwner {
PROVENANCE = _provenanceHash;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
//SETTERS FOR PAUSED, REVEALED AND FREEZE METADATA
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function freezeMetadata() public onlyOwner {
require(isRevealed(), "Base URI is not set");
frozenMetadata = true;
}
function setOnlyWhitelist_1() public onlyOwner {
mintPhase = 1;
}
function setOnlyWhitelist_2() public onlyOwner {
mintPhase = 2;
}
function setOnlyPublicSale() public onlyOwner {
mintPhase = 3;
}
//SETTERS FOR COSTS
function setCostWhitelist_1(uint256 _newValue) public onlyOwner {
costWhitelist_1 = _newValue;
}
function setCostWhitelist_2(uint256 _newValue) public onlyOwner {
costWhitelist_2 = _newValue;
}
function setCostPublicSale(uint256 _newValue) public onlyOwner {
costPublicSale = _newValue;
}
//SETTERS FOR MAXMINTAMOUNT
function setMaxMintAmountWhitelist_1(uint16 _newValue) public onlyOwner {
maxMintAmountWhitelist_1 = _newValue;
}
function setMaxMintAmountWhitelist_2(uint16 _newValue) public onlyOwner {
maxMintAmountWhitelist_2 = _newValue;
}
function setMaxMintAmountPublicSale(uint16 _newValue) public onlyOwner {
maxMintAmountPublicSale = _newValue;
}
//SET WHITELIST
function setWhitelistHash(bytes32 _merkleRoot) external onlyOwner {
merkleRoot = _merkleRoot;
}
//WITHDRAWALS
function withdraw() public payable onlyOwner nonReentrant {
// ================This will pay 20%====================================
(bool phunsuccess, ) = payable(0xbEaB247e6ec95133a991a05A516A1b923fB70F7C).call{value: (address(this).balance * 20) / 100}("");
require(phunsuccess);
// ====================================================================
// ================This will pay remaining 80%=========================
(bool coldsuccess, ) = payable(0x5AA333D43ee39f412b0c2a3F0b28aA580c87aC50).call{value: address(this).balance}("");
require(coldsuccess);
// ====================================================================
// This will payout the OWNER the remainder of the contract balance if any left.
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
// =====================================================================
}
// ROYALTIES
function setDefaultRoyalty(address _receiver, uint96 feeNumerator) public onlyOwner {
_setDefaultRoyalty(_receiver, feeNumerator);
}
function getAmountMintedWhitelist_1(address _address) external view returns (uint16) {
return amountMintedWhitelist_1[_address];
}
function getAmountMintedWhitelist_2(address _address) external view returns (uint16) {
return amountMintedWhitelist_2[_address];
}
function approve(address to, uint256 tokenId) public virtual override {
require(!blockedAddresses[to], "Address is blocked for approval");
super.approve(to, tokenId);
}
function setApprovalForAll(address operator, bool approved) public virtual override {
require(!blockedAddresses[operator], "Operator is blocked for approval");
super.setApprovalForAll(operator, approved);
}
function isAddressBlocked(address _address) public view returns (bool) {
return blockedAddresses[_address];
}
function setBlockedAddress(address _address, bool _blocked) external onlyOwner {
blockedAddresses[_address] = _blocked;
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Strings.sol 94 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
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_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}
Math.sol 415 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
IERC2981.sol 23 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
ERC721.sol 483 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.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, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
mapping(uint256 tokenId => address) private _owners;
mapping(address owner => uint256) private _balances;
mapping(uint256 tokenId => address) private _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual returns (uint256) {
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(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 overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
// Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
* consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
* `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
*/
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
return _tokenApprovals[tokenId];
}
/**
* @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
* particular (ignoring whether it is owned by `owner`).
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
/**
* @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
* Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
* the `spender` for the specific `tokenId`.
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increasing an account's balance using this function tends to be paired with an override of the
* {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
* remain consistent with one another.
*/
function _increaseBalance(address account, uint128 value) internal virtual {
unchecked {
_balances[account] += value;
}
}
/**
* @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
* (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that
* `auth` is either the owner of the token, or approved to operate on the token (by the owner).
*
* Emits a {Transfer} event.
*
* NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
address from = _ownerOf(tokenId);
// Perform (optional) operator check
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
// Execute the update
if (from != address(0)) {
// Clear approval. No need to re-authorize or emit the Approval event
_approve(address(0), tokenId, address(0), false);
unchecked {
_balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
_balances[to] += 1;
}
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
return from;
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
/**
* @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
_checkOnERC721Received(address(0), to, tokenId, data);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
* are aware of the ERC721 standard to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is like {safeTransferFrom} in the sense that it invokes
* {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `tokenId` token must exist and be owned by `from`.
* - `to` cannot be the zero address.
* - `from` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
* either the owner of the token, or approved to operate on all tokens held by this owner.
*
* Emits an {Approval} event.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
/**
* @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
* emitted in the context of transfers.
*/
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
// Avoid reading the owner unless necessary
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
// We do not use _isAuthorized because single-token approvals should not be able to call approve
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
if (emitEvent) {
emit Approval(owner, to, tokenId);
}
}
_tokenApprovals[tokenId] = to;
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Requirements:
* - operator can't be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
* Returns the owner.
*
* Overrides to ownership logic should be done to {_ownerOf}.
*/
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
* recipient doesn't accept the token transfer. 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
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
revert ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC721InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../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`.
*
* 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;
/**
* @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
ERC2981.sol 137 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.20;
import {IERC2981} from "../../interfaces/IERC2981.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 tokenId => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev The default royalty set is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidDefaultRoyalty(uint256 numerator, uint256 denominator);
/**
* @dev The default royalty receiver is invalid.
*/
error ERC2981InvalidDefaultRoyaltyReceiver(address receiver);
/**
* @dev The royalty set for an specific `tokenId` is invalid (eg. (numerator / denominator) >= 1).
*/
error ERC2981InvalidTokenRoyalty(uint256 tokenId, uint256 numerator, uint256 denominator);
/**
* @dev The royalty receiver for `tokenId` is invalid.
*/
error ERC2981InvalidTokenRoyaltyReceiver(uint256 tokenId, address receiver);
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidDefaultRoyalty(feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidDefaultRoyaltyReceiver(address(0));
}
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
uint256 denominator = _feeDenominator();
if (feeNumerator > denominator) {
// Royalty fee will exceed the sale price
revert ERC2981InvalidTokenRoyalty(tokenId, feeNumerator, denominator);
}
if (receiver == address(0)) {
revert ERC2981InvalidTokenRoyaltyReceiver(tokenId, address(0));
}
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement 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);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @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 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @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 `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 232 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.20;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Calldata version of {processProof}
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofLen = proof.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
if (leavesLen + proofLen != totalHashes + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
if (proofPos != proofLen) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[totalHashes - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Sorts the pair (a, b) and hashes the result.
*/
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
ERC721Royalty.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/ERC721Royalty.sol)
pragma solidity ^0.8.20;
import {ERC721} from "../ERC721.sol";
import {ERC2981} from "../../common/ERC2981.sol";
/**
* @dev Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty payment
* information.
*
* Royalty information can be specified globally for all token ids via {ERC2981-_setDefaultRoyalty}, and/or individually
* for specific token ids via {ERC2981-_setTokenRoyalty}. The latter takes precedence over the first.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*/
abstract contract ERC721Royalty is ERC2981, ERC721 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../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);
}
Read Contract
PROVENANCE 0x6373a6b1 → string
balanceOf 0x70a08231 → uint256
baseExtension 0xc6682862 → string
baseURI 0x6c0360eb → string
costPublicSale 0x3966fa0f → uint256
costWhitelist_1 0x92057770 → uint256
costWhitelist_2 0xe0601275 → uint256
frozenMetadata 0x8529ccad → bool
getAmountMintedWhitelist_1 0xa9748289 → uint16
getAmountMintedWhitelist_2 0x0a93a058 → uint16
getApproved 0x081812fc → address
isAddressBlocked 0xe7dad4f9 → bool
isApprovedForAll 0xe985e9c5 → bool
isRevealed 0x54214f69 → bool
isWhitelisted 0x5a23dd99 → bool
maxMintAmountPublicSale 0x0311bbd3 → uint16
maxMintAmountWhitelist_1 0xe6d9e56e → uint16
maxMintAmountWhitelist_2 0xf1aacdfd → uint16
maxSupply 0xd5abeb01 → uint16
merkleRoot 0x2eb4a7ab → bytes32
mintPhase 0x17881cbf → uint8
name 0x06fdde03 → string
notRevealedURI 0x72250380 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint16
Write Contract 30 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
freezeMetadata 0xd111515d
No parameters
mintOnlyOwner 0x4cd50b60
uint16 _mintAmount
mintPublicSale 0x54c98403
uint16 _mintAmount
mintWhitelist_1 0xbc497af0
uint16 _mintAmount
bytes32[] _merkleProof
mintWhitelist_2 0x718445da
uint16 _mintAmount
bytes32[] _merkleProof
renounceOwnership 0x715018a6
No parameters
reveal 0x4c261247
string _newBaseURI
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseExtension 0xda3ef23f
string _newBaseExtension
setBlockedAddress 0x92d5011f
address _address
bool _blocked
setCostPublicSale 0x9196f761
uint256 _newValue
setCostWhitelist_1 0xab2dbe4c
uint256 _newValue
setCostWhitelist_2 0x13662197
uint256 _newValue
setDefaultRoyalty 0x04634d8d
address _receiver
uint96 feeNumerator
setMaxMintAmountPublicSale 0x1c0af178
uint16 _newValue
setMaxMintAmountWhitelist_1 0xb6f50fe6
uint16 _newValue
setMaxMintAmountWhitelist_2 0x7c0c32b7
uint16 _newValue
setNotRevealedURI 0xf2c4ce1e
string _notRevealedURI
setOnlyPublicSale 0x7eedcfd0
No parameters
setOnlyWhitelist_1 0x94a10f78
No parameters
setOnlyWhitelist_2 0x0fe4fb6b
No parameters
setPaused 0x16c38b3c
bool _state
setProvenanceHash 0x10969523
string _provenanceHash
setWhitelistHash 0x1b60a072
bytes32 _merkleRoot
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x3ccfd60b
No parameters
Recent Transactions
No transactions found for this address