Address Contract Verified
Address
0xd833a1990656c5c282b809cB82500455a8e6a205
Balance
0 ETH
Nonce
1
Code Size
10738 bytes
Creator
0x5a86cF98...29EA at tx 0x13ca5f5d...4db69b
Indexed Transactions
0
Contract Bytecode
10738 bytes
0x608060405234801561001057600080fd5b50600436106101575760003560e01c80638da5cb5b116100c3578063e436692e1161007c578063e436692e1461031d578063e728782b14610345578063e985e9c514610358578063f242432a14610394578063f2fde38b146103a7578063f5298aca146103ba57600080fd5b80638da5cb5b1461029357806395d89b41146102ae578063a22cb465146102b6578063acce7860146102c9578063bd85b039146102ea578063dc1ea7921461030a57600080fd5b80632eb2c2d6116101155780632eb2c2d6146101f55780634e1273f4146102085780634f558e79146102285780636b20c4541461024a578063715018a61461025d578063734f851e1461026557600080fd5b8062fdd58e1461015c57806301ffc9a71461018257806306fdde03146101a55780630e89341c146101ba5780632b8bd8b1146101cd5780632e544cda146101e2575b600080fd5b61016f61016a366004611ca0565b6103cd565b6040519081526020015b60405180910390f35b610195610190366004611ce0565b610466565b6040519015158152602001610179565b6101ad6104b6565b6040516101799190611d4a565b6101ad6101c8366004611d5d565b610548565b6101e06101db366004611d5d565b6105ed565b005b6101e06101f0366004611d5d565b6106d5565b6101e0610203366004611eee565b6107ae565b61021b610216366004611f97565b6107fa565b604051610179919061209c565b610195610236366004611d5d565b600090815260046020526040902054151590565b6101e06102583660046120af565b610923565b6101e061096b565b610195610273366004611d5d565b60009081526007602052604090205460ff61010090910416151560011490565b6003546040516001600160a01b039091168152602001610179565b6101ad61097f565b6101e06102c4366004612122565b61098e565b6102dc6102d736600461215e565b61099d565b604051610179929190612248565b61016f6102f8366004611d5d565b60009081526004602052604090205490565b6101e061031836600461215e565b610c88565b61019561032b366004611d5d565b60009081526007602052604090205460ff16151560011490565b6101e061035336600461228c565b610dde565b6101956103663660046122dc565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6101e06103a236600461230f565b610f36565b6101e06103b5366004612373565b610f7b565b6101e06103c836600461238e565b610ff4565b60006001600160a01b03831661043d5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061049757506001600160e01b031982166303a24d0760e21b145b8061046057506301ffc9a760e01b6001600160e01b0319831614610460565b6060600580546104c5906123c1565b80601f01602080910402602001604051908101604052809291908181526020018280546104f1906123c1565b801561053e5780601f106105135761010080835404028352916020019161053e565b820191906000526020600020905b81548152906001019060200180831161052157829003601f168201915b5050505050905090565b6000818152600760205260409020600101805460609190610568906123c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610594906123c1565b80156105e15780601f106105b6576101008083540402835291602001916105e1565b820191906000526020600020905b8154815290600101906020018083116105c457829003601f168201915b50505050509050919050565b6105f5611037565b6106138160009081526007602052604090205460ff16151560011490565b1561067f5760405162461bcd60e51b815260206004820152603660248201527f546f6b656e206d696e74696e6720616c7265616479206c6f636b65642c20796f60448201527575207472796e61206275726e20455448206672656e3f60501b6064820152608401610434565b60008181526007602052604090819020805460ff19166001179055517fb19a39e336e85c75e1f0853372bf73017d3df86aaa82395502ce825f8838d642906106ca9083815260200190565b60405180910390a150565b6106dd611037565b600081815260076020526040902054600161010090910460ff161515036107615760405162461bcd60e51b815260206004820152603260248201527f546f6b656e2055524920616c7265616479206c6f636b65642c20796f75207472604482015271796e61206275726e20455448206672656e3f60701b6064820152608401610434565b60008181526007602052604090819020805461ff001916610100179055517f8e470ad5f77e27b10f85d07b6cbcc7ff160dbfba3487c1b3c17aac89fcd2d7eb906106ca9083815260200190565b6001600160a01b0385163314806107ca57506107ca8533610366565b6107e65760405162461bcd60e51b8152600401610434906123fb565b6107f38585858585611091565b5050505050565b6060815183511461085f5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b6064820152608401610434565b600083516001600160401b0381111561087a5761087a611d76565b6040519080825280602002602001820160405280156108a3578160200160208202803683370190505b50905060005b845181101561091b576108ee8582815181106108c7576108c7612449565b60200260200101518583815181106108e1576108e1612449565b60200260200101516103cd565b82828151811061090057610900612449565b602090810291909101015261091481612475565b90506108a9565b509392505050565b6001600160a01b03831633148061093f575061093f8333610366565b61095b5760405162461bcd60e51b8152600401610434906123fb565b61096683838361123b565b505050565b610973611037565b61097d60006113d8565b565b6060600680546104c5906123c1565b61099933838361142a565b5050565b60006109a7611c65565b6109c58460009081526007602052604090205460ff16151560011490565b156109e25760405162461bcd60e51b81526004016104349061248e565b6109eb84610548565b51600003610a0b5760405162461bcd60e51b8152600401610434906124d4565b600191506000805b8451811015610c7f57610a55858281518110610a3157610a31612449565b6020026020010151600001516001600160a01b03166001600160a01b03163b151590565b15610c6f57848181518110610a6c57610a6c612449565b6020026020010151600001516001600160a01b031663f23a6e61303089898681518110610a9b57610a9b612449565b60209081029190910181015101516040516001600160e01b031960e087901b1681526001600160a01b03948516600482015293909216602484015260448301526001600160601b0316606482015260a06084820152600060a482015260c4016020604051808303816000875af1925050508015610b35575060408051601f3d908101601f19168201909252610b3291810190612523565b60015b610c0757610b41612540565b806308c379a003610bb35750610b5561255c565b80610b605750610bb5565b60009450858281518110610b7657610b76612449565b6020026020010151600001518484600a8110610b9457610b94612449565b6001600160a01b03909216602092909202015250600190910190610c6f565b505b60009350848181518110610bcb57610bcb612449565b6020026020010151600001518383600a8110610be957610be9612449565b6001600160a01b039092166020929092020152600190910190610c6f565b6001600160e01b0319811663f23a6e6160e01b14610c6d5760009450858281518110610c3557610c35612449565b6020026020010151600001518484600a8110610c5357610c53612449565b6001600160a01b0390921660209290920201526001909201915b505b600a8214610c7f57600101610a13565b50509250929050565b610c90611037565b610cae8260009081526007602052604090205460ff16151560011490565b15610ccb5760405162461bcd60e51b81526004016104349061248e565b610cd482610548565b51600003610cf45760405162461bcd60e51b8152600401610434906124d4565b600082815260046020526040812054905b8251811015610d7457610d6c838281518110610d2357610d23612449565b60200260200101516000015185858481518110610d4257610d42612449565b6020026020010151602001516001600160601b03166040518060200160405280600081525061150a565b600101610d05565b507f38649a6ce477d384bb7d9dc182476f54898a49cd6c7e639f9a4f449b1b395f3183835183610db08760009081526004602052604090205490565b610dba91906125e5565b604080519384526020840192909252908201526060015b60405180910390a1505050565b610de6611037565b600082815260076020526040902054600161010090910460ff16151503610e475760405162461bcd60e51b81526020600482015260156024820152742a37b5b2b7102aa924903637b1b5b2b210333932b760591b6044820152606401610434565b60008281526007602052604081206001018054610e63906123c1565b80601f0160208091040260200160405190810160405280929190818152602001828054610e8f906123c1565b8015610edc5780601f10610eb157610100808354040283529160200191610edc565b820191906000526020600020905b815481529060010190602001808311610ebf57829003601f168201915b50505060008681526007602052604090209293505060019091019050610f02838261263e565b507f31b096c6ff64a74a686605caa11c1eb1e36d3ab8079b1e117b5074d70d63ac7b838284604051610dd1939291906126fd565b6001600160a01b038516331480610f525750610f528533610366565b610f6e5760405162461bcd60e51b8152600401610434906123fb565b6107f3858585858561162d565b610f83611037565b6001600160a01b038116610fe85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610434565b610ff1816113d8565b50565b6001600160a01b03831633148061101057506110108333610366565b61102c5760405162461bcd60e51b8152600401610434906123fb565b610966838383611765565b6003546001600160a01b0316331461097d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610434565b81518351146110b25760405162461bcd60e51b815260040161043490612732565b6001600160a01b0384166110d85760405162461bcd60e51b81526004016104349061277a565b336110e781878787878761187d565b60005b84518110156111cd57600085828151811061110757611107612449565b60200260200101519050600085838151811061112557611125612449565b602090810291909101810151600084815280835260408082206001600160a01b038e1683529093529190912054909150818110156111755760405162461bcd60e51b8152600401610434906127bf565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906111b2908490612809565b92505081905550505050806111c690612475565b90506110ea565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161121d92919061281c565b60405180910390a461123381878787878761188b565b505050505050565b6001600160a01b0383166112615760405162461bcd60e51b81526004016104349061284a565b80518251146112825760405162461bcd60e51b815260040161043490612732565b60003390506112a58185600086866040518060200160405280600081525061187d565b60005b835181101561136a5760008482815181106112c5576112c5612449565b6020026020010151905060008483815181106112e3576112e3612449565b602090810291909101810151600084815280835260408082206001600160a01b038c1683529093529190912054909150818110156113335760405162461bcd60e51b81526004016104349061288d565b6000928352602083815260408085206001600160a01b038b168652909152909220910390558061136281612475565b9150506112a8565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516113bb92919061281c565b60405180910390a460408051602081019091526000905250505050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361149d5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b6064820152608401610434565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841661156a5760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b6064820152608401610434565b336000611576856119e6565b90506000611583856119e6565b90506115948360008985858961187d565b6000868152602081815260408083206001600160a01b038b168452909152812080548792906115c4908490612809565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461162483600089898989611a31565b50505050505050565b6001600160a01b0384166116535760405162461bcd60e51b81526004016104349061277a565b33600061165f856119e6565b9050600061166c856119e6565b905061167c83898985858961187d565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156116bd5760405162461bcd60e51b8152600401610434906127bf565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906116fa908490612809565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a461175a848a8a8a8a8a611a31565b505050505050505050565b6001600160a01b03831661178b5760405162461bcd60e51b81526004016104349061284a565b336000611797846119e6565b905060006117a4846119e6565b90506117c48387600085856040518060200160405280600081525061187d565b6000858152602081815260408083206001600160a01b038a168452909152902054848110156118055760405162461bcd60e51b81526004016104349061288d565b6000868152602081815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052611624565b611233868686868686611aec565b6001600160a01b0384163b156112335760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906118cf90899089908890889088906004016128d1565b6020604051808303816000875af192505050801561190a575060408051601f3d908101601f1916820190925261190791810190612523565b60015b6119b657611916612540565b806308c379a00361194f575061192a61255c565b806119355750611951565b8060405162461bcd60e51b81526004016104349190611d4a565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b6064820152608401610434565b6001600160e01b0319811663bc197c8160e01b146116245760405162461bcd60e51b81526004016104349061292f565b60408051600180825281830190925260609160009190602080830190803683370190505090508281600081518110611a2057611a20612449565b602090810291909101015292915050565b6001600160a01b0384163b156112335760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611a759089908990889088908890600401612977565b6020604051808303816000875af1925050508015611ab0575060408051601f3d908101601f19168201909252611aad91810190612523565b60015b611abc57611916612540565b6001600160e01b0319811663f23a6e6160e01b146116245760405162461bcd60e51b81526004016104349061292f565b6001600160a01b038516611b735760005b8351811015611b7157828181518110611b1857611b18612449565b602002602001015160046000868481518110611b3657611b36612449565b602002602001015181526020019081526020016000206000828254611b5b9190612809565b90915550611b6a905081612475565b9050611afd565b505b6001600160a01b0384166112335760005b8351811015611624576000848281518110611ba157611ba1612449565b602002602001015190506000848381518110611bbf57611bbf612449565b6020026020010151905060006004600084815260200190815260200160002054905081811015611c425760405162461bcd60e51b815260206004820152602860248201527f455243313135353a206275726e20616d6f756e74206578636565647320746f74604482015267616c537570706c7960c01b6064820152608401610434565b60009283526004602052604090922091039055611c5e81612475565b9050611b84565b604051806101400160405280600a906020820280368337509192915050565b80356001600160a01b0381168114611c9b57600080fd5b919050565b60008060408385031215611cb357600080fd5b611cbc83611c84565b946020939093013593505050565b6001600160e01b031981168114610ff157600080fd5b600060208284031215611cf257600080fd5b8135611cfd81611cca565b9392505050565b6000815180845260005b81811015611d2a57602081850181015186830182015201611d0e565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000611cfd6020830184611d04565b600060208284031215611d6f57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b604081018181106001600160401b0382111715611dab57611dab611d76565b60405250565b601f8201601f191681016001600160401b0381118282101715611dd657611dd6611d76565b6040525050565b60006001600160401b03821115611df657611df6611d76565b5060051b60200190565b600082601f830112611e1157600080fd5b81356020611e1e82611ddd565b604051611e2b8282611db1565b83815260059390931b8501820192828101915086841115611e4b57600080fd5b8286015b84811015611e665780358352918301918301611e4f565b509695505050505050565b60006001600160401b03831115611e8a57611e8a611d76565b604051611ea1601f8501601f191660200182611db1565b809150838152848484011115611eb657600080fd5b83836020830137600060208583010152509392505050565b600082601f830112611edf57600080fd5b611cfd83833560208501611e71565b600080600080600060a08688031215611f0657600080fd5b611f0f86611c84565b9450611f1d60208701611c84565b935060408601356001600160401b0380821115611f3957600080fd5b611f4589838a01611e00565b94506060880135915080821115611f5b57600080fd5b611f6789838a01611e00565b93506080880135915080821115611f7d57600080fd5b50611f8a88828901611ece565b9150509295509295909350565b60008060408385031215611faa57600080fd5b82356001600160401b0380821115611fc157600080fd5b818501915085601f830112611fd557600080fd5b81356020611fe282611ddd565b604051611fef8282611db1565b83815260059390931b850182019282810191508984111561200f57600080fd5b948201945b838610156120345761202586611c84565b82529482019490820190612014565b9650508601359250508082111561204a57600080fd5b5061205785828601611e00565b9150509250929050565b600081518084526020808501945080840160005b8381101561209157815187529582019590820190600101612075565b509495945050505050565b602081526000611cfd6020830184612061565b6000806000606084860312156120c457600080fd5b6120cd84611c84565b925060208401356001600160401b03808211156120e957600080fd5b6120f587838801611e00565b9350604086013591508082111561210b57600080fd5b5061211886828701611e00565b9150509250925092565b6000806040838503121561213557600080fd5b61213e83611c84565b91506020830135801515811461215357600080fd5b809150509250929050565b600080604080848603121561217257600080fd5b833592506020808501356001600160401b0381111561219057600080fd5b8501601f810187136121a157600080fd5b80356121ac81611ddd565b84516121b88282611db1565b82815260069290921b83018401918481019150898311156121d857600080fd5b928401925b828410156122385785848b0312156121f55760008081fd5b855161220081611d8c565b61220985611c84565b8152858501356001600160601b03811681146122255760008081fd5b81870152825292850192908401906121dd565b8096505050505050509250929050565b8215158152610160810160208083018460005b600a8110156122815781516001600160a01b03168352918301919083019060010161225b565b505050509392505050565b6000806040838503121561229f57600080fd5b8235915060208301356001600160401b038111156122bc57600080fd5b8301601f810185136122cd57600080fd5b61205785823560208401611e71565b600080604083850312156122ef57600080fd5b6122f883611c84565b915061230660208401611c84565b90509250929050565b600080600080600060a0868803121561232757600080fd5b61233086611c84565b945061233e60208701611c84565b9350604086013592506060860135915060808601356001600160401b0381111561236757600080fd5b611f8a88828901611ece565b60006020828403121561238557600080fd5b611cfd82611c84565b6000806000606084860312156123a357600080fd5b6123ac84611c84565b95602085013595506040909401359392505050565b600181811c908216806123d557607f821691505b6020821081036123f557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016124875761248761245f565b5060010190565b60208082526026908201527f546f6b656e206d696e74696e67206c6f636b656420666f72207468697320746f6040820152651ad95b88125960d21b606082015260800190565b6020808252602f908201527f546f6b656e205552492073686f756c64206e6f7420626520626c616e6b20666f60408201526e1c881d1a1a5cc81d1bdad95b881259608a1b606082015260800190565b60006020828403121561253557600080fd5b8151611cfd81611cca565b600060033d11156125595760046000803e5060005160e01c5b90565b600060443d101561256a5790565b6040516003193d81016004833e81513d6001600160401b03816024840111818411171561259957505050505090565b82850191508151818111156125b15750505050505090565b843d87010160208285010111156125cb5750505050505090565b6125da60208286010187611db1565b509095945050505050565b818103818111156104605761046061245f565b601f82111561096657600081815260208120601f850160051c8101602086101561261f5750805b601f850160051c820191505b818110156112335782815560010161262b565b81516001600160401b0381111561265757612657611d76565b61266b8161266584546123c1565b846125f8565b602080601f8311600181146126a057600084156126885750858301515b600019600386901b1c1916600185901b178555611233565b600085815260208120601f198616915b828110156126cf578886015182559484019460019091019084016126b0565b50858210156126ed5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8381526060602082015260006127166060830185611d04565b82810360408401526127288185611d04565b9695505050505050565b60208082526028908201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206040820152670dad2e6dac2e8c6d60c31b606082015260800190565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b808201808211156104605761046061245f565b60408152600061282f6040830185612061565b82810360208401526128418185612061565b95945050505050565b60208082526023908201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260408201526265737360e81b606082015260800190565b60208082526024908201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604082015263616e636560e01b606082015260800190565b6001600160a01b0386811682528516602082015260a0604082018190526000906128fd90830186612061565b828103606084015261290f8186612061565b905082810360808401526129238185611d04565b98975050505050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906129b190830184611d04565b97965050505050505056fea2646970667358221220f1abd756c07dc2506b843faaad8d788e593fb38d77ef1e4e7b3c11da4323abc964736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
ERC1155.sol 517 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @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)) private _balances;
// Mapping from account to operator approvals
mapping(address => mapping(address => bool)) private _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: address zero is not a valid owner");
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 {
_setApprovalForAll(_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 token owner or 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: caller is not token owner or 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();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, to, ids, amounts, 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);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_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);
_afterTokenTransfer(operator, from, to, ids, amounts, data);
_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 `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: mint to the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, address(0), to, ids, amounts, data);
_balances[id][to] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* 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 _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);
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/**
* @dev Destroys `amount` tokens of token type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `amount` tokens of token type `id`.
*/
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
uint256 fromBalance = _balances[id][from];
require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
emit TransferSingle(operator, from, address(0), id, amount);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
*/
function _burnBatch(
address from,
uint256[] memory ids,
uint256[] memory amounts
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
address operator = _msgSender();
_beforeTokenTransfer(operator, from, address(0), ids, amounts, "");
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: burn amount exceeds balance");
unchecked {
_balances[id][from] = fromBalance - amount;
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
_afterTokenTransfer(operator, from, address(0), ids, amounts, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC1155: setting approval status for self");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `ids` and `amounts` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
/**
* @dev Hook that is called after any token transfer. This includes minting
* and burning, as well as batched variants.
*
* The same hook is called on both single and batched variants. For single
* transfers, the length of the `id` and `amount` arrays will be 1.
*
* Calling conditions (for each `id` and `amount` pair):
*
* - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* of token type `id` will be transferred to `to`.
* - When `from` is zero, `amount` tokens of token type `id` will be minted
* for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
* will be burned.
* - `from` and `to` are never both zero.
* - `ids` and `amounts` have the same, non-zero length.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual {}
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) private {
if (to.isContract()) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
revert("ERC1155: ERC1155Receiver rejected tokens");
}
} catch Error(string memory reason) {
revert(reason);
} catch {
revert("ERC1155: transfer to non-ERC1155Receiver implementer");
}
}
}
function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
uint256[] memory array = new uint256[](1);
array[0] = element;
return array;
}
}
ERC1155Burnable.sol 40 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/extensions/ERC1155Burnable.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of {ERC1155} that allows token holders to destroy both their
* own tokens and those that they have been approved to use.
*
* _Available since v3.1._
*/
abstract contract ERC1155Burnable is ERC1155 {
function burn(
address account,
uint256 id,
uint256 value
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_burn(account, id, value);
}
function burnBatch(
address account,
uint256[] memory ids,
uint256[] memory values
) public virtual {
require(
account == _msgSender() || isApprovedForAll(account, _msgSender()),
"ERC1155: caller is not token owner or approved"
);
_burnBatch(account, ids, values);
}
}
IERC1155MetadataURI.sol 22 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.0;
import "../IERC1155.sol";
/**
* @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);
}
IERC1155Receiver.sol 58 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @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.
*
* NOTE: 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.
*
* NOTE: 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);
}
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;
}
}
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);
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
ERC1155Supply.sol 64 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)
pragma solidity ^0.8.0;
import "../ERC1155.sol";
/**
* @dev Extension of ERC1155 that adds tracking of total supply per id.
*
* Useful for scenarios where Fungible and Non-fungible tokens have to be
* clearly identified. Note: While a totalSupply of 1 might mean the
* corresponding is an NFT, there is no guarantees that no other token with the
* same id are not going to be minted.
*/
abstract contract ERC1155Supply is ERC1155 {
mapping(uint256 => uint256) private _totalSupply;
/**
* @dev Total amount of tokens in with a given id.
*/
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply[id];
}
/**
* @dev Indicates whether any token exist with a given id, or not.
*/
function exists(uint256 id) public view virtual returns (bool) {
return ERC1155Supply.totalSupply(id) > 0;
}
/**
* @dev See {ERC1155-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
if (from == address(0)) {
for (uint256 i = 0; i < ids.length; ++i) {
_totalSupply[ids[i]] += amounts[i];
}
}
if (to == address(0)) {
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids[i];
uint256 amount = amounts[i];
uint256 supply = _totalSupply[id];
require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
unchecked {
_totalSupply[id] = supply - amount;
}
}
}
}
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @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 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;
}
ERC165Checker.sol 123 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/ERC165Checker.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Library used to query support of an interface declared via {IERC165}.
*
* Note that these functions return the actual result of the query: they do not
* `revert` if an interface is not supported. It is up to the caller to decide
* what to do in these cases.
*/
library ERC165Checker {
// As per the EIP-165 spec, no interface should ever match 0xffffffff
bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
/**
* @dev Returns true if `account` supports the {IERC165} interface.
*/
function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return
supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&
!supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);
}
/**
* @dev Returns true if `account` supports the interface defined by
* `interfaceId`. Support for {IERC165} itself is queried automatically.
*
* See {IERC165-supportsInterface}.
*/
function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId
return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);
}
/**
* @dev Returns a boolean array where each value corresponds to the
* interfaces passed in and whether they're supported or not. This allows
* you to batch check interfaces for a contract where your expectation
* is that some interfaces may not be supported.
*
* See {IERC165-supportsInterface}.
*
* _Available since v3.4._
*/
function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
internal
view
returns (bool[] memory)
{
// an array of booleans corresponding to interfaceIds and whether they're supported or not
bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
// query support of ERC165 itself
if (supportsERC165(account)) {
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);
}
}
return interfaceIdsSupported;
}
/**
* @dev Returns true if `account` supports all the interfaces defined in
* `interfaceIds`. Support for {IERC165} itself is queried automatically.
*
* Batch-querying can lead to gas savings by skipping repeated checks for
* {IERC165} support.
*
* See {IERC165-supportsInterface}.
*/
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself
if (!supportsERC165(account)) {
return false;
}
// query support of each interface in interfaceIds
for (uint256 i = 0; i < interfaceIds.length; i++) {
if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {
return false;
}
}
// all interfaces supported
return true;
}
/**
* @notice Query if a contract implements an interface, does not check ERC165 support
* @param account The address of the contract to query for support of an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @return true if the contract at account indicates support of the interface with
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
* Interface identification is specified in ERC-165.
*/
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
// prepare call
bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
// perform static call
bool success;
uint256 returnSize;
uint256 returnValue;
assembly {
success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
returnSize := returndatasize()
returnValue := mload(0x00)
}
return success && returnSize >= 0x20 && returnValue > 0;
}
}
Wassietopia.sol 712 lines
// SPDX-License-Identifier: MIT
/**
((
(((((( (( (. ((, ((((((( (( (( ((( ((( ((((((((
(( (( (( ((. (( ((, (( (( (( (( (( ((((. ((((((((( ((
(( (( (( ((, (( (( (( *(( (( (* (( (( (( ((.
(( ((* (( (( .(( (( .(( (( ((( ((( (( ((( (((/
(((((( (((. (( (( (( ((((((( ((((( (( .(( (((((( ((
(( ((( (( (( (( (( (( *(( (/ (( ,(( ((( ((( (( ((,
(( ((( ((. (( ((((((( ((# (( #(( ((((( ((, (( (( ((
(( %(( (( (((( (( ((( ((((( (((((((( (( ((((((
* (( ((((((((
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
/**
*
* @dev Wassietopia is an ERC-1155 contract with airdrop functionality.
*
* This contract is an ERC-1155 with the following features:
* - Owner can create new tokenIds for distribution in airdrops.
* - Airdrop mech is minting using a passed array of an object denoting recipient and quantity.
* - Minting can be locked for a given tokenId, i.e. no more airdrop for that Id.
* - URI per token Id.
* - Changeable URI.
* - Lockable URI per tokenId.
* - Stores name and symbol for consistency with ERC721 / 20
*
*/
contract Wassietopia is ERC1155, Ownable, ERC1155Burnable, ERC1155Supply {
using Address for address;
/**
*
* @dev Add name and symbol for consistency with ERC-721 NFTs.
*
*/
string private _name;
string private _symbol;
/**
*
* @dev Struct to hold details of a given tokenId, being:
* - mintingLocked: If this is set to TRUE by the owner no more minting can occur
* - uriLocked: If this is set to TRUE the URI for this tokenId cannot be changed
* - uri: the token URI for this tokenId
*
*/
struct AirdropToken {
bool mintingLocked;
bool uriLocked;
string uri;
}
/**
*
* @dev Struct received on calls to airdrop and validateAirdrop
*
*/
struct AirdropDetail {
address receiver;
uint96 quantity;
}
/**
*
* @dev Emitted when a tokenId URI is locked
*
*/
event TokenURILocked(uint256 tokenId);
/**
*
* @dev Emitted when minting for a tokenId is locked
*
*/
event TokenMintingLocked(uint256 tokenId);
/**
*
* @dev Emitted when a tokenId URI is updated
*
*/
event TokenURIUpdated(uint256 tokenId, string oldURI, string newURI);
/**
*
* @dev Emitted when an airdrop is performed
*
*/
event AirdropComplete(
uint256 tokenId,
uint256 numberOfRecipients,
uint256 quantityMinted
);
/**
*
* @dev Mapping between tokenId and the details object for that Id
*
*/
mapping(uint256 => AirdropToken) token;
/**
*
* @dev Constructor must be passed:
* - The token name and symbol. I mean, why is everyone out there leaving this as 'ERC1155'???
*
*/
constructor(string memory tokenName_, string memory tokenSymbol_)
ERC1155("")
{
_name = tokenName_;
_symbol = tokenSymbol_;
}
/**
*
* @dev Add name for consistency with ERC-721 NFTs.
*
*/
function name() public view returns (string memory) {
return _name;
}
/**
*
* @dev Add symbol for consistency with ERC-721 NFTs.
*
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
*
* @dev Return the URI lock status for a token
*
*/
function tokenURILocked(uint256 tokenId_)
public
view
returns (bool tokenURIIsLocked)
{
return token[tokenId_].uriLocked == true;
}
/**
*
* @dev Return the minting status for a token
*
*/
function tokenMintingLocked(uint256 tokenId_)
public
view
returns (bool tokenMintingIsLocked)
{
return token[tokenId_].mintingLocked == true;
}
/**
*
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the correct URI for each token Id
*
*/
function uri(uint256 tokenId_)
public
view
override
returns (string memory)
{
return token[tokenId_].uri;
}
/**
*
* @dev Owner can airdrop tokens that aren't locked
*
*/
function airdrop(uint256 tokenId_, AirdropDetail[] memory airdropDetails_)
public
onlyOwner
{
require(
!tokenMintingLocked(tokenId_),
"Token minting locked for this token Id"
);
require(
bytes(uri(tokenId_)).length != 0,
"Token URI should not be blank for this token Id"
);
// Cache the pre-airdrop supply
uint256 preSupply = totalSupply(tokenId_);
for (uint256 i = 0; i < airdropDetails_.length; ) {
_mint(
airdropDetails_[i].receiver,
tokenId_,
airdropDetails_[i].quantity,
""
);
unchecked {
i++;
}
}
emit AirdropComplete(
tokenId_,
airdropDetails_.length,
totalSupply(tokenId_) - preSupply
);
}
/**
*
* @dev Validate an airdrop. This checks that for all items if the recpient is a
* contract address that supports ERC1155Received
*
*/
function validateAirdrop(
uint256 tokenId_,
AirdropDetail[] memory airdropDetails_
) external returns (bool success_, address[10] memory failingAddresses_) {
require(
!tokenMintingLocked(tokenId_),
"Token minting locked for this token Id"
);
require(
bytes(uri(tokenId_)).length != 0,
"Token URI should not be blank for this token Id"
);
success_ = true;
uint256 failingIndex = 0;
for (uint256 i = 0; i < airdropDetails_.length; ) {
if (airdropDetails_[i].receiver.isContract()) {
try
IERC1155Receiver(airdropDetails_[i].receiver)
.onERC1155Received(
address(this),
address(this),
tokenId_,
airdropDetails_[i].quantity,
""
)
returns (bytes4 response) {
if (
response != IERC1155Receiver.onERC1155Received.selector
) {
success_ = false;
failingAddresses_[failingIndex] = airdropDetails_[i]
.receiver;
unchecked {
failingIndex++;
}
}
} catch Error(string memory) {
success_ = false;
failingAddresses_[failingIndex] = airdropDetails_[i]
.receiver;
unchecked {
failingIndex++;
}
} catch {
success_ = false;
failingAddresses_[failingIndex] = airdropDetails_[i]
.receiver;
unchecked {
failingIndex++;
}
}
}
if (failingIndex == 10) {
// 10 Errors recorded. Break here and report
break;
}
unchecked {
i++;
}
}
return (success_, failingAddresses_);
}
/**
*
* @dev Owner can set the URI for a token until it's URI is locked.
*
*/
function setURIForTokenId(uint256 tokenId_, string memory newURI_)
public
onlyOwner
{
require(!tokenURILocked(tokenId_), "Token URI locked fren");
string memory oldURI = token[tokenId_].uri;
token[tokenId_].uri = newURI_;
emit TokenURIUpdated(tokenId_, oldURI, newURI_);
}
/**
*
* @dev Owner can lock the URI for a token once no further changes are required.
*
*/
function lockURIForTokenId(uint256 tokenId_) public onlyOwner {
require(
!tokenURILocked(tokenId_),
"Token URI already locked, you tryna burn ETH fren?"
);
token[tokenId_].uriLocked = true;
emit TokenURILocked(tokenId_);
}
/**
*
* @dev Owner can lock the airdrop THIS MEANS NO MORE TOKENS
* FOR THIS TOKEN ID CAN EVER BE MINTED
*
*/
function lockMintingForTokenId(uint256 tokenId_) public onlyOwner {
require(
!tokenMintingLocked(tokenId_),
"Token minting already locked, you tryna burn ETH fren?"
);
token[tokenId_].mintingLocked = true;
emit TokenMintingLocked(tokenId_);
}
/**
*
* @dev Keep track of the supply (records the amount minted and tracks burns)
*
*/
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal override(ERC1155, ERC1155Supply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%% %%%%%
/.&&&&&&&&&&&&&&&& &@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ %%%%%%%% %%%% .
,**&&&&&&&&&&&&&&&% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ /%%%%%%%%%%,(
& (&&&&&&&&&&&&&&&* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@# %%%%%%%%
& %&&&&&&&&&&&&&&&,,@@@@@@@@@@@@@@@@@@@,@/@@@@@@@@@@@@@@@@@@, %%%% *
& &&&&&&&&omnus&&&&&&has&&&&&&&&&&&&&&&&your&&&&&&&&back&&&&&&&&fren&&&
*/
Read Contract
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
exists 0x4f558e79 → bool
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenMintingLocked 0xe436692e → bool
tokenURILocked 0x734f851e → bool
totalSupply 0xbd85b039 → uint256
uri 0x0e89341c → string
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
airdrop 0x219af392
uint256 tokenId_
tuple[] airdropDetails_
burn 0xf5298aca
address account
uint256 id
uint256 value
burnBatch 0x6b20c454
address account
uint256[] ids
uint256[] values
lockMintingForTokenId 0x2b8bd8b1
uint256 tokenId_
lockURIForTokenId 0x2e544cda
uint256 tokenId_
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
setURIForTokenId 0xe728782b
uint256 tokenId_
string newURI_
transferOwnership 0xf2fde38b
address newOwner
validateAirdrop 0x0dfa3fc6
uint256 tokenId_
tuple[] airdropDetails_
returns: bool, address[10]
Recent Transactions
No transactions found for this address