Address Contract Partially Verified
Address
0xE3d0fe9B7E0B951663267a3Ed1e6577f6f79757e
Balance
0 ETH
Nonce
1
Code Size
9982 bytes
Creator
0x8914496d...F1d2 at tx 0x5542398b...1a6e69
Indexed Transactions
0
Contract Bytecode
9982 bytes
0x60806040526004361061016e5760003560e01c80638a0b0360116100d6578063dd0d65401161007f578063f242432a11610059578063f242432a1461049f578063f2fde38b146104bf578063f7d97577146104df57600080fd5b8063dd0d6540146103f9578063e757223014610429578063e985e9c51461045657600080fd5b806395d89b41116100b057806395d89b411461038a5780639a57829a146103b9578063a22cb465146103d957600080fd5b80638a0b0360146103125780638da5cb5b1461033257806392ab723e1461035a57600080fd5b80632eb2c2d611610138578063641ce14011610112578063641ce140146102ca5780636686f3f6146102dd578063715018a6146102fd57600080fd5b80632eb2c2d61461025d5780634e1273f41461027d5780635451fea2146102aa57600080fd5b8062f714ce14610173578062fdd58e1461019557806301ffc9a7146101c857806306fdde03146101f85780630e89341c1461023d575b600080fd5b34801561017f57600080fd5b5061019361018e366004611c75565b6104ff565b005b3480156101a157600080fd5b506101b56101b0366004611ca5565b6105b3565b6040519081526020015b60405180910390f35b3480156101d457600080fd5b506101e86101e3366004611ce7565b610645565b60405190151581526020016101bf565b34801561020457600080fd5b506102306040518060400160405280600c81526020016b47656e6572616c436172647360a01b81525081565b6040516101bf9190611d58565b34801561024957600080fd5b50610230610258366004611d6b565b610697565b34801561026957600080fd5b50610193610278366004611eda565b61073c565b34801561028957600080fd5b5061029d610298366004611f88565b6107d3565b6040516101bf9190612090565b3480156102b657600080fd5b506101936102c53660046120a3565b6108fd565b6101936102d836600461215a565b610aac565b3480156102e957600080fd5b506101936102f83660046121b6565b610e99565b34801561030957600080fd5b50610193610ed8565b34801561031e57600080fd5b5061019361032d3660046121d8565b610f0e565b34801561033e57600080fd5b506003546040516001600160a01b0390911681526020016101bf565b34801561036657600080fd5b506101b5610375366004611d6b565b60009081526006602052604090206002015490565b34801561039657600080fd5b5061023060405180604001604052806003815260200162474d4360e81b81525081565b3480156103c557600080fd5b506101936103d4366004612239565b6110ba565b3480156103e557600080fd5b506101936103f4366004612254565b6110f7565b34801561040557600080fd5b506101b5610414366004611d6b565b60009081526006602052604090206001015490565b34801561043557600080fd5b506101b5610444366004611d6b565b60009081526006602052604090205490565b34801561046257600080fd5b506101e8610471366004612289565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b3480156104ab57600080fd5b506101936104ba3660046122b7565b6111ce565b3480156104cb57600080fd5b506101936104da366004612320565b611255565b3480156104eb57600080fd5b506101936104fa3660046121b6565b6112f0565b6003546001600160a01b031633146105325760405162461bcd60e51b81526004016105299061233d565b60405180910390fd5b814710156105825760405162461bcd60e51b815260206004820152601b60248201527f47656e6572616c3a206e6f7420656e6f7567682062616c616e636500000000006044820152606401610529565b8161058b574791505b6001600160a01b03811661059c5750335b6105af6001600160a01b0382168361132c565b5050565b60006001600160a01b03831661061f5760405162461bcd60e51b815260206004820152602b60248201527f455243313135353a2062616c616e636520717565727920666f7220746865207a60448201526a65726f206164647265737360a81b6064820152608401610529565b506000908152602081815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b03198216636cdb3d1360e11b148061067657506001600160e01b031982166303a24d0760e21b145b8061069157506301ffc9a760e01b6001600160e01b03198316145b92915050565b60008181526006602052604090206004018054606091906106b790612372565b80601f01602080910402602001604051908101604052809291908181526020018280546106e390612372565b80156107305780601f1061070557610100808354040283529160200191610730565b820191906000526020600020905b81548152906001019060200180831161071357829003601f168201915b50505050509050919050565b6001600160a01b03851633148061075857506107588533610471565b6107bf5760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f74206044820152711bdddb995c881b9bdc88185c1c1c9bdd995960721b6064820152608401610529565b6107cc858585858561144a565b5050505050565b606081518351146108385760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610529565b6000835167ffffffffffffffff81111561085457610854611d84565b60405190808252806020026020018201604052801561087d578160200160208202803683370190505b50905060005b84518110156108f5576108c88582815181106108a1576108a16123ad565b60200260200101518583815181106108bb576108bb6123ad565b60200260200101516105b3565b8282815181106108da576108da6123ad565b60209081029190910101526108ee816123d9565b9050610883565b509392505050565b6003546001600160a01b031633146109275760405162461bcd60e51b81526004016105299061233d565b600085815260066020526040902060020154156109865760405162461bcd60e51b815260206004820152601d60248201527f47656e6572616c3a207479706520616c726561647920646566696e65640000006044820152606401610529565b600083116109eb5760405162461bcd60e51b815260206004820152602c60248201527f47656e6572616c3a206d7573742073657420616e2061626f7665207a65726f2060448201526b746f74616c20737570706c7960a01b6064820152608401610529565b6000815111610a3c5760405162461bcd60e51b815260206004820152601760248201527f47656e6572616c3a206d757374207365742061205552490000000000000000006044820152606401610529565b6040805160a0810182528581526000602080830182815283850188815260608501888152608086018881528c865260068552969094208551815591516001830155516002820155915160038301559251805192939192610aa29260048501920190611bc7565b5050505050505050565b60026004541415610aff5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610529565b600260045560055460ff16610b565760405162461bcd60e51b815260206004820152601c60248201527f47656e6572616c3a206d696e74696e672069732064697361626c6564000000006044820152606401610529565b600083815260066020526040902060028101546001909101541080610b8a5750600083815260066020526040902060030154155b610bd65760405162461bcd60e51b815260206004820152601d60248201527f47656e6572616c3a20746f74616c20737570706c7920757365642075700000006044820152606401610529565b610be084846105b3565b158015610c1157506001600160a01b038416600090815260076020908152604080832086845290915290205460ff16155b610c2d5760405162461bcd60e51b8152600401610529906123f4565b6000610cbb838380806020026020016040519081016040528093929190818152602001838360200280828437600092018290525089815260066020908152604091829020600301549151919450610ca093503392500160609190911b6bffffffffffffffffffffffff1916815260140190565b60405160208183030381529060405280519060200120611627565b600085815260066020526040812060030154919250901580610cda5750815b60008681526006602052604090205490915015610d705760008581526006602052604090205434101580610d0b5750815b610d685760405162461bcd60e51b815260206004820152602860248201527f47656e6572616c3a20696e636f7272656374207072696365206f72206e6f7420604482015267185c1c1c9bdd995960c21b6064820152608401610529565b506001610dd3565b3415610dd35760405162461bcd60e51b815260206004820152602c60248201527f47656e6572616c3a2073656e742076616c756520666f72206e6f6e2d7061796160448201526b189b19481d1bdad95b88125160a21b6064820152608401610529565b80610e205760405162461bcd60e51b815260206004820152601d60248201527f47656e6572616c3a206e6f7420617070726f76656420746f206d696e740000006044820152606401610529565b6000858152600660205260408120600101805491610e3d836123d9565b90915550506001600160a01b03861660009081526007602090815260408083208884528252808320805460ff191660019081179091558151928301909152918152610e8c9188918891906116d6565b5050600160045550505050565b6003546001600160a01b03163314610ec35760405162461bcd60e51b81526004016105299061233d565b60009182526006602052604090912060030155565b6003546001600160a01b03163314610f025760405162461bcd60e51b81526004016105299061233d565b610f0c60006117e0565b565b6003546001600160a01b03163314610f385760405162461bcd60e51b81526004016105299061233d565b60008181526006602052604090206002810154600190910154610f5c908490612447565b10610fa95760405162461bcd60e51b815260206004820152601d60248201527f47656e6572616c3a20746f74616c20737570706c7920757365642075700000006044820152606401610529565b60005b828110156110b4576000848483818110610fc857610fc86123ad565b9050602002016020810190610fdd9190612320565b6001600160a01b038116600090815260076020908152604080832087845290915290205490915060ff1615801561101b575061101981846105b3565b155b6110375760405162461bcd60e51b8152600401610529906123f4565b6000838152600660205260408120600101805491611054836123d9565b90915550506001600160a01b03811660009081526007602090815260408083208684528252808320805460ff1916600190811790915581519283019091529181526110a39183918691906116d6565b506110ad816123d9565b9050610fac565b50505050565b6003546001600160a01b031633146110e45760405162461bcd60e51b81526004016105299061233d565b6005805460ff1916911515919091179055565b336001600160a01b03831614156111625760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610529565b3360008181526001602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6001600160a01b0385163314806111ea57506111ea8533610471565b6112485760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201526808185c1c1c9bdd995960ba1b6064820152608401610529565b6107cc858585858561183f565b6003546001600160a01b0316331461127f5760405162461bcd60e51b81526004016105299061233d565b6001600160a01b0381166112e45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610529565b6112ed816117e0565b50565b6003546001600160a01b0316331461131a5760405162461bcd60e51b81526004016105299061233d565b60009182526006602052604090912055565b8047101561137c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610529565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146113c9576040519150601f19603f3d011682016040523d82523d6000602084013e6113ce565b606091505b50509050806114455760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610529565b505050565b81518351146114ac5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b6064820152608401610529565b6001600160a01b0384166114d25760405162461bcd60e51b81526004016105299061245f565b3360005b84518110156115b95760008582815181106114f3576114f36123ad565b602002602001015190506000858381518110611511576115116123ad565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156115615760405162461bcd60e51b8152600401610529906124a4565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b1682528120805484929061159e908490612447565b92505081905550505050806115b2906123d9565b90506114d6565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516116099291906124ee565b60405180910390a461161f81878787878761195c565b505050505050565b600081815b85518110156116cb576000868281518110611649576116496123ad565b6020026020010151905080831161168b5760408051602081018590529081018290526060016040516020818303038152906040528051906020012092506116b8565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b50806116c3816123d9565b91505061162c565b509092149392505050565b6001600160a01b0384166117365760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610529565b336117508160008761174788611ac1565b6107cc88611ac1565b6000848152602081815260408083206001600160a01b038916845290915281208054859290611780908490612447565b909155505060408051858152602081018590526001600160a01b0380881692600092918516917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46107cc81600087878787611b0c565b600380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0384166118655760405162461bcd60e51b81526004016105299061245f565b3361187581878761174788611ac1565b6000848152602081815260408083206001600160a01b038a168452909152902054838110156118b65760405162461bcd60e51b8152600401610529906124a4565b6000858152602081815260408083206001600160a01b038b81168552925280832087850390559088168252812080548692906118f3908490612447565b909155505060408051868152602081018690526001600160a01b03808916928a821692918616917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611953828888888888611b0c565b50505050505050565b6001600160a01b0384163b1561161f5760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906119a0908990899088908890889060040161251c565b6020604051808303816000875af19250505080156119db575060408051601f3d908101601f191682019092526119d89181019061257a565b60015b611a91576119e7612597565b806308c379a01415611a2157506119fc6125b3565b80611a075750611a23565b8060405162461bcd60e51b81526004016105299190611d58565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560448201527f526563656976657220696d706c656d656e7465720000000000000000000000006064820152608401610529565b6001600160e01b0319811663bc197c8160e01b146119535760405162461bcd60e51b81526004016105299061263d565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110611afb57611afb6123ad565b602090810291909101015292915050565b6001600160a01b0384163b1561161f5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611b509089908990889088908890600401612685565b6020604051808303816000875af1925050508015611b8b575060408051601f3d908101601f19168201909252611b889181019061257a565b60015b611b97576119e7612597565b6001600160e01b0319811663f23a6e6160e01b146119535760405162461bcd60e51b81526004016105299061263d565b828054611bd390612372565b90600052602060002090601f016020900481019282611bf55760008555611c3b565b82601f10611c0e57805160ff1916838001178555611c3b565b82800160010185558215611c3b579182015b82811115611c3b578251825591602001919060010190611c20565b50611c47929150611c4b565b5090565b5b80821115611c475760008155600101611c4c565b6001600160a01b03811681146112ed57600080fd5b60008060408385031215611c8857600080fd5b823591506020830135611c9a81611c60565b809150509250929050565b60008060408385031215611cb857600080fd5b8235611cc381611c60565b946020939093013593505050565b6001600160e01b0319811681146112ed57600080fd5b600060208284031215611cf957600080fd5b8135611d0481611cd1565b9392505050565b6000815180845260005b81811015611d3157602081850181015186830182015201611d15565b81811115611d43576000602083870101525b50601f01601f19169290920160200192915050565b602081526000611d046020830184611d0b565b600060208284031215611d7d57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715611dc057611dc0611d84565b6040525050565b600067ffffffffffffffff821115611de157611de1611d84565b5060051b60200190565b600082601f830112611dfc57600080fd5b81356020611e0982611dc7565b604051611e168282611d9a565b83815260059390931b8501820192828101915086841115611e3657600080fd5b8286015b84811015611e515780358352918301918301611e3a565b509695505050505050565b600067ffffffffffffffff831115611e7657611e76611d84565b604051611e8d601f8501601f191660200182611d9a565b809150838152848484011115611ea257600080fd5b83836020830137600060208583010152509392505050565b600082601f830112611ecb57600080fd5b611d0483833560208501611e5c565b600080600080600060a08688031215611ef257600080fd5b8535611efd81611c60565b94506020860135611f0d81611c60565b9350604086013567ffffffffffffffff80821115611f2a57600080fd5b611f3689838a01611deb565b94506060880135915080821115611f4c57600080fd5b611f5889838a01611deb565b93506080880135915080821115611f6e57600080fd5b50611f7b88828901611eba565b9150509295509295909350565b60008060408385031215611f9b57600080fd5b823567ffffffffffffffff80821115611fb357600080fd5b818501915085601f830112611fc757600080fd5b81356020611fd482611dc7565b604051611fe18282611d9a565b83815260059390931b850182019282810191508984111561200157600080fd5b948201945b8386101561202857853561201981611c60565b82529482019490820190612006565b9650508601359250508082111561203e57600080fd5b5061204b85828601611deb565b9150509250929050565b600081518084526020808501945080840160005b8381101561208557815187529582019590820190600101612069565b509495945050505050565b602081526000611d046020830184612055565b600080600080600060a086880312156120bb57600080fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff8111156120ee57600080fd5b8601601f810188136120ff57600080fd5b611f7b88823560208401611e5c565b60008083601f84011261212057600080fd5b50813567ffffffffffffffff81111561213857600080fd5b6020830191508360208260051b850101111561215357600080fd5b9250929050565b6000806000806060858703121561217057600080fd5b843561217b81611c60565b935060208501359250604085013567ffffffffffffffff81111561219e57600080fd5b6121aa8782880161210e565b95989497509550505050565b600080604083850312156121c957600080fd5b50508035926020909101359150565b6000806000604084860312156121ed57600080fd5b833567ffffffffffffffff81111561220457600080fd5b6122108682870161210e565b909790965060209590950135949350505050565b8035801515811461223457600080fd5b919050565b60006020828403121561224b57600080fd5b611d0482612224565b6000806040838503121561226757600080fd5b823561227281611c60565b915061228060208401612224565b90509250929050565b6000806040838503121561229c57600080fd5b82356122a781611c60565b91506020830135611c9a81611c60565b600080600080600060a086880312156122cf57600080fd5b85356122da81611c60565b945060208601356122ea81611c60565b93506040860135925060608601359150608086013567ffffffffffffffff81111561231457600080fd5b611f7b88828901611eba565b60006020828403121561233257600080fd5b8135611d0481611c60565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600181811c9082168061238657607f821691505b602082108114156123a757634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156123ed576123ed6123c3565b5060010190565b60208082526033908201527f47656e6572616c3a2063616e6e6f74206f776e206d6f7265207468616e206f6e60408201527219481bd988184811d95b995c985b0810d85c99606a1b606082015260800190565b6000821982111561245a5761245a6123c3565b500190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6040815260006125016040830185612055565b82810360208401526125138185612055565b95945050505050565b60006001600160a01b03808816835280871660208401525060a0604083015261254860a0830186612055565b828103606084015261255a8186612055565b9050828103608084015261256e8185611d0b565b98975050505050505050565b60006020828403121561258c57600080fd5b8151611d0481611cd1565b600060033d11156125b05760046000803e5060005160e01c5b90565b600060443d10156125c15790565b6040516003193d81016004833e81513d67ffffffffffffffff81602484011181841117156125f157505050505090565b82850191508151818111156126095750505050505090565b843d87010160208285010111156126235750505050505090565b61263260208286010187611d9a565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a060808301526126bd60a0830184611d0b565b97965050505050505056fea2646970667358221220a33c282823ab180e4ef4d4a5493f101ddae76605fe89dda1780416c59f93b56464736f6c634300080b0033
Verified Source Code Partial Match
Compiler: v0.8.11+commit.d7f03943
EVM: london
Optimization: Yes (300 runs)
GeneralCards.sol 1853 lines
// SPDX-License-Identifier: MIT
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;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length)
internal
pure
returns (string memory)
{
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(
data
);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data)
internal
view
returns (bytes memory)
{
return
functionStaticCall(
target,
data,
"Address: low-level static call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return
functionDelegateCall(
target,
data,
"Address: low-level delegate call failed"
);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
/**
* @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);
}
/**
* @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;
}
}
/**
* @dev _Available since v3.1._
*/
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId)
external
view
returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator)
external
view
returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(
address indexed operator,
address indexed from,
address indexed to,
uint256 id,
uint256 value
);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(
address indexed account,
address indexed operator,
bool approved
);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id)
external
view
returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator)
external
view
returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
library StringUtils {
/// @dev Does a byte-by-byte lexicographical comparison of two strings.
/// @return a negative number if `_a` is smaller, zero if they are equal
/// and a positive numbe if `_b` is smaller.
function compare(string memory _a, string memory _b)
internal
pure
returns (int256)
{
bytes memory a = bytes(_a);
bytes memory b = bytes(_b);
uint256 minLength = a.length;
if (b.length < minLength) minLength = b.length;
//@todo unroll the loop into increments of 32 and do full 32 byte comparisons
for (uint256 i = 0; i < minLength; i++)
if (a[i] < b[i]) return -1;
else if (a[i] > b[i]) return 1;
if (a.length < b.length) return -1;
else if (a.length > b.length) return 1;
else return 0;
}
/// @dev Compares two strings and returns true iff they are equal.
function equal(string memory _a, string memory _b)
internal
pure
returns (bool)
{
return compare(_a, _b) == 0;
}
/// @dev Finds the index of the first occurrence of _needle in _haystack
function indexOf(string memory _haystack, string memory _needle)
internal
pure
returns (int256)
{
bytes memory h = bytes(_haystack);
bytes memory n = bytes(_needle);
if (h.length < 1 || n.length < 1 || (n.length > h.length)) return -1;
else if (h.length > (2**128 - 1))
// since we have to be able to return -1 (if the char isn't found or input error), this function must return an "int" type with a max length of (2^128 - 1)
return -1;
else {
uint256 subindex = 0;
for (uint256 i = 0; i < h.length; i++) {
if (h[i] == n[0]) // found the first char of b
{
subindex = 1;
while (
subindex < n.length &&
(i + subindex) < h.length &&
h[i + subindex] == n[subindex] // search until the chars don't match or until we reach the end of a or b
) {
subindex++;
}
if (subindex == n.length) return int256(i);
}
}
return -1;
}
}
}
contract Whitelistable {
using Address for address;
using StringUtils for string;
enum Specification {
NONE,
ERC721,
ERC20
}
struct WhitelistCheck {
Specification specification;
address tokenAddress;
}
mapping(uint256 => WhitelistCheck) private whitelist;
function setWhitelistCheck(
string memory specification,
address tokenAddress,
uint256 _id
) public virtual {
require(tokenAddress.isContract(), "Token address must be a contract");
whitelist[_id].specification = specificationByValue(specification);
whitelist[_id].tokenAddress = tokenAddress;
}
function isWhitelisted(address wallet, uint256 _id)
internal
view
returns (bool)
{
if (whitelist[_id].specification == Specification.ERC721) {
try IERC721(whitelist[_id].tokenAddress).balanceOf(wallet) {
return
IERC721(whitelist[_id].tokenAddress).balanceOf(wallet) > 0;
} catch Error(string memory) {
return false;
}
} else if (whitelist[_id].specification == Specification.ERC20) {
try IERC20(whitelist[_id].tokenAddress).balanceOf(wallet) {
return
IERC20(whitelist[_id].tokenAddress).balanceOf(wallet) > 0;
} catch Error(string memory) {
return false;
}
} else {
return false;
}
}
function specificationByValue(string memory value)
private
pure
returns (Specification)
{
if (value.equal("ERC721") || value.equal("ERC-721")) {
return Specification.ERC721;
} else if (value.equal("ERC20") || value.equal("ERC-20")) {
return Specification.ERC20;
} else {
revert("Unknown specification");
}
}
}
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*
* _Available since v3.1._
*/
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
using Address for address;
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) internal balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) internal operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, IERC165)
returns (bool)
{
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256) public view virtual override returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id)
public
view
virtual
override
returns (uint256)
{
require(
account != address(0),
"ERC1155: balance query for the zero address"
);
return balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
public
view
virtual
override
returns (uint256[] memory)
{
require(
accounts.length == ids.length,
"ERC1155: accounts and ids length mismatch"
);
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts[i], ids[i]);
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved)
public
virtual
override
{
require(
_msgSender() != operator,
"ERC1155: setting approval status for self"
);
operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator)
public
view
virtual
override
returns (bool)
{
return operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(
operator,
from,
to,
_asSingletonArray(id),
_asSingletonArray(amount),
data
);
uint256 fromBalance = balances[id][from];
require(
fromBalance >= amount,
"ERC1155: insufficient balance for transfer"
);
unchecked {
balances[id][from] = fromBalance - amount;
}
balances[id][to] += amount;
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(
ids.length == amounts.length,
"ERC1155: ids and amounts length mismatch"
);
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 fromBalance = balances[id][from];
require(
fromBalance >= amount,
"ERC1155: insufficient balance for transfer"
);
unchecked {
balances[id][from] = fromBalance - amount;
}
balances[id][to] += amount;
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(
operator,
from,
to,
ids,
amounts,
data
);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the amounts in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `account`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(account != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
_beforeTokenTransfer(
operator,
address(0),
account,
_asSingletonArray(id),
_asSingletonArray(amount),
data
);
balances[id][account] += amount;
emit TransferSingle(operator, address(0), account, id, amount);
_doSafeTransferAcceptanceCheck(
operator,
address(0),
account,
id,
amount,
data
);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
require(
ids.length == amounts.length,
"ERC1155: ids and amounts length mismatch"
);
address operator = _msgSender();
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
for (uint256 i = 0; i < ids.length; i++) {
balances[ids[i]][to] += amounts[i];
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(
operator,
address(0),
to,
ids,
amounts,
data
);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `account`
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address account,
uint256 id,
uint256 amount
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
_beforeTokenTransfer(
operator,
account,
address(0),
_asSingletonArray(id),
_asSingletonArray(amount),
""
);
uint256 accountBalance = balances[id][account];
require(
accountBalance >= amount,
"ERC1155: burn amount exceeds balance"
);
unchecked {
balances[id][account] = accountBalance - amount;
}
emit TransferSingle(operator, account, address(0), id, amount);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address account,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(account != address(0), "ERC1155: burn from the zero address");
require(
ids.length == amounts.length,
"ERC1155: ids and amounts length mismatch"
);
address operator = _msgSender();
_beforeTokenTransfer(operator, account, address(0), ids, amounts, "");
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 accountBalance = balances[id][account];
require(
accountBalance >= am...
// [truncated — 59958 bytes total]
Read Contract
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
getPrice 0xe7572230 → uint256
getTotalSupply 0x92ab723e → uint256
getUsedSupply 0xdd0d6540 → uint256
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
uri 0x0e89341c → string
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
createType 0x5451fea2
uint256 _id
uint256 _price
uint256 _totalSupply
bytes32 _allowListMerkleRoot
string _uri
mint 0x641ce140
address to
uint256 id
bytes32[] merkleProof
mintToMany 0x8a0b0360
address[] _to
uint256 _id
renounceOwnership 0x715018a6
No parameters
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 id
uint256 amount
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setCanMint 0x9a57829a
bool _canMint
setMintApprovals 0x6686f3f6
uint256 id
bytes32 merkleRoot
setPrice 0xf7d97577
uint256 id
uint256 price
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x00f714ce
uint256 amount
address to
Recent Transactions
No transactions found for this address