Address Contract Verified
Address
0x70588Eb4626600e6b9cD49b140E39e5a814D9535
Balance
0 ETH
Nonce
1
Code Size
13343 bytes
Creator
0x8EFDbeCf...8085 at tx 0x4e92222f...f47200
Indexed Transactions
0
Contract Bytecode
13343 bytes
0x608060405234801561001057600080fd5b506004361061025c5760003560e01c80636352211e11610145578063a22cb465116100bd578063d1fdeaa71161008c578063d547741f11610071578063d547741f14610573578063da216e0c14610586578063e985e9c51461059957600080fd5b8063d1fdeaa714610525578063d53913931461054c57600080fd5b8063a22cb465146104e4578063a2309ff8146104f7578063b88d4fde146104ff578063c87b56dd1461051257600080fd5b806391d148541161011457806395d89b41116100f957806395d89b41146104cd578063966ff650146104d5578063a217fddf146104dc57600080fd5b806391d148541461046d578063931868fe146104a657600080fd5b80636352211e1461042357806370a08231146104365780638832e6e3146104495780638da5cb5b1461045c57600080fd5b80632a55205a116101d857806336568abe116101a75780634f6ccce71161018c5780634f6ccce7146103ea57806359506d09146103fd5780635ad448421461041057600080fd5b806336568abe146103c457806342842e0e146103d757600080fd5b80632a55205a146103595780632af4c31e1461038b5780632f2ff15d1461039e5780632f745c59146103b157600080fd5b80630e05010c1161022f5780631837fc64116102145780631837fc64146102fc57806323b872dd14610323578063248a9ca31461033657600080fd5b80630e05010c146102de57806318160ddd146102f457600080fd5b806301ffc9a71461026157806306fdde0314610289578063081812fc1461029e578063095ea7b3146102c9575b600080fd5b61027461026f366004612d67565b6105d5565b60405190151581526020015b60405180910390f35b610291610631565b6040516102809190612dd4565b6102b16102ac366004612de7565b6106c3565b6040516001600160a01b039091168152602001610280565b6102dc6102d7366004612e1c565b610720565b005b6102e66107df565b604051908152602001610280565b6102e66107f0565b6102e67f9d2b5027b19aca88f2f1800508f7464c1461521b1a4fd3efe3ebd10aff8cee1981565b6102dc610331366004612e46565b610805565b6102e6610344366004612de7565b60009081526009602052604090206001015490565b61036c610367366004612e82565b610850565b604080516001600160a01b039093168352602083019190915201610280565b6102dc610399366004612ea4565b61092d565b6102dc6103ac366004612ebf565b610a43565b6102e66103bf366004612e1c565b610a68565b6102dc6103d2366004612ebf565b610b19565b6102dc6103e5366004612e46565b610ba5565b6102e66103f8366004612de7565b610bc0565b6102dc61040b366004612ea4565b610c06565b6102b161041e366004612de7565b610e1a565b6102b1610431366004612de7565b610e27565b6102e6610444366004612ea4565b610ebd565b6102dc610457366004612fc9565b610f0b565b600a546001600160a01b03166102b1565b61027461047b366004612ebf565b60009182526009602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6102e67f01717aaaa351726e46d35b2c987b274c47e02dd75d039b99548e3deef67c1a7181565b61029161117d565b60006102e6565b6102e6600081565b6102dc6104f2366004613020565b61118c565b6102e6611197565b6102dc61050d36600461305c565b6111a3565b610291610520366004612de7565b6111ef565b6102e67fae4d1e12831401715a9adfc399ef79aefc968299d67b5fbb2a6eb4cbd63bd49e81565b6102e67f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a681565b6102dc610581366004612ebf565b611423565b6102dc6105943660046130c4565b611448565b6102746105a7366004613101565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f8832e6e300000000000000000000000000000000000000000000000000000000148061062b575061062b8261170d565b92915050565b6060600080546106409061311d565b80601f016020809104026020016040519081016040528092919081815260200182805461066c9061311d565b80156106b95780601f1061068e576101008083540402835291602001916106b9565b820191906000526020600020905b81548152906001019060200180831161069c57829003601f168201915b5050505050905090565b60006106ce82611763565b610704576040517fb1d04f0800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b506000908152600560205260409020546001600160a01b031690565b600061072b82610e27565b9050806001600160a01b0316836001600160a01b031603610778576040517f4fe05af100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336001600160a01b03821614801590610798575061079681336105a7565b155b156107cf576040517fd585559200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107da818484611775565b505050565b60006107eb600b611483565b905090565b6000806107fb611197565b6107eb919061319f565b61080f33826117e9565b610845576040517f4fe05af100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107da8383836118a6565b60008281526008602090815260408083208151808301909252546001600160a01b038116808352740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff169282019290925282916108f15750604080518082019091526007546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1660208201525b602081015160009061271090610915906bffffffffffffffffffffffff16876131b2565b61091f91906131d1565b915196919550909350505050565b7fae4d1e12831401715a9adfc399ef79aefc968299d67b5fbb2a6eb4cbd63bd49e61095781611994565b6001600160a01b0382166109d85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b600a80546001600160a01b038481167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b600082815260096020526040902060010154610a5e81611994565b6107da83836119a1565b6000806008610a7760026114b5565b901c90506000805b6000610a8d60048884611a61565b905080600003610aa05750600101610adf565b6000610aab82611a87565b9050868185011115610ad557600883901b610ac883868a03611cc3565b019550505050505061062b565b9290920191506001015b82811115610a7f576040517f1390f2a100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381163314610b975760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016109cf565b610ba18282612014565b5050565b6107da838383604051806020016040528060008152506111a3565b6000610bca6107f0565b8210610c02576040517f1390f2a100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5090565b7f9d2b5027b19aca88f2f1800508f7464c1461521b1a4fd3efe3ebd10aff8cee19610c3081611994565b6001600160a01b038216610cac5760405162461bcd60e51b815260206004820152602360248201527f44616973793a2070726f766964657220697320746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016109cf565b6000610cb8600b611483565b90508015610e09576000610cd8610cd060018461319f565b600b9061148d565b90506000816001600160a01b03166329d7e69b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e919061320c565b90506000826001600160a01b031663d5abeb016040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da4919061320c565b9050610dae611197565b610db88284613225565b14610e055760405162461bcd60e51b815260206004820152601760248201527f44616973793a20696e76616c696420737461727420696400000000000000000060448201526064016109cf565b5050505b610e14600b846114a0565b50505050565b600061062b600b8361148d565b600081610e3460026114b5565b11610e6b576040517fb1d04f0800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610e786003846120b5565b905060016001600160a01b0382161161062b576040517fb1d04f0800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060016001600160a01b03831611610f02576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61062b82612112565b7f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6610f3581611994565b6000610f3f6107f0565b90506000610f4d600b611483565b905060008111610f9f5760405162461bcd60e51b815260206004820152601660248201527f44616973793a206e6f207572692070726f76696465720000000000000000000060448201526064016109cf565b6000610faf610cd060018461319f565b90506001600160a01b03811661102d5760405162461bcd60e51b815260206004820152602360248201527f44616973793a2070726f766964657220697320746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016109cf565b6000816001600160a01b03166329d7e69b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561106d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611091919061320c565b90506000826001600160a01b031663d5abeb016040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f7919061320c565b905084821115801561111b575061110e8183613225565b6111188987613225565b11155b6111675760405162461bcd60e51b815260206004820152601460248201527f44616973793a20696e76616c696420636f756e7400000000000000000000000060448201526064016109cf565b611172898989612154565b505050505050505050565b6060600180546106409061311d565b610ba13383836121eb565b60006107eb60026114b5565b6111ad33836117e9565b6111e3576040517f4fe05af100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e14848484846122c1565b60606111fa82611763565b61126c5760405162461bcd60e51b815260206004820152602660248201527f44616973793a2055524920717565727920666f72206e6f6e6578697374656e7460448201527f20746f6b656e000000000000000000000000000000000000000000000000000060648201526084016109cf565b600080611279600b611483565b905060005b818110156113b4576000611293600b8361148d565b90506000816001600160a01b031663d5abeb016040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f9919061320c565b6113039086613225565b90508087101561139e576040517fc87b56dd000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b0383169063c87b56dd90602401600060405180830381865afa15801561136b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113939190810190613238565b979650505050505050565b93508190506113ac816132af565b91505061127e565b5060405162461bcd60e51b815260206004820152603160248201527f45524337323155524953746f726167653a2055524920717565727920666f722060448201527f6e6f6e6578697374656e7420746f6b656e00000000000000000000000000000060648201526084016109cf565b60008281526009602052604090206001015461143e81611994565b6107da8383612014565b7f01717aaaa351726e46d35b2c987b274c47e02dd75d039b99548e3deef67c1a7161147281611994565b6107da828461230e565b6000199055565b600061062b825490565b60006114998383612439565b9392505050565b6000611499836001600160a01b038416612463565b805460009060001981146114c95780611499565b60009392505050565b606061062b6001600160a01b03831660145b606060006114f38360026131b2565b6114fe906002613225565b67ffffffffffffffff81111561151657611516612eeb565b6040519080825280601f01601f191660200182016040528015611540576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611577576115776132c9565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106115da576115da6132c9565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060006116168460026131b2565b611621906001613225565b90505b60018111156116be577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110611662576116626132c9565b1a60f81b828281518110611678576116786132c9565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936116b7816132f8565b9050611624565b5083156114995760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109cf565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061062b575061062b826124b2565b60008161176e6107f0565b1192915050565b60008181526005602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0386811691821790925591518493918716917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006117f482611763565b61182a576040517fb1d04f0800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61183660048484612549565b156118435750600161062b565b600061184e83610e27565b6001600160a01b0380821660009081526006602090815260408083209389168352929052205490915060ff168061189e57506000838152600560205260409020546001600160a01b038581169116145b949350505050565b6118b260048483612549565b6118e8576040517fa114810000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016001600160a01b0383161161192b576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119358382612580565b61194260048484846125ed565b61194e60038284612603565b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b61199e81336126b4565b50565b60008281526009602090815260408083206001600160a01b038516845290915290205460ff16610ba15760008281526009602090815260408083206001600160a01b0385168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055611a1d3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008381611a6f8486612729565b81526020019081526020016000205490509392505050565b600081600003611a9957506000919050565b7f55555555555555555555555555555555555555555555555555555555555555558260011c167f555555555555555555555555555555555555555555555555555555555555555583160191507f33333333333333333333333333333333333333333333333333333333333333338260021c167f333333333333333333333333333333333333333333333333333333333333333383160191507f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f8260041c167f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f83160191507eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff8260081c167eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff83160191507dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff8260101c167dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff83160191507bffffffff00000000ffffffff00000000ffffffff00000000ffffffff8260201c167bffffffff00000000ffffffff00000000ffffffff00000000ffffffff831601915077ffffffffffffffff0000000000000000ffffffffffffffff8260401c1677ffffffffffffffff0000000000000000ffffffffffffffff83160191506fffffffffffffffffffffffffffffffff8260801c166fffffffffffffffffffffffffffffffff8316019150819050919050565b600060ff821115611d165760405162461bcd60e51b815260206004820152601960248201527f426974733a20696e646578206f7574206f6620626f756e64730000000000000060448201526064016109cf565b82600003611d27575060001961062b565b60009050600182019150827f55555555555555555555555555555555555555555555555555555555555555558160011c167f55555555555555555555555555555555555555555555555555555555555555558216017f33333333333333333333333333333333333333333333333333333333333333338160021c167f33333333333333333333333333333333333333333333333333333333333333338216017f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f8160041c167f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f8216017eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff8160081c167eff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff8216017dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff8160101c167dffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff8216017bffffffff00000000ffffffff00000000ffffffff00000000ffffffff8160201c167bffffffff00000000ffffffff00000000ffffffff00000000ffffffff82160177ffffffffffffffff0000000000000000ffffffffffffffff8160401c1677ffffffffffffffff0000000000000000ffffffffffffffff8216016fffffffffffffffffffffffffffffffff81169050808a1115611f4357608089019850808a0399505b5080881c67ffffffffffffffff16808a1115611f6557604089019850808a0399505b5081881c63ffffffff16808a1115611f8357602089019850808a0399505b5082881c61ffff16808a1115611f9f57601089019850808a0399505b5083881c60ff16808a1115611fba57600889019850808a0399505b5084881c600f16808a1115611fd557600489019850808a0399505b5085881c600316808a1115611ff057600289019850808a0399505b5086881c600116808a1115612006576001890198505b505050505050505092915050565b60008281526009602090815260408083206001600160a01b038516845290915290205460ff1615610ba15760008281526009602090815260408083206001600160a01b038516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000815b600081815260208581526040909120549081901c9063ffffffff166001600160a01b038216158015906120ed575084818401115b156120fc5750915061062b9050565b50506000198101906120b9575060009392505050565b600080600861212160026114b5565b901c90506000805b61213d61213860048784611a61565b611a87565b909101906001018281111561212957509392505050565b600061216060026114b5565b905061216d8482856127d3565b6001600160a01b0384163b6121825750505050565b808301815b61219460008783876128ce565b6121ca576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600101818111156121875781858401146121e357600080fd5b505050505050565b816001600160a01b0316836001600160a01b031603612236576040517fb06307db00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383811660008181526006602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6122cc8484846118a6565b6122d8848484846128ce565b610e14576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6127106bffffffffffffffffffffffff821611156123945760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c6550726963650000000000000000000000000000000000000000000060648201526084016109cf565b6001600160a01b0382166123ea5760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c69642072656365697665720000000000000060448201526064016109cf565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff90911660209092018290527401000000000000000000000000000000000000000090910217600755565b6000826000018281548110612450576124506132c9565b9060005260206000200154905092915050565b60008181526001830160205260408120546124aa5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561062b565b50600061062b565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a00000000000000000000000000000000000000000000000000000000148061062b57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461062b565b60008061255a600884901c85612729565b600090815260208690526040902054600160ff85169190911c8116149150509392505050565b60008181526005602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055518291906001600160a01b038516907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925908390a45050565b6125f8848483612a33565b610e14848383612a6b565b600082815260208481526040909120549081901c9063ffffffff16612629836001612aa2565b6000858152602087905260409020556001600160a01b038216158061264f575060018111155b1561265b575050505050565b6000612668856001613225565b600081815260208881526040909120549192501c6001600160a01b03166121e35761269d8361269860018561319f565b612aa2565b600082815260208890526040902055505050505050565b60008281526009602090815260408083206001600160a01b038516845290915290205460ff16610ba1576126e7816114d2565b6126f28360206114e4565b60405160200161270392919061330f565b60408051601f198184030181529082905262461bcd60e51b82526109cf91600401612dd4565b600063ffffffff8311156127a55760405162461bcd60e51b815260206004820152602e60248201527f455243373231424f204173736574733a20706167654e6f206d7573742062652060448201527f6c657373207468616e20325e333200000000000000000000000000000000000060648201526084016109cf565b5077ffffffffffffffffffffffffffffffffffffffff00000000602082901b1663ffffffff83161792915050565b60016001600160a01b03841611612816576040517fe6c4247b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b620100006128248284613225565b111561285c576040517f12d23d8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6128696004848484612b43565b6128766003848484612c2a565b612881600282612c4b565b60005b604051838201906001600160a01b038616906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46001018181106128845750505050565b60006001600160a01b0384163b15612a28576040517f150b7a020000000000000000000000000000000000000000000000000000000081526001600160a01b0385169063150b7a029061292b903390899088908890600401613390565b6020604051808303816000875af1925050508015612966575060408051601f3d908101601f19168201909252612963918101906133cc565b60015b6129dd573d808015612994576040519150601f19603f3d011682016040523d82523d6000602084013e612999565b606091505b5080516000036129d5576040517fd1a57ed600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061189e565b506001949350505050565b6000612a43600883901c84612729565b60009081526020949094525060409092208054600160ff9094169390931b1990921690915550565b6000612a7b600883901c84612729565b60009081526020949094525060409092208054600160ff9094169390931b90921790915550565b600063ffffffff821115612b1e5760405162461bcd60e51b815260206004820152602d60248201527f455243373231424f204f776e6572733a20636f756e74206d757374206265206c60448201527f657373207468616e20325e33320000000000000000000000000000000000000060648201526084016109cf565b5060209190911b77ffffffffffffffffffffffffffffffffffffffff00000000161790565b8015610e145760006001612b578385613225565b612b61919061319f565b9050600883811c9082901c808214612be1576000612b7f8388612729565b90506000612b8d8389612729565b9050815b600019828203612ba45760ff80881690031c5b838203612bb957600160ff8a1681901b909103015b600082815260208c9052604090208054909117905560010181811115612b9157505050612c21565b600160ff86811682901b6000198287169092039190911c030180886000612c08868b612729565b8152602081019190915260400160002080549091179055505b50505050505050565b612c348382612aa2565b600092835260209490945250604090209190915550565b60008111612cc15760405162461bcd60e51b815260206004820152602560248201527f436f756e7465723a20636f756e74206d7573742062652067726561746572207460448201527f68616e203000000000000000000000000000000000000000000000000000000060648201526084016109cf565b815460006000198214612cdd57612cd88383613225565b612cdf565b825b90506000198103612d325760405162461bcd60e51b815260206004820152601160248201527f436f756e7465723a206f766572666c6f7700000000000000000000000000000060448201526064016109cf565b9092555050565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461199e57600080fd5b600060208284031215612d7957600080fd5b813561149981612d39565b60005b83811015612d9f578181015183820152602001612d87565b50506000910152565b60008151808452612dc0816020860160208601612d84565b601f01601f19169290920160200192915050565b6020815260006114996020830184612da8565b600060208284031215612df957600080fd5b5035919050565b80356001600160a01b0381168114612e1757600080fd5b919050565b60008060408385031215612e2f57600080fd5b612e3883612e00565b946020939093013593505050565b600080600060608486031215612e5b57600080fd5b612e6484612e00565b9250612e7260208501612e00565b9150604084013590509250925092565b60008060408385031215612e9557600080fd5b50508035926020909101359150565b600060208284031215612eb657600080fd5b61149982612e00565b60008060408385031215612ed257600080fd5b82359150612ee260208401612e00565b90509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612f4357612f43612eeb565b604052919050565b600067ffffffffffffffff821115612f6557612f65612eeb565b50601f01601f191660200190565b600082601f830112612f8457600080fd5b8135612f97612f9282612f4b565b612f1a565b818152846020838601011115612fac57600080fd5b816020850160208301376000918101602001919091529392505050565b600080600060608486031215612fde57600080fd5b612fe784612e00565b925060208401359150604084013567ffffffffffffffff81111561300a57600080fd5b61301686828701612f73565b9150509250925092565b6000806040838503121561303357600080fd5b61303c83612e00565b91506020830135801515811461305157600080fd5b809150509250929050565b6000806000806080858703121561307257600080fd5b61307b85612e00565b935061308960208601612e00565b925060408501359150606085013567ffffffffffffffff8111156130ac57600080fd5b6130b887828801612f73565b91505092959194509250565b600080604083850312156130d757600080fd5b82356bffffffffffffffffffffffff811681146130f357600080fd5b9150612ee260208401612e00565b6000806040838503121561311457600080fd5b6130f383612e00565b600181811c9082168061313157607f821691505b60208210810361316a577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8181038181111561062b5761062b613170565b60008160001904831182151516156131cc576131cc613170565b500290565b600082613207577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b60006020828403121561321e57600080fd5b5051919050565b8082018082111561062b5761062b613170565b60006020828403121561324a57600080fd5b815167ffffffffffffffff81111561326157600080fd5b8201601f8101841361327257600080fd5b8051613280612f9282612f4b565b81815285602083850101111561329557600080fd5b6132a6826020830160208601612d84565b95945050505050565b600060001982036132c2576132c2613170565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008161330757613307613170565b506000190190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613347816017850160208801612d84565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613384816028840160208801612d84565b01602801949350505050565b60006001600160a01b038087168352808616602084015250836040830152608060608301526133c26080830184612da8565b9695505050505050565b6000602082840312156133de57600080fd5b815161149981612d3956fea2646970667358221220622a8dc184edf5333eacd37e2ec1d65a61b09a69fa3211e8b592fe0b7eb7b4c664736f6c63430008100033
Verified Source Code Full Match
Compiler: v0.8.16+commit.07a7930e
EVM: london
Optimization: Yes (9999 runs)
Daisy.sol 113 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "erc721bo/contracts/extensions/ERC721BONonburnable.sol";
import "./ITokenUriProvider.sol";
import "./IDaisy.sol";
contract Daisy is ERC721BONonburnable, ERC2981, AccessControl, IDaisy {
using Strings for uint256;
using EnumerableSet for EnumerableSet.AddressSet;
address private _owner;
bytes32 public constant CHANGE_ROYALTY_ROLE = keccak256("CHANGE_ROYALTY_ROLE");
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant PROVIDER_ADMIN_ROLE = keccak256("PROVIDER_ADMIN_ROLE");
bytes32 public constant OWNER_ADMIN_ROLE = keccak256("OWNER_ADMIN_ROLE");
EnumerableSet.AddressSet private _uriProviders;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(string memory name,
string memory symbol,
uint96 feeNumerator,
address payee,
address defaultProvider) ERC721BO(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(PROVIDER_ADMIN_ROLE, msg.sender);
_setupRole(OWNER_ADMIN_ROLE, msg.sender);
_setupRole(CHANGE_ROYALTY_ROLE, msg.sender);
_setDefaultRoyalty(payee, feeNumerator);
addUriProvider(defaultProvider);
}
function setDefaultRoyalty(uint96 feeNumerator, address payee) public virtual onlyRole(CHANGE_ROYALTY_ROLE) {
_setDefaultRoyalty(payee, feeNumerator);
}
function changeOwnership(address newOwner) public virtual onlyRole(OWNER_ADMIN_ROLE) {
require(newOwner != address(0), "Ownable: new owner is the zero address");
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
function owner() public view virtual returns (address) {
return _owner;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721BO, ERC2981, AccessControl, IERC165) returns (bool) {
return interfaceId == type(IDaisy).interfaceId || super.supportsInterface(interfaceId);
}
function addUriProvider(address provider) public virtual onlyRole(PROVIDER_ADMIN_ROLE) {
require(provider != address(0), "Daisy: provider is the zero address");
uint256 providerCount = _uriProviders.length();
if (providerCount > 0)
{
address p = _uriProviders.at(providerCount - 1);
uint256 startId = ITokenUriProvider(p).startId();
uint256 maxSupply = ITokenUriProvider(p).maxSupply();
require(startId + maxSupply == totalMinted(), "Daisy: invalid start id");
}
_uriProviders.add(provider);
}
function uriProvider(uint256 index) public view virtual returns (address) {
return address(uint160(_uriProviders.at(index)));
}
function uriProviderCount() public view virtual returns (uint256) {
return _uriProviders.length();
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "Daisy: URI query for nonexistent token");
uint256 count;
uint256 providerCount = _uriProviders.length();
for (uint256 i = 0; i < providerCount; i++) {
ITokenUriProvider provider = ITokenUriProvider(_uriProviders.at(i));
uint256 a = count + provider.maxSupply();
if (tokenId < a)
return provider.tokenURI(tokenId);
count = a;
}
revert("ERC721URIStorage: URI query for nonexistent token");
}
function safeMint(address to, uint256 count, bytes memory data) external onlyRole(MINTER_ROLE) {
uint256 start = totalSupply();
uint256 providerCount = _uriProviders.length();
require(providerCount > 0, "Daisy: no uri provider");
address provider = _uriProviders.at(providerCount - 1);
require(provider != address(0), "Daisy: provider is the zero address");
uint256 startId = ITokenUriProvider(provider).startId();
uint256 maxSupply = ITokenUriProvider(provider).maxSupply();
require(startId <= start && start + count <= startId + maxSupply, "Daisy: invalid count");
_safeMint(to, count, data);
}
}
IDaisy.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface IDaisy is IERC165 {
function safeMint(address to, uint256 count, bytes memory data) external;
}
Bits.sol 148 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to bits.
*/
library Bits {
uint256 internal constant MASK_BIT_COUNT_ALL_3 = 0x3333333333333333333333333333333333333333333333333333333333333333;
uint256 internal constant MASK_BIT_COUNT_ALL_5 = 0x5555555555555555555555555555555555555555555555555555555555555555;
uint256 internal constant MASK_BIT_COUNT_LOW_4 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F;
uint256 internal constant MASK_BIT_COUNT_LOW_8 = 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF;
uint256 internal constant MASK_BIT_COUNT_LOW_16 = 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF;
uint256 internal constant MASK_BIT_COUNT_LOW_32 = 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF;
uint256 internal constant MASK_BIT_COUNT_LOW_64 = 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF;
uint256 internal constant MASK_BIT_COUNT_LOW_128 = 0x00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
/**
* @dev Returns the number of bits set to true in the given `value`.
*/
function popCount(uint256 flags) internal pure returns (uint256) {
if (flags == 0)
return 0;
assembly {
//Add every 1 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_ALL_5) + ((flags >> 1) & MASK_BIT_COUNT_ALL_5);
flags := add(and(flags, MASK_BIT_COUNT_ALL_5), and(shr(1, flags), MASK_BIT_COUNT_ALL_5))
//Add every 2 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_ALL_3) + ((flags >> 2) & MASK_BIT_COUNT_ALL_3);
flags := add(and(flags, MASK_BIT_COUNT_ALL_3), and(shr(2, flags), MASK_BIT_COUNT_ALL_3))
//Add every 4 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_4) + ((flags >> 4) & MASK_BIT_COUNT_LOW_4);
flags := add(and(flags, MASK_BIT_COUNT_LOW_4), and(shr(4, flags), MASK_BIT_COUNT_LOW_4))
//Add every 8 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_8) + ((flags >> 8) & MASK_BIT_COUNT_LOW_8);
flags := add(and(flags, MASK_BIT_COUNT_LOW_8), and(shr(8, flags), MASK_BIT_COUNT_LOW_8))
//Add every 16 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_16) + ((flags >> 16) & MASK_BIT_COUNT_LOW_16);
flags := add(and(flags, MASK_BIT_COUNT_LOW_16), and(shr(16, flags), MASK_BIT_COUNT_LOW_16))
//Add every 32 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_32) + ((flags >> 32) & MASK_BIT_COUNT_LOW_32);
flags := add(and(flags, MASK_BIT_COUNT_LOW_32), and(shr(32, flags), MASK_BIT_COUNT_LOW_32))
//Add every 64 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_64) + ((flags >> 64) & MASK_BIT_COUNT_LOW_64);
flags := add(and(flags, MASK_BIT_COUNT_LOW_64), and(shr(64, flags), MASK_BIT_COUNT_LOW_64))
//Add every 128 bits in parallel.
//flags = (flags & MASK_BIT_COUNT_LOW_128) + ((flags >> 128) & MASK_BIT_COUNT_LOW_128);
flags := add(and(flags, MASK_BIT_COUNT_LOW_128), and(shr(128, flags), MASK_BIT_COUNT_LOW_128))
}
return flags;
}
/**
* @dev Returns the index of the given `value` counting from the right, with the `n`th bit set to true.
*/
function indexOf(uint256 flags, uint256 n) internal pure returns (uint256 rank) {
require(n <= 0xFF, "Bits: index out of bounds");
if (flags == 0)
{
rank = type(uint256).max;
}
else
{
rank = 0;
assembly {
//n = n + 1;
n := add(n, 1)
/* At each step, the range of the addition target is increased and the results are reserved. */
//uint256 flags0 = flags;
let flags0 := flags
//uint256 flags1 = (flags0 & MASK_BIT_COUNT_ALL_5) + ((flags0 >> 1) & MASK_BIT_COUNT_ALL_5);
let flags1 := add(and(flags0, MASK_BIT_COUNT_ALL_5), and(shr(1, flags0), MASK_BIT_COUNT_ALL_5))
//uint256 flags2 = (flags1 & MASK_BIT_COUNT_ALL_3) + ((flags1 >> 2) & MASK_BIT_COUNT_ALL_3);
let flags2 := add(and(flags1, MASK_BIT_COUNT_ALL_3), and(shr(2, flags1), MASK_BIT_COUNT_ALL_3))
//uint256 flags3 = (flags2 & MASK_BIT_COUNT_LOW_4) + ((flags2 >> 4) & MASK_BIT_COUNT_LOW_4);
let flags3 := add(and(flags2, MASK_BIT_COUNT_LOW_4), and(shr(4, flags2), MASK_BIT_COUNT_LOW_4))
//uint256 flags4 = (flags3 & MASK_BIT_COUNT_LOW_8) + ((flags3 >> 8) & MASK_BIT_COUNT_LOW_8);
let flags4 := add(and(flags3, MASK_BIT_COUNT_LOW_8), and(shr(8, flags3), MASK_BIT_COUNT_LOW_8))
//uint256 flags5 = (flags4 & MASK_BIT_COUNT_LOW_16) + ((flags4 >> 16) & MASK_BIT_COUNT_LOW_16);
let flags5 := add(and(flags4, MASK_BIT_COUNT_LOW_16), and(shr(16, flags4), MASK_BIT_COUNT_LOW_16))
//uint256 flags6 = (flags5 & MASK_BIT_COUNT_LOW_32) + ((flags5 >> 32) & MASK_BIT_COUNT_LOW_32);
let flags6 := add(and(flags5, MASK_BIT_COUNT_LOW_32), and(shr(32, flags5), MASK_BIT_COUNT_LOW_32))
//uint256 flags7 = (flags6 & MASK_BIT_COUNT_LOW_64) + ((flags6 >> 64) & MASK_BIT_COUNT_LOW_64);
let flags7 := add(and(flags6, MASK_BIT_COUNT_LOW_64), and(shr(64, flags6), MASK_BIT_COUNT_LOW_64))
/* Based on the step-by-step addition results, the index is identified by a binary search. */
//flags7 & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
let temp := and(flags7, MASK_BIT_COUNT_LOW_128)
//if (n > temp) { rank += 128; n -= temp; }
if gt(n, temp) { rank := add(rank, 128) n := sub(n, temp) }
//temp = (flags6 >> rank) & 0xFFFFFFFFFFFFFFFF;
temp := and(shr(rank, flags6), 0xFFFFFFFFFFFFFFFF)
//if (n > temp) { rank += 64; n -= temp; }
if gt(n, temp) { rank := add(rank, 64) n := sub(n, temp) }
//temp = (flags5 >> rank) & 0xFFFFFFFF;
temp := and(shr(rank, flags5), 0xFFFFFFFF)
//if (n > temp) { rank += 32; n -= temp; }
if gt(n, temp) { rank := add(rank, 32) n := sub(n, temp) }
//temp = (flags4 >> rank) & 0xFFFF;
temp := and(shr(rank, flags4), 0xFFFF)
//if (n > temp) { rank += 16; n -= temp; }
if gt(n, temp) { rank := add(rank, 16) n := sub(n, temp) }
//temp = (flags3 >> rank) & 0xFF;
temp := and(shr(rank, flags3), 0xFF)
//if (n > temp) { rank += 8; n -= temp; }
if gt(n, temp) { rank := add(rank, 8) n := sub(n, temp) }
//temp = (flags2 >> rank) & 0x0F;
temp := and(shr(rank, flags2), 0x0F)
//if (n > temp) { rank += 4; n -= temp; }
if gt(n, temp) { rank := add(rank, 4) n := sub(n, temp) }
//temp = (flags1 >> rank) & 0x03;
temp := and(shr(rank, flags1), 0x03)
//if (n > temp) { rank += 2; n -= temp; }
if gt(n, temp) { rank := add(rank, 2) n := sub(n, temp) }
//temp = (flags0 >> rank) & 0x01;
temp := and(shr(rank, flags0), 0x01)
//if (n > temp) { rank += 1; }
if gt(n, temp) { rank := add(rank, 1) }
}
}
}
}
Assets.sol 145 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for ownership flag table.
*/
library Assets {
struct Pages {
mapping(uint256 => uint256) _inner;
}
/**
* @dev Returns page key by `pageNo` and `owner`.
*/
function getPageKeyBy(uint256 pageNo, address owner) internal pure returns (uint256) {
require(type(uint32).max >= pageNo, "ERC721BO Assets: pageNo must be less than 2^32");
unchecked {
return (uint256(uint160(owner)) << 32) | uint32(pageNo);
}
}
/**
* @dev Returns ownership flags by `owner` and `pageNo`.
*/
function page(Pages storage pages, address owner, uint256 pageNo) internal view returns (uint256) {
return pages._inner[getPageKeyBy(pageNo, owner)];
}
/**
* @dev Returns whether the `owner` owns the `tokenId`.
* Returns true if owned, false otherwise.
*/
function exists(Pages storage pages, address owner, uint256 tokenId) internal view returns (bool) {
unchecked {
uint256 key = getPageKeyBy(tokenId >> 8, owner);
return (pages._inner[key] >> (tokenId & 0xFF)) & 1 == 1;
}
}
/**
* @dev Set the ownership flag of the `tokenId` of `from` to false and the ownership flag of `to` to true.
*/
function transfer(Pages storage pages, address from, address to, uint256 tokenId) internal {
unset(pages, from, tokenId);
set(pages, to, tokenId);
}
/**
* @dev Set the ownership flag of the `tokenId` of `owner` to true.
*/
function set(Pages storage pages, address owner, uint256 tokenId) internal {
unchecked {
uint256 key = getPageKeyBy(tokenId >> 8, owner);
pages._inner[key] |= (1 << (tokenId & 0xFF));
}
}
/**
* @dev Override the ownership flag of `owner` from `from` to `from` + `count` with true.
*/
function setRange(Pages storage pages, address owner, uint256 from, uint256 count) internal {
if (count == 0)
return;
uint256 to = from + count - 1;
uint256 fromPageNo = from >> 8;
uint256 toPageNo = to >> 8;
unchecked {
if (fromPageNo != toPageNo)
{
uint256 fromPage = getPageKeyBy(fromPageNo, owner);
uint256 toPage = getPageKeyBy(toPageNo, owner);
uint256 i = fromPage;
do {
uint256 mask = type(uint256).max;
if (i == toPage)
mask >>= 0xFF - (to & 0xFF);
if (i == fromPage)
mask -= (1 << (from & 0xFF)) - 1;
pages._inner[i] |= mask;
++i;
} while (i <= toPage);
}
else{
uint256 mask = type(uint256).max;
mask >>= 0xFF - (to & 0xFF);
mask -= (1 << (from & 0xFF)) - 1;
pages._inner[getPageKeyBy(fromPageNo, owner)] |= mask;
}
}
}
/**
* @dev Set the ownership flag of the `tokenId` of `owner` to false.
*/
function unset(Pages storage pages, address owner, uint256 tokenId) internal {
unchecked {
uint256 key = getPageKeyBy(tokenId >> 8, owner);
pages._inner[key] &= ~(1 << (tokenId & 0xFF));
}
}
/**
* @dev Override the ownership flag of `owner` from `from` to `from` + `count` with false.
*/
function unsetRange(Pages storage pages, address owner, uint256 from, uint256 count) internal {
if (count == 0)
return;
uint256 to = from + count - 1;
uint256 fromPageNo = from >> 8;
uint256 toPageNo = to >> 8;
unchecked {
if (fromPageNo != toPageNo)
{
uint256 fromPage = getPageKeyBy(fromPageNo, owner);
uint256 toPage = getPageKeyBy(toPageNo, owner);
uint256 i = fromPage;
do {
uint256 mask = type(uint256).max;
if (i == toPage)
mask >>= 0xFF - (to & 0xFF);
if (i == fromPage)
mask -= (1 << (from & 0xFF)) - 1;
pages._inner[i] &= ~mask;
++i;
} while (i <= toPage);
}
else{
uint256 mask = type(uint256).max;
mask >>= 0xFF - (to & 0xFF);
mask -= (1 << (from & 0xFF)) - 1;
pages._inner[getPageKeyBy(fromPageNo, owner)] &= ~mask;
}
}
}
}
Owners.sol 82 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for owner list using delayed initialization mechanism.
*/
library Owners {
struct AddressSet {
mapping(uint256 => uint256) _inner;
}
/**
* @dev Returns the owner of `tokenId`.
*/
function ownerOf(AddressSet storage set, uint256 tokenId) internal view returns (address) {
unchecked{
uint256 i = tokenId;
do {
(address o, uint256 c) = unpack(set._inner[i]);
if (o != address(0) && i + c > tokenId){
return o;
}
--i;
} while (i != type(uint256).max);
return address(0);
}
}
/**
* @dev Set `from` to `from + count` as tokens owned by the `owner`.
*/
function mint(AddressSet storage set, address owner, uint256 from, uint256 count) internal {
set._inner[from] = pack(owner, count);
}
/**
* @dev Change the owner of `tokenId` to `owner`.
*/
function overwrite(AddressSet storage set, uint256 tokenId, address owner) internal {
(address o, uint256 c) = unpack(set._inner[tokenId]);
set._inner[tokenId] = pack(owner, 1);
if (o == address(0) || c <= 1)
return;
uint256 nextTokenId = tokenId + 1;
if (unpackAddress(set._inner[nextTokenId]) == address(0))
set._inner[nextTokenId] = pack(o, c - 1);
}
/**
* @dev Returns the value of `owner` and `count` packed into a uint256 value.
*/
function pack(address owner, uint256 count) private pure returns (uint256){
require(type(uint32).max >= count, "ERC721BO Owners: count must be less than 2^32");
// Unchecked because bitwise operations only.
unchecked {
return (uint256(uint160(owner)) << 32) | count;
}
}
/**
* @dev Returns `owner` and `count` from `packed`.
*/
function unpack(uint256 packed) private pure returns (address owner, uint256 count){
// Unchecked because bitwise operations only.
unchecked {
owner = address(uint160(packed >> 32));
count = packed & type(uint32).max;
}
}
/**
* @dev Returns owner address from `packed`.
*/
function unpackAddress(uint256 packed) private pure returns (address){
// Unchecked because bitwise operations only.
unchecked {
return address(uint160(packed >> 32) & type(uint160).max);
}
}
}
Counter.sol 38 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for counter with initial value of non zero.
*/
library Counter {
struct Minted {
uint256 _inner;
}
/**
* @dev Save `type(uint256).max` to save on gas costs for the first mint.
* Zero to non-zero gas costs are less than zero to non-zero.
*/
function initialize(Minted storage minted) internal {
minted._inner = type(uint256).max;
}
/**
* @dev Add `count` to the internal value.
*/
function increment(Minted storage minted, uint256 count) internal {
require(count > 0, "Counter: count must be greater than 0");
uint256 t = minted._inner;
uint256 incremented = t == type(uint256).max ? count : t + count;
require(incremented != type(uint256).max, "Counter: overflow");
minted._inner = incremented;
}
/**
* @dev Returns the internal value.
*/
function current(Minted storage minted) internal view returns (uint256) {
uint256 t = minted._inner;
return t == type(uint256).max ? 0 : t;
}
}
ITokenUriProvider.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ITokenUriProvider {
function maxSupply() external view returns (uint256);
function startId() external view returns (uint256);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
ERC721BO.sol 775 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./IERC721BO.sol";
import "./Bits.sol";
import "./Assets.sol";
import "./Owners.sol";
import "./Counter.sol";
abstract contract ERC721BO is Context, IERC721BO {
using Address for address;
using Strings for uint256;
using Bits for uint256;
using Assets for Assets.Pages;
using Owners for Owners.AddressSet;
using Counter for Counter.Minted;
uint256 private constant DEFAULT_MAX_TOKEN_COUNT = 1 << 16;
//Burned tokens are stored as assets at address(1).
address private constant BURN_ADDRESS = address(1);
/**
* @dev Token name.
*/
string internal _name;
/**
* @dev Token symbol.
*/
string internal _symbol;
/**
* @dev Total minted tokens count.
* This counter is incremented on each token minting.
* It is used to generate new token ids.
* Initialized with `type(uint256).max` to reduce gas cost for first `SSTORE`.
*/
Counter.Minted private _totalMints;
/**
* @dev Used to store token owners.
* Store multiple owners in bulk with a lazy initialization mechanism.
*/
Owners.AddressSet private _owners;
/**
* @dev Stores the ownership flag table for each owner.
* `uint256` as one page, 256 ownerships can be stored on a single page.
*/
Assets.Pages private _assets;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @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_;
_totalMints.initialize();
}
/**
* @dev Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165 to learn more about how these ids are created.
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165) returns (bool) {
return
interfaceId == type(IERC165).interfaceId ||
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Enumerable).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId;
}
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner <= BURN_ADDRESS) revert InvalidAddress();
return _balanceOf(owner);
}
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
if (_totalMints.current() <= tokenId) revert NonexistentToken();
address owner = _owners.ownerOf(tokenId);
if (owner <= BURN_ADDRESS) revert NonexistentToken();
return owner;
}
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert NonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing tokenURI. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @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 of ERC721.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721BO.ownerOf(tokenId);
if (to == owner)
revert CallerIsNotOwnerNorApproved();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender()))
revert CallerIsNotOwnerNorApprovedForAll();
_approve(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert NonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call transferFrom or safeTransferFrom for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an `ApprovalForAll` event of ERC721.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See setApprovalForAll
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use safeTransferFrom whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either approve or setApprovalForAll.
*
* Emits an `Transfer` event of ERC721.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
if (!_isApprovedOrOwner(_msgSender(), tokenId)) revert CallerIsNotOwnerNorApproved();
_transfer(from, to, tokenId);
}
/**
* @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 an `Transfer` event of ERC721.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either approve or setApprovalForAll.
* - If `to` refers to a smart contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer.
*
* Emits an `Transfer` event of ERC721.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
if (!_isApprovedOrOwner(_msgSender(), tokenId)) revert CallerIsNotOwnerNorApproved();
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() public override view returns (uint256){
return totalMinted() - totalBurnt();
}
/**
* @dev Returns the total amount of burnt token by the contract.
*/
function totalBurnt() public virtual view returns (uint256){
return _balanceOf(BURN_ADDRESS);
}
/**
* @dev Returns the total amount of minted token by the contract.
*/
function totalMinted() public virtual view returns (uint256){
return _totalMints.current();
}
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with balanceOf to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public virtual override view returns (uint256){
uint256 pageCount = _totalMints.current() >> 8;
uint256 total = 0;
uint256 i = 0;
do {
unchecked {
uint256 page = _assets.page(owner, i);
if (page == 0)
{
++i;
continue;
}
uint256 count = page.popCount();
if (total + count > index)
return page.indexOf(index - total) + (i << 8);
total += count;
++i;
}
} while (i <= pageCount);
revert IndexOutOfRange();
}
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with totalSupply to enumerate all tokens.
*/
function tokenByIndex(uint256 index) public virtual override view returns (uint256){
uint256 totalMints = _totalMints.current();
uint256 pageCount = totalMints >> 8;
uint256 i = 0;
uint256 popTotal = 0;
uint256 tokenId = type(uint256).max;
do {
unchecked {
uint256 page = ~_assets.page(BURN_ADDRESS, i);
if (page == 0)
{
++i;
continue;
}
uint256 count = page.popCount();
if (popTotal + count > index)
{
tokenId = page.indexOf(index - popTotal) + (i << 8);
break;
}
popTotal += count;
++i;
}
} while (i <= pageCount);
if (tokenId >= totalMints)
revert IndexOutOfRange();
return tokenId;
}
/**
* @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.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to safeTransferFrom, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement IERC721Receiver.onERC721Received, which is called upon a safe transfer.
*
* Emits an `Transfer` event of ERC721.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
if (!_checkOnERC721Received(from, to, tokenId, _data)) revert TransferToNonERC721ReceiverImplementer();
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via approve or setApprovalForAll.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _totalMints.current() > tokenId && !_assets.exists(BURN_ADDRESS, tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
if (!_exists(tokenId)) revert NonexistentToken();
if (_assets.exists(spender, tokenId))
return true;
address owner = ERC721BO.ownerOf(tokenId);
// Direct reference to `_tokenApprovals` as it passes `_exists(tokenId)`.
return (isApprovedForAll(owner, spender) || _tokenApprovals[tokenId] == spender);
}
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, "");
}
/**
* @dev Same as `_safeMint`, with an additional `data` parameter which is
* forwarded in IERC721Receiver.onERC721Received to contract recipients.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
uint256 start = _totalMints.current();
_mint(to, start, quantity);
if (!to.isContract())
return;
// Implemented with reference to ERC721A
// The possibility of overflow is unrealistic based on the `start + quantity` validation in `_mint`.
unchecked {
uint256 end = start + quantity;
uint256 index = start;
do {
if (!_checkOnERC721Received(address(0), to, index, _data))
revert TransferToNonERC721ReceiverImplementer();
++index;
} while (index <= end);
// Reentrancy protection.
if (start + quantity != end) revert();
}
}
/**
* @dev Safely re-mints `tokenId` and transfers it to `to`.
*
* 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 an `Transfer` event of ERC721.
*/
function _safeReMint(address to, uint256 tokenId) internal virtual {
_safeReMint(to, tokenId, "");
}
/**
* @dev Same as `_safeReMint`, with an additional `data` parameter which is
* forwarded in IERC721Receiver.onERC721Received to contract recipients.
*/
function _safeReMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_remint(to, tokenId);
if (!_checkOnERC721Received(address(0), to, tokenId, _data))
revert TransferToNonERC721ReceiverImplementer();
}
/**
* @dev Batch mints `count` tokens and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use _safeMint whenever possible
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` mints count.
*
* Emits an `Transfer` event of ERC721.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 start = _totalMints.current();
_mint(to, start, quantity);
}
/**
* @dev Batch mints `start` to `count` tokens and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use _safeMint whenever possible
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `start` number to start mints.
* - `quantity` mints count.
*
* Emits an `Transfer` event of ERC721.
*/
function _mint(address to, uint256 start, uint256 quantity) internal virtual {
if (to <= BURN_ADDRESS)
revert InvalidAddress();
// Cannot mint more than a defined number of mints
if (start + quantity > _getMaxTokenCount())
revert ExceededMaxOfMint();
_beforeTokenMint(address(0), to, start, quantity);
_assets.setRange(to, start, quantity);
_owners.mint(to, start, quantity);
_totalMints.increment(quantity);
// Unchecked as it is emit only.
unchecked {
uint256 i = 0;
do {
emit Transfer(address(0), to, start + i);
++i;
} while (i < quantity);
}
_afterTokenMint(address(0), to, start, quantity);
}
/**
* @dev Re-mints `tokenId` and transfers it to `to`.
* The approval is cleared when the token is burned.
*
* WARNING: Usage of this method is discouraged, use _safeReMint whenever possible
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` must not exist and burnt.
*
* Emits an `Transfer` event of ERC721.
*/
function _remint(address to, uint256 tokenId) internal virtual {
if (to <= BURN_ADDRESS)
revert InvalidAddress();
// Burned tokens become the property of `BURN_ADDRESS`.
if (!_assets.exists(BURN_ADDRESS, tokenId))
revert TokenAlreadyMinted();
_beforeTokenTransfer(address(0), to, tokenId);
_assets.transfer(BURN_ADDRESS, to, tokenId);
_owners.overwrite(tokenId, to);
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits an `Transfer` event of ERC721.
*/
function _burn(uint256 tokenId) internal virtual {
if(!_exists(tokenId))
revert NonexistentToken();
address owner = ERC721BO.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_clearApprove(owner, tokenId);
// Burned tokens are stored in the `BURN_ADDRESS` asset.
_assets.transfer(owner, BURN_ADDRESS, tokenId);
_owners.overwrite(tokenId, BURN_ADDRESS);
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to transferFrom, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits an `Transfer` event of ERC721.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
if (!_assets.exists(from, tokenId))
revert TransferFromIncorrectOwner();
if (to <= BURN_ADDRESS)
revert InvalidAddress();
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_clearApprove(from, tokenId);
_assets.transfer(from, to, tokenId);
_owners.overwrite(tokenId, to);
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approval for `tokenId` from `from` to zero address.
*
* Emits an `Approval` event of ERC721.
*/
function _clearApprove(address from, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = address(0);
emit Approval(from, address(0), tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId` of `owner`
*
* Emits an `Approval` event of ERC721.
*/
function _approve(address owner, address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an `ApprovalForAll` event of ERC721.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
if (owner == operator) revert ApproveToCaller();
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Returns the number of tokens in the `owner`'s account.
* Note that no validation of the specified address is performed.
*/
function _balanceOf(address owner) internal view returns (uint256) {
uint256 pageCount = _totalMints.current() >> 8;
uint256 balance = 0;
// Counting Owner Flags.
// The number of pages is calculated from the total mints.
// Therefore, the max value of `balance` is `page count * 256` and it is impractical to overflow.
unchecked {
uint256 i = 0;
do {
balance += _assets.page(owner, i).popCount();
++i;
} while (i <= pageCount);
}
return balance;
}
/**
* @dev Returns the maximum of tokens that can be stored by the contract.
*/
function _getMaxTokenCount() internal pure returns (uint256) {
return DEFAULT_MAX_TOKEN_COUNT;
}
/**
* @dev Internal function to invoke IERC721Receiver.onERC721Received on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _beforeTokenMint(
address from,
address to,
uint256 start,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
function _afterTokenMint(
address from,
address to,
uint256 start,
uint256 quantity
) internal virtual {}
}
IERC721BO.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface IERC721BO is IERC165, IERC721Enumerable, IERC721Metadata{
error NonexistentToken();
error InvalidAddress();
error CallerIsNotOwnerNorApproved();
error CallerIsNotOwnerNorApprovedForAll();
error IndexOutOfRange();
error TransferToNonERC721ReceiverImplementer();
error ExceededMaxOfMint();
error TokenAlreadyMinted();
error TransferFromIncorrectOwner();
error ApproveToCaller();
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
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), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @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) {
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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @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 up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (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; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 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.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
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 (rounding == Rounding.Up && 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 down.
*
* 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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* 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 + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* 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 10, 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 + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
IERC2981.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IERC721.sol 145 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* 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 caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
ERC2981.sol 111 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)
pragma solidity ^0.8.0;
import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
*
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
* specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
*
* Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
* fee is specified in basis points by default.
*
* IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
* https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
* voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
*
* _Available since v4.5._
*/
abstract contract ERC2981 is IERC2981, ERC165 {
struct RoyaltyInfo {
address receiver;
uint96 royaltyFraction;
}
RoyaltyInfo private _defaultRoyaltyInfo;
mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @inheritdoc IERC2981
*/
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();
return (royalty.receiver, royaltyAmount);
}
/**
* @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
* fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
* override.
*/
function _feeDenominator() internal pure virtual returns (uint96) {
return 10000;
}
/**
* @dev Sets the royalty information that all ids in this contract will default to.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: invalid receiver");
_defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Removes default royalty information.
*/
function _deleteDefaultRoyalty() internal virtual {
delete _defaultRoyaltyInfo;
}
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/
function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
}
/**
* @dev Resets royalty information for the token id back to the global default.
*/
function _resetTokenRoyalty(uint256 tokenId) internal virtual {
delete _tokenRoyaltyInfo[tokenId];
}
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
ERC721BONonburnable.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721BO.sol";
abstract contract ERC721BONonburnable is ERC721BO {
function totalBurnt() public virtual override view returns (uint256){
return 0;
}
function tokenByIndex(uint256 index) public virtual override view returns (uint256){
if (index >= totalSupply()) revert IndexOutOfRange();
return index;
}
function _exists(uint256 tokenId) internal view virtual override returns (bool) {
return totalSupply() > tokenId;
}
function _remint(address, uint256) internal virtual override {
revert("Not supported");
}
function _burn(uint256) internal virtual override {
revert("Not supported");
}
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
EnumerableSet.sol 378 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
CHANGE_ROYALTY_ROLE 0x931868fe → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MINTER_ROLE 0xd5391393 → bytes32
OWNER_ADMIN_ROLE 0xd1fdeaa7 → bytes32
PROVIDER_ADMIN_ROLE 0x1837fc64 → bytes32
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalBurnt 0x966ff650 → uint256
totalMinted 0xa2309ff8 → uint256
totalSupply 0x18160ddd → uint256
uriProvider 0x5ad44842 → address
uriProviderCount 0x0e05010c → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
addUriProvider 0x59506d09
address provider
approve 0x095ea7b3
address to
uint256 tokenId
changeOwnership 0x2af4c31e
address newOwner
grantRole 0x2f2ff15d
bytes32 role
address account
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
safeMint 0x8832e6e3
address to
uint256 count
bytes data
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setDefaultRoyalty 0xda216e0c
uint96 feeNumerator
address payee
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
Recent Transactions
No transactions found for this address