Address Contract Partially Verified
Address
0x27Cda43F8246aB6F1F87F8A344C6316a435B1E10
Balance
0 ETH
Nonce
1
Code Size
9816 bytes
Creator
0x5e7b89dE...52D3 at tx 0xad5604ef...714520
Indexed Transactions
0
Contract Bytecode
9816 bytes
0x608060405234801561001057600080fd5b506004361061014c5760003560e01c806373f25c38116100c3578063cd53d08e1161007c578063cd53d08e146102b4578063d2a6b51a146102c7578063d79cd255146102da578063e985e9c5146102ed578063f242432a14610300578063f2fde38b146103135761014c565b806373f25c381461024b5780637e518ec81461025e5780638da5cb5b1461027157806395d89b4114610286578063a22cb4651461028e578063bd85b039146102a15761014c565b80630ecaea73116101155780630ecaea73146101d7578063156e29f6146101ea5780632693ebf2146101fd5780632eb2c2d6146102105780634a198119146102235780634e1273f41461022b5761014c565b8062fdd58e1461015157806301ffc9a71461017a57806306fdde031461019a5780630ca83480146101af5780630e89341c146101c4575b600080fd5b61016461015f366004611b32565b610326565b60405161017191906123c0565b60405180910390f35b61018d610188366004611c47565b61034f565b6040516101719190611f10565b6101a261039e565b6040516101719190611f1b565b6101c26101bd366004611a8e565b61042c565b005b6101a26101d2366004611ce1565b61053a565b6101646101e5366004611b32565b6105be565b6101c26101f8366004611b5d565b61068b565b61016461020b366004611ce1565b610742565b6101c261021e36600461192f565b610754565b6101646107d3565b61023e610239366004611b91565b6107ea565b6040516101719190611ed8565b61018d6102593660046118db565b610938565b6101c261026c366004611c9b565b61094d565b610279610998565b6040516101719190611e21565b6101a26109a7565b6101c261029c366004611b01565b6109b4565b6101646102af366004611ce1565b610a23565b6102796102c2366004611ce1565b610a35565b6101c26102d5366004611a40565b610a50565b6101c26102e8366004611b01565b610acb565b61018d6102fb3660046118f7565b610b35565b6101c261030e3660046119d9565b610be7565b6101c26103213660046118db565b610c5f565b6001600160a01b0382166000908152602081815260408083208484529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061038057506001600160e01b0319821663c5aa421f60e01b145b1561038d57506001610399565b61039682610ccd565b90505b919050565b600980546103ab906124a0565b80601f01602080910402602001604051908101604052809291908181526020018280546103d7906124a0565b80156104245780601f106103f957610100808354040283529160200191610424565b820191906000526020600020905b81548152906001019060200180831161040757829003601f168201915b505050505081565b60005b825181101561051957600083828151811061045a57634e487b7160e01b600052603260045260246000fd5b6020026020010151905061046c610cf9565b6000828152600660205260409020546001600160a01b039081169116146104ae5760405162461bcd60e51b81526004016104a590612015565b60405180910390fd5b60008383815181106104d057634e487b7160e01b600052603260045260246000fd5b60200260200101519050806007600084815260200190815260200160002060008282546104fd9190612431565b9250508190555050508080610511906124db565b91505061042f565b5061053583838360405180602001604052806000815250610cfd565b505050565b606061054582610e9c565b6105615760405162461bcd60e51b81526004016104a590612199565b600060028054610570906124a0565b90501161058c5760405180602001604052806000815250610396565b600261059783610eb9565b6040516020016105a8929190611d7b565b6040516020818303038152906040529050919050565b6000600860006105cc610cf9565b6001600160a01b0316815260208101919091526040016000205460ff166106055760405162461bcd60e51b81526004016104a5906121de565b600061060f6107d3565b9050610619610fd4565b610621610cf9565b6006600083815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555061067384828560405180602001604052806000815250610feb565b60008181526007602052604090209290925550919050565b81610694610cf9565b6000828152600660205260409020546001600160a01b0390811691161480156106e25750600860006106c4610cf9565b6001600160a01b0316815260208101919091526040016000205460ff165b6106fe5760405162461bcd60e51b81526004016104a59061236f565b61071984848460405180602001604052806000815250610feb565b60008381526007602052604081208054849290610737908490612431565b909155505050505050565b60076020526000908152604090205481565b336001600160a01b038616148061077057506107708533610b35565b61078c5760405162461bcd60e51b81526004016104a590612284565b6001600160a01b0384166107b25760405162461bcd60e51b81526004016104a590612149565b6107be85858585611090565b6107cc858585855a866112f7565b5050505050565b600060055460016107e49190612431565b90505b90565b6060815183511461080d5760405162461bcd60e51b81526004016104a590612238565b6000835167ffffffffffffffff81111561083757634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610860578160200160208202803683370190505b50905060005b84518110156109305760008086838151811061089257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008583815181106108dc57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205482828151811061091357634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610928816124db565b915050610866565b509392505050565b60086020526000908152604090205460ff1681565b610955610cf9565b6001600160a01b0316610966610998565b6001600160a01b03161461098c5760405162461bcd60e51b81526004016104a590612203565b6109958161140f565b50565b6003546001600160a01b031690565b600a80546103ab906124a0565b3360008181526001602090815260408083206001600160a01b038716808552925291829020805460ff191685151517905590519091907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190610a17908590611f10565b60405180910390a35050565b60009081526007602052604090205490565b6006602052600090815260409020546001600160a01b031681565b6001600160a01b038216610a765760405162461bcd60e51b81526004016104a590612323565b60005b8151811015610535576000828281518110610aa457634e487b7160e01b600052603260045260246000fd5b60200260200101519050610ab88482611426565b5080610ac3816124db565b915050610a79565b610ad3610cf9565b6001600160a01b0316610ae4610998565b6001600160a01b031614610b0a5760405162461bcd60e51b81526004016104a590612203565b6001600160a01b03919091166000908152600860205260409020805460ff1916911515919091179055565b6004805460405163c455279160e01b81526000926001600160a01b0392831692851691839163c455279191610b6c91899101611e21565b60206040518083038186803b158015610b8457600080fd5b505afa158015610b98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbc9190611c7f565b6001600160a01b03161415610bd5576001915050610349565b610bdf84846114c8565b949350505050565b336001600160a01b0386161480610c035750610c038533610b35565b610c1f5760405162461bcd60e51b81526004016104a5906120aa565b6001600160a01b038416610c455760405162461bcd60e51b81526004016104a590611fca565b610c51858585856114f6565b6107cc858585855a866115d2565b610c67610cf9565b6001600160a01b0316610c78610998565b6001600160a01b031614610c9e5760405162461bcd60e51b81526004016104a590612203565b6001600160a01b038116610cc45760405162461bcd60e51b81526004016104a590612064565b610995816116a3565b60006001600160e01b031982166303a24d0760e21b1415610cf057506001610399565b610396826116f5565b3390565b8151835114610d1e5760405162461bcd60e51b81526004016104a5906122d3565b825160005b81811015610e3457610dc1848281518110610d4e57634e487b7160e01b600052603260045260246000fd5b6020026020010151600080896001600160a01b03166001600160a01b031681526020019081526020016000206000888581518110610d9c57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205461172190919063ffffffff16565b600080886001600160a01b03166001600160a01b031681526020019081526020016000206000878481518110610e0757634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055508080610e2c906124db565b915050610d23565b50846001600160a01b031660006001600160a01b0316336001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8787604051610e85929190611eeb565b60405180910390a46107cc60008686865a876112f7565b6000908152600660205260409020546001600160a01b0316151590565b606081610ede57506040805180820190915260018152600360fc1b6020820152610399565b8160005b8115610f085780610ef2816124db565b9150610f019050600a83612449565b9150610ee2565b60008167ffffffffffffffff811115610f3157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610f5b576020820181803683370190505b5090505b8415610bdf57610f7060018361245d565b9150610f7d600a866124f6565b610f88906030612431565b60f81b818381518110610fab57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350610fcd600a86612449565b9450610f5f565b60058054906000610fe4836124db565b9190505550565b6001600160a01b0384166000908152602081815260408083208684529091529020546110179083611721565b6001600160a01b03851660008181526020818152604080832088845290915280822093909355915190919033907fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f629061107390889088906123c9565b60405180910390a461108a60008585855a866115d2565b50505050565b80518251146110b15760405162461bcd60e51b81526004016104a5906120f4565b815160005b81811015611298576111548382815181106110e157634e487b7160e01b600052603260045260246000fd5b6020026020010151600080896001600160a01b03166001600160a01b03168152602001908152602001600020600087858151811061112f57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000205461173490919063ffffffff16565b600080886001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061119a57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055506112258382815181106111d757634e487b7160e01b600052603260045260246000fd5b6020026020010151600080886001600160a01b03166001600160a01b031681526020019081526020016000206000878581518110610d9c57634e487b7160e01b600052603260045260246000fd5b600080876001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061126b57634e487b7160e01b600052603260045260246000fd5b60200260200101518152602001908152602001600020819055508080611290906124db565b9150506110b6565b50836001600160a01b0316856001600160a01b0316336001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516112e8929190611eeb565b60405180910390a45050505050565b611309856001600160a01b0316611740565b156114075760405163bc197c8160e01b81526001600160a01b0386169063bc197c81906113429033908a90899089908890600401611e35565b602060405180830381600087803b15801561135c57600080fd5b505af192505050801561138c575060408051601f3d908101601f1916820190925261138991810190611c63565b60015b6113d557611398612552565b806113a357506113bd565b8060405162461bcd60e51b81526004016104a59190611f1b565b60405162461bcd60e51b81526004016104a590611f2e565b6001600160e01b0319811663bc197c8160e01b146114055760405162461bcd60e51b81526004016104a590611f82565b505b505050505050565b805161142290600290602084019061175f565b5050565b8061142f610cf9565b6000828152600660205260409020546001600160a01b03908116911614801561147d57506008600061145f610cf9565b6001600160a01b0316815260208101919091526040016000205460ff165b6114995760405162461bcd60e51b81526004016104a59061236f565b50600090815260066020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6001600160a01b0384166000908152602081815260408083208584529091529020546115229082611734565b6001600160a01b03808616600090815260208181526040808320878452825280832094909455918616815280825282812085825290915220546115659082611721565b6001600160a01b03808516600081815260208181526040808320888452909152908190209390935591519086169033907fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62906115c490879087906123c9565b60405180910390a450505050565b6115e4856001600160a01b0316611740565b156114075760405163f23a6e6160e01b81526001600160a01b0386169063f23a6e619061161d9033908a90899089908890600401611e93565b602060405180830381600087803b15801561163757600080fd5b505af1925050508015611667575060408051601f3d908101601f1916820190925261166491810190611c63565b60015b61167357611398612552565b6001600160e01b0319811663f23a6e6160e01b146114055760405162461bcd60e51b81526004016104a590611f82565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006001600160e01b03198216636cdb3d1360e11b141561171857506001610399565b61039682611746565b600061172d8284612431565b9392505050565b600061172d828461245d565b3b151590565b6001600160e01b031981166301ffc9a760e01b14919050565b82805461176b906124a0565b90600052602060002090601f01602090048101928261178d57600085556117d3565b82601f106117a657805160ff19168380011785556117d3565b828001600101855582156117d3579182015b828111156117d35782518255916020019190600101906117b8565b506117df9291506117e3565b5090565b5b808211156117df57600081556001016117e4565b600067ffffffffffffffff83111561181257611812612536565b611825601f8401601f19166020016123d7565b905082815283838301111561183957600080fd5b828260208301376000602084830101529392505050565b600082601f830112611860578081fd5b8135602061187561187083612401565b6123d7565b8281528181019085830183850287018401881015611891578586fd5b855b858110156118af57813584529284019290840190600101611893565b5090979650505050505050565b600082601f8301126118cc578081fd5b61172d838335602085016117f8565b6000602082840312156118ec578081fd5b813561172d816125f7565b60008060408385031215611909578081fd5b8235611914816125f7565b91506020830135611924816125f7565b809150509250929050565b600080600080600060a08688031215611946578081fd5b8535611951816125f7565b94506020860135611961816125f7565b9350604086013567ffffffffffffffff8082111561197d578283fd5b61198989838a01611850565b9450606088013591508082111561199e578283fd5b6119aa89838a01611850565b935060808801359150808211156119bf578283fd5b506119cc888289016118bc565b9150509295509295909350565b600080600080600060a086880312156119f0578081fd5b85356119fb816125f7565b94506020860135611a0b816125f7565b93506040860135925060608601359150608086013567ffffffffffffffff811115611a34578182fd5b6119cc888289016118bc565b60008060408385031215611a52578182fd5b8235611a5d816125f7565b9150602083013567ffffffffffffffff811115611a78578182fd5b611a8485828601611850565b9150509250929050565b600080600060608486031215611aa2578283fd5b8335611aad816125f7565b9250602084013567ffffffffffffffff80821115611ac9578384fd5b611ad587838801611850565b93506040860135915080821115611aea578283fd5b50611af786828701611850565b9150509250925092565b60008060408385031215611b13578182fd5b8235611b1e816125f7565b915060208301358015158114611924578182fd5b60008060408385031215611b44578182fd5b8235611b4f816125f7565b946020939093013593505050565b600080600060608486031215611b71578081fd5b8335611b7c816125f7565b95602085013595506040909401359392505050565b60008060408385031215611ba3578182fd5b823567ffffffffffffffff80821115611bba578384fd5b818501915085601f830112611bcd578384fd5b81356020611bdd61187083612401565b82815281810190858301838502870184018b1015611bf9578889fd5b8896505b84871015611c24578035611c10816125f7565b835260019690960195918301918301611bfd565b5096505086013592505080821115611c3a578283fd5b50611a8485828601611850565b600060208284031215611c58578081fd5b813561172d8161260c565b600060208284031215611c74578081fd5b815161172d8161260c565b600060208284031215611c90578081fd5b815161172d816125f7565b600060208284031215611cac578081fd5b813567ffffffffffffffff811115611cc2578182fd5b8201601f81018413611cd2578182fd5b610bdf848235602084016117f8565b600060208284031215611cf2578081fd5b5035919050565b6000815180845260208085019450808401835b83811015611d2857815187529582019590820190600101611d0c565b509495945050505050565b60008151808452611d4b816020860160208601612474565b601f01601f19169290920160200192915050565b60008151611d71818560208601612474565b9290920192915050565b8254600090819060028104600180831680611d9757607f831692505b6020808410821415611db757634e487b7160e01b87526022600452602487fd5b818015611dcb5760018114611ddc57611e08565b60ff19861689528489019650611e08565b611de58b612425565b885b86811015611e005781548b820152908501908301611de7565b505084890196505b505050505050611e188185611d5f565b95945050505050565b6001600160a01b0391909116815260200190565b6001600160a01b0386811682528516602082015260a060408201819052600090611e6190830186611cf9565b8281036060840152611e738186611cf9565b90508281036080840152611e878185611d33565b98975050505050505050565b6001600160a01b03868116825285166020820152604081018490526060810183905260a060808201819052600090611ecd90830184611d33565b979650505050505050565b60006020825261172d6020830184611cf9565b600060408252611efe6040830185611cf9565b8281036020840152611e188185611cf9565b901515815260200190565b60006020825261172d6020830184611d33565b60208082526034908201527f455243313135353a207472616e7366657220746f206e6f6e20455243313135356040820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b606082015260800190565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6020808252602b908201527f4552433131353523736166655472616e7366657246726f6d3a20494e56414c4960408201526a1117d49150d2541251539560aa1b606082015260800190565b6020808252602f908201527f455243313135355472616461626c652362617463684d696e743a204f4e4c595f60408201526e10d491505513d497d0531313d5d151608a1b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252602a908201527f4552433131353523736166655472616e7366657246726f6d3a20494e56414c49604082015269222fa7a822a920aa27a960b11b606082015260800190565b60208082526035908201527f45524331313535235f7361666542617463685472616e7366657246726f6d3a206040820152740929cac82989288be82a4a482b2a6be988a9c8ea89605b1b606082015260800190565b60208082526030908201527f45524331313535237361666542617463685472616e7366657246726f6d3a204960408201526f13959053125117d49150d2541251539560821b606082015260800190565b60208082526025908201527f4552433732315472616461626c65237572693a204e4f4e4558495354454e545f6040820152642a27a5a2a760d91b606082015260800190565b6020808252600b908201526a139bdd08185b1b1bddd95960aa1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602c908201527f455243313135352362616c616e63654f6642617463683a20494e56414c49445f60408201526b082a4a482b2be988a9c8ea8960a31b606082015260800190565b6020808252602f908201527f45524331313535237361666542617463685472616e7366657246726f6d3a204960408201526e272b20a624a22fa7a822a920aa27a960891b606082015260800190565b60208082526030908201527f455243313135354d696e744275726e2362617463684d696e743a20494e56414c60408201526f09288be82a4a482b2a6be988a9c8ea8960831b606082015260800190565b6020808252602c908201527f455243313135355472616461626c652373657443726561746f723a20494e564160408201526b2624a22fa0a2222922a9a99760a11b606082015260800190565b60208082526031908201527f455243313135355472616461626c652363726561746f724f6e6c793a204f4e4c6040820152701657d0d491505513d497d0531313d5d151607a1b606082015260800190565b90815260200190565b918252602082015260400190565b60405181810167ffffffffffffffff811182821017156123f9576123f9612536565b604052919050565b600067ffffffffffffffff82111561241b5761241b612536565b5060209081020190565b60009081526020902090565b600082198211156124445761244461250a565b500190565b60008261245857612458612520565b500490565b60008282101561246f5761246f61250a565b500390565b60005b8381101561248f578181015183820152602001612477565b8381111561108a5750506000910152565b6002810460018216806124b457607f821691505b602082108114156124d557634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156124ef576124ef61250a565b5060010190565b60008261250557612505612520565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b60e01c90565b600060443d1015612562576107e7565b600481823e6308c379a0612576825161254c565b14612580576107e7565b6040513d600319016004823e80513d67ffffffffffffffff81602484011181841117156125b057505050506107e7565b828401925082519150808211156125ca57505050506107e7565b503d830160208284010111156125e2575050506107e7565b601f01601f1916810160200160405291505090565b6001600160a01b038116811461099557600080fd5b6001600160e01b03198116811461099557600080fdfea2646970667358221220e2e622cbd2e27e83d13b3f853fa06322e1601f596f3ed6923de2af7a7f0a9f5f64736f6c63430008000033
Verified Source Code Partial Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (200 runs)
Ownable.sol 62 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts//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(address newOwner) {
_setOwner(newOwner);
}
/**
* @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 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);
}
}
ERC1155.sol 256 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "./IERC1155.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* @dev Implementation of Multi-Token Standard contract
*/
contract ERC1155 is IERC1155, ERC165 {
using SafeMath for uint256;
using Address for address;
/***********************************|
| Variables and Events |
|__________________________________*/
// onReceive function signatures
bytes4 constant internal ERC1155_RECEIVED_VALUE = 0xf23a6e61;
bytes4 constant internal ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81;
// Objects balances
mapping (address => mapping(uint256 => uint256)) internal balances;
// Operator Functions
mapping (address => mapping(address => bool)) internal operators;
/***********************************|
| Public Transfer Functions |
|__________________________________*/
/**
* @notice Transfers amount amount of an _id from the _from address to the _to address specified
* @param _from Source address
* @param _to Target address
* @param _id ID of the token type
* @param _amount Transfered amount
* @param _data Additional data with no specified format, sent in call to `_to`
*/
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data)
public override
{
require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeTransferFrom: INVALID_OPERATOR");
require(_to != address(0),"ERC1155#safeTransferFrom: INVALID_RECIPIENT");
// require(_amount <= balances[_from][_id]) is not necessary since checked with safemath operations
_safeTransferFrom(_from, _to, _id, _amount);
_callonERC1155Received(_from, _to, _id, _amount, gasleft(), _data);
}
/**
* @notice Send multiple types of Tokens from the _from address to the _to address (with safety call)
* @param _from Source addresses
* @param _to Target addresses
* @param _ids IDs of each token type
* @param _amounts Transfer amounts per token type
* @param _data Additional data with no specified format, sent in call to `_to`
*/
function safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data)
public override
{
// Requirements
require((msg.sender == _from) || isApprovedForAll(_from, msg.sender), "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR");
require(_to != address(0), "ERC1155#safeBatchTransferFrom: INVALID_RECIPIENT");
_safeBatchTransferFrom(_from, _to, _ids, _amounts);
_callonERC1155BatchReceived(_from, _to, _ids, _amounts, gasleft(), _data);
}
/***********************************|
| Internal Transfer Functions |
|__________________________________*/
/**
* @notice Transfers amount amount of an _id from the _from address to the _to address specified
* @param _from Source address
* @param _to Target address
* @param _id ID of the token type
* @param _amount Transfered amount
*/
function _safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount)
internal
{
// Update balances
balances[_from][_id] = balances[_from][_id].sub(_amount); // Subtract amount
balances[_to][_id] = balances[_to][_id].add(_amount); // Add amount
// Emit event
emit TransferSingle(msg.sender, _from, _to, _id, _amount);
}
/**
* @notice Verifies if receiver is contract and if so, calls (_to).onERC1155Received(...)
*/
function _callonERC1155Received(address _from, address _to, uint256 _id, uint256 _amount, uint256 /*_gasLimit*/, bytes memory _data)
internal
{
if (_to.isContract()) {
try IERC1155Receiver(_to).onERC1155Received(msg.sender, _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");
}
}
}
/**
* @notice Send multiple types of Tokens from the _from address to the _to address (with safety call)
* @param _from Source addresses
* @param _to Target addresses
* @param _ids IDs of each token type
* @param _amounts Transfer amounts per token type
*/
function _safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts)
internal
{
require(_ids.length == _amounts.length, "ERC1155#_safeBatchTransferFrom: INVALID_ARRAYS_LENGTH");
// Number of transfer to execute
uint256 nTransfer = _ids.length;
// Executing all transfers
for (uint256 i = 0; i < nTransfer; i++) {
// Update storage balance of previous bin
balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(_amounts[i]);
balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]);
}
// Emit event
emit TransferBatch(msg.sender, _from, _to, _ids, _amounts);
}
/**
* @notice Verifies if receiver is contract and if so, calls (_to).onERC1155BatchReceived(...)
*/
function _callonERC1155BatchReceived(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, uint256 /*_gasLimit*/, bytes memory _data)
internal
{
if (_to.isContract()) {
try IERC1155Receiver(_to).onERC1155BatchReceived(msg.sender, _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");
}
}
// Pass data if recipient is contract
// if (_to.isContract()) {
// bytes4 retval = IERC1155Receiver(_to).onERC1155BatchReceived{gas: _gasLimit}(msg.sender, _from, _ids, _amounts, _data);
// require(retval == ERC1155_BATCH_RECEIVED_VALUE, "ERC1155#_callonERC1155BatchReceived: INVALID_ON_RECEIVE_MESSAGE");
// }
}
/***********************************|
| Operator Functions |
|__________________________________*/
/**
* @notice Enable or disable approval for a third party ("operator") to manage all of caller's tokens
* @param _operator Address to add to the set of authorized operators
* @param _approved True if the operator is approved, false to revoke approval
*/
function setApprovalForAll(address _operator, bool _approved)
external override
{
// Update operator status
operators[msg.sender][_operator] = _approved;
emit ApprovalForAll(msg.sender, _operator, _approved);
}
/**
* @notice Queries the approval status of an operator for a given owner
* @param _owner The owner of the Tokens
* @param _operator Address of authorized operator
* @return isOperator True if the operator is approved, false if not
*/
function isApprovedForAll(address _owner, address _operator)
public virtual override view returns (bool isOperator)
{
return operators[_owner][_operator];
}
/***********************************|
| Balance Functions |
|__________________________________*/
/**
* @notice Get the balance of an account's Tokens
* @param _owner The address of the token holder
* @param _id ID of the Token
* @return The _owner's balance of the Token type requested
*/
function balanceOf(address _owner, uint256 _id)
public override view returns (uint256)
{
return balances[_owner][_id];
}
/**
* @notice Get the balance of multiple account/token pairs
* @param _owners The addresses of the token holders
* @param _ids ID of the Tokens
* @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)
*/
function balanceOfBatch(address[] memory _owners, uint256[] memory _ids)
public override view returns (uint256[] memory)
{
require(_owners.length == _ids.length, "ERC1155#balanceOfBatch: INVALID_ARRAY_LENGTH");
// Variables
uint256[] memory batchBalances = new uint256[](_owners.length);
// Iterate over each owner and token ID
for (uint256 i = 0; i < _owners.length; i++) {
batchBalances[i] = balances[_owners[i]][_ids[i]];
}
return batchBalances;
}
/***********************************|
| ERC165 Functions |
|__________________________________*/
/**
* @notice Query if a contract implements an interface
* @param _interfaceID The interface identifier, as specified in ERC-165
* @return `true` if the contract implements `_interfaceID` and
*/
function supportsInterface(bytes4 _interfaceID) public override(ERC165) virtual view returns (bool) {
if (_interfaceID == type(IERC1155).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
}
IERC1155.sol 106 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
interface IERC1155 {
/****************************************|
| Events |
|_______________________________________*/
/**
* @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, including zero amount transfers as well as minting or burning
* Operator MUST be msg.sender
* When minting/creating tokens, the `_from` field MUST be set to `0x0`
* When burning/destroying tokens, the `_to` field MUST be set to `0x0`
* The total amount transferred from address 0x0 minus the total amount transferred to 0x0 may be used by clients and exchanges to be added to the "circulating supply" for a given token ID
* To broadcast the existence of a token ID with no initial balance, the contract SHOULD emit the TransferSingle event from `0x0` to `0x0`, with the token creator as `_operator`, and a `_amount` of 0
*/
event TransferSingle(address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _amount);
/**
* @dev Either TransferSingle or TransferBatch MUST emit when tokens are transferred, including zero amount transfers as well as minting or burning
* Operator MUST be msg.sender
* When minting/creating tokens, the `_from` field MUST be set to `0x0`
* When burning/destroying tokens, the `_to` field MUST be set to `0x0`
* The total amount transferred from address 0x0 minus the total amount transferred to 0x0 may be used by clients and exchanges to be added to the "circulating supply" for a given token ID
* To broadcast the existence of multiple token IDs with no initial balance, this SHOULD emit the TransferBatch event from `0x0` to `0x0`, with the token creator as `_operator`, and a `_amount` of 0
*/
event TransferBatch(address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _amounts);
/**
* @dev MUST emit when an approval is updated
*/
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
/****************************************|
| Functions |
|_______________________________________*/
/**
* @notice Transfers amount of an _id from the _from address to the _to address specified
* @dev MUST emit TransferSingle event on success
* Caller must be approved to manage the _from account's tokens (see isApprovedForAll)
* MUST throw if `_to` is the zero address
* MUST throw if balance of sender for token `_id` is lower than the `_amount` sent
* MUST throw on any other error
* When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155Received` on `_to` and revert if the return amount is not `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* @param _from Source address
* @param _to Target address
* @param _id ID of the token type
* @param _amount Transfered amount
* @param _data Additional data with no specified format, sent in call to `_to`
*/
function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes calldata _data) external;
/**
* @notice Send multiple types of Tokens from the _from address to the _to address (with safety call)
* @dev MUST emit TransferBatch event on success
* Caller must be approved to manage the _from account's tokens (see isApprovedForAll)
* MUST throw if `_to` is the zero address
* MUST throw if length of `_ids` is not the same as length of `_amounts`
* MUST throw if any of the balance of sender for token `_ids` is lower than the respective `_amounts` sent
* MUST throw on any other error
* When transfer is complete, this function MUST check if `_to` is a smart contract (code size > 0). If so, it MUST call `onERC1155BatchReceived` on `_to` and revert if the return amount is not `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* Transfers and events MUST occur in the array order they were submitted (_ids[0] before _ids[1], etc)
* @param _from Source addresses
* @param _to Target addresses
* @param _ids IDs of each token type
* @param _amounts Transfer amounts per token type
* @param _data Additional data with no specified format, sent in call to `_to`
*/
function safeBatchTransferFrom(address _from, address _to, uint256[] calldata _ids, uint256[] calldata _amounts, bytes calldata _data) external;
/**
* @notice Get the balance of an account's Tokens
* @param _owner The address of the token holder
* @param _id ID of the Token
* @return The _owner's balance of the Token type requested
*/
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
/**
* @notice Get the balance of multiple account/token pairs
* @param _owners The addresses of the token holders
* @param _ids ID of the Tokens
* @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)
*/
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids) external view returns (uint256[] memory);
/**
* @notice Enable or disable approval for a third party ("operator") to manage all of caller's tokens
* @dev MUST emit the ApprovalForAll event on success
* @param _operator Address to add to the set of authorized operators
* @param _approved True if the operator is approved, false to revoke approval
*/
function setApprovalForAll(address _operator, bool _approved) external;
/**
* @notice Queries the approval status of an operator for a given owner
* @param _owner The owner of the Tokens
* @param _operator Address of authorized operator
* @return isOperator True if the operator is approved, false if not
*/
function isApprovedForAll(address _owner, address _operator) external view returns (bool isOperator);
}
ERC1155Metadata.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC1155Metadata.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
/**
* @notice Contract that handles metadata related methods.
* @dev Methods assume a deterministic generation of URI based on token IDs.
* Methods also assume that URI uses hex representation of token IDs.
*/
contract ERC1155Metadata is IERC1155Metadata, ERC165 {
// URI's default URI prefix
string internal baseMetadataURI;
/***********************************|
| Metadata Public Function s |
|__________________________________*/
/**
* @notice A distinct Uniform Resource Identifier (URI) for a given token.
* @dev URIs are defined in RFC 3986.
* URIs are assumed to be deterministically generated based on token ID
* @return URI string
*/
function uri(uint256 _id) public virtual override view returns (string memory) {
return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json"));
}
/**
* @notice Will update the base URL of token's URI
* @param _newBaseMetadataURI New base URL of token's URI
*/
function _setBaseMetadataURI(string memory _newBaseMetadataURI) internal {
baseMetadataURI = _newBaseMetadataURI;
}
/**
* @notice Query if a contract implements an interface
* @param _interfaceID The interface identifier, as specified in ERC-165
* @return `true` if the contract implements `_interfaceID` and
*/
function supportsInterface(bytes4 _interfaceID) public override virtual view returns (bool) {
if (_interfaceID == type(IERC1155Metadata).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
/***********************************|
| Utility Internal Functions |
|__________________________________*/
/**
* @notice Convert uint256 to string
* @param _i Unsigned integer to convert to string
*/
function _uint2str(uint256 _i) internal pure returns (string memory _uintAsString) {
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 ii = _i;
uint256 len;
// Get number of bytes
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
// Get each individual ASCII
while (ii != 0) {
bstr[k--] = bytes1(uint8(48 + ii % 10));
ii /= 10;
}
// Convert to string
return string(bstr);
}
}
ERC1155MintBurn.sol 109 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC1155.sol";
/**
* @dev Multi-Fungible Tokens with minting and burning methods. These methods assume
* a parent contract to be executed as they are `internal` functions
*/
contract ERC1155MintBurn is ERC1155 {
using SafeMath for uint256;
/****************************************|
| Minting Functions |
|_______________________________________*/
/**
* @notice Mint _amount of tokens of a given id
* @param _to The address to mint tokens to
* @param _id Token id to mint
* @param _amount The amount to be minted
* @param _data Data to pass if receiver is contract
*/
function _mint(address _to, uint256 _id, uint256 _amount, bytes memory _data)
internal
{
// Add _amount
balances[_to][_id] = balances[_to][_id].add(_amount);
// Emit event
emit TransferSingle(msg.sender, address(0x0), _to, _id, _amount);
// Calling onReceive method if recipient is contract
_callonERC1155Received(address(0x0), _to, _id, _amount, gasleft(), _data);
}
/**
* @notice Mint tokens for each ids in _ids
* @param _to The address to mint tokens to
* @param _ids Array of ids to mint
* @param _amounts Array of amount of tokens to mint per id
* @param _data Data to pass if receiver is contract
*/
function _batchMint(address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data)
internal
{
require(_ids.length == _amounts.length, "ERC1155MintBurn#batchMint: INVALID_ARRAYS_LENGTH");
// Number of mints to execute
uint256 nMint = _ids.length;
// Executing all minting
for (uint256 i = 0; i < nMint; i++) {
// Update storage balance
balances[_to][_ids[i]] = balances[_to][_ids[i]].add(_amounts[i]);
}
// Emit batch mint event
emit TransferBatch(msg.sender, address(0x0), _to, _ids, _amounts);
// Calling onReceive method if recipient is contract
_callonERC1155BatchReceived(address(0x0), _to, _ids, _amounts, gasleft(), _data);
}
/****************************************|
| Burning Functions |
|_______________________________________*/
/**
* @notice Burn _amount of tokens of a given token id
* @param _from The address to burn tokens from
* @param _id Token id to burn
* @param _amount The amount to be burned
*/
function _burn(address _from, uint256 _id, uint256 _amount)
internal
{
//Substract _amount
balances[_from][_id] = balances[_from][_id].sub(_amount);
// Emit event
emit TransferSingle(msg.sender, _from, address(0x0), _id, _amount);
}
/**
* @notice Burn tokens of given token id for each (_ids[i], _amounts[i]) pair
* @param _from The address to burn tokens from
* @param _ids Array of token ids to burn
* @param _amounts Array of the amount to be burned
*/
function _batchBurn(address _from, uint256[] memory _ids, uint256[] memory _amounts)
internal
{
// Number of mints to execute
uint256 nBurn = _ids.length;
require(nBurn == _amounts.length, "ERC1155MintBurn#batchBurn: INVALID_ARRAYS_LENGTH");
// Executing all minting
for (uint256 i = 0; i < nBurn; i++) {
// Update storage balance
balances[_from][_ids[i]] = balances[_from][_ids[i]].sub(_amounts[i]);
}
// Emit batch mint event
emit TransferBatch(msg.sender, _from, address(0x0), _ids, _amounts);
}
}
ERC1155Tradable.sol 246 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Strings.sol";
import './IERC1155Tradable.sol';
import './ERC1155.sol';
import './ERC1155Metadata.sol';
import './ERC1155MintBurn.sol';
import "../Ownable.sol";
contract OwnableDelegateProxy { }
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
}
/**
* @title ERC1155Tradable
* ERC1155Tradable - ERC1155 contract that whitelists an operator address, has create and mint functionality, and supports useful standards from OpenZeppelin,
like _exists(), name(), symbol(), and totalSupply()
*/
contract ERC1155Tradable is IERC1155Tradable, ERC1155, ERC1155MintBurn, ERC1155Metadata, Ownable {
using Strings for uint256;
address proxyRegistryAddress;
uint256 private _currentTokenID;
mapping (uint256 => address) public creators;
mapping (uint256 => uint256) public tokenSupply;
mapping(address => bool) public isAllowedToCreate;
// Contract name
string public name;
// Contract symbol
string public symbol;
/**
* @dev Require_msgSender() to be the creator of the token id
*/
modifier creatorOnly(uint256 _id) {
require(creators[_id] ==_msgSender() && isAllowedToCreate[_msgSender()], "ERC1155Tradable#creatorOnly: ONLY_CREATOR_ALLOWED");
_;
}
/**
* @dev Require_msgSender() to own more than 0 of the token id
*/
modifier ownersOnly(uint256 _id) {
require(balances[msg.sender][_id] > 0, "ERC1155Tradable#ownersOnly: ONLY_OWNERS_ALLOWED");
_;
}
constructor(
string memory _name,
string memory _symbol,
string memory _metadataURI,
address _proxyRegistryAddress,
address owner
) Ownable(owner) {
name = _name;
symbol = _symbol;
proxyRegistryAddress = _proxyRegistryAddress;
isAllowedToCreate[owner] = true;
_setBaseMetadataURI(_metadataURI);
}
function uri(
uint256 _id
) public view override returns (string memory) {
require(_exists(_id), "ERC721Tradable#uri: NONEXISTENT_TOKEN");
return bytes(baseMetadataURI).length > 0 ? string(abi.encodePacked(baseMetadataURI, _id.toString())) : "";
}
/**
* @dev Returns the total quantity for a token ID
* @param _id uint256 ID of the token to query
* @return amount of token in existence
*/
function totalSupply(
uint256 _id
) public view returns (uint256) {
return tokenSupply[_id];
}
/**
* @dev Will update the base URL of token's URI
* @param _newBaseMetadataURI New base URL of token's URI
*/
function setBaseMetadataURI(
string memory _newBaseMetadataURI
) public onlyOwner {
_setBaseMetadataURI(_newBaseMetadataURI);
}
/**
* @dev Sets address allowed to create
* @param _account account to allow/disallow
* @param _allow true to allow, false to remove
*/
function setAllowToCreate(address _account, bool _allow) public onlyOwner {
isAllowedToCreate[_account] = _allow;
}
/**
* @dev Creates a new token type and assigns _initialSupply to an address
* NOTE: remove onlyOwner if you want third parties to create new tokens on your contract (which may change your IDs)
* @param _initialOwner address of the first owner of the token
* @param _initialSupply amount to supply the first owner
* @return The newly created token ID
*/
function create(
address _initialOwner,
uint256 _initialSupply
) external override returns (uint256) {
require(isAllowedToCreate[_msgSender()], "Not allowed");
uint256 _id = getNextTokenID();
_incrementTokenTypeId();
creators[_id] =_msgSender();
_mint(_initialOwner, _id, _initialSupply, "");
tokenSupply[_id] = _initialSupply;
return _id;
}
/**
* @dev Mints some amount of tokens to an address
* @param _to Address of the future owner of the token
* @param _id Token ID to mint
* @param _quantity Amount of tokens to mint
*/
function mint(
address _to,
uint256 _id,
uint256 _quantity
) public override creatorOnly(_id) {
_mint(_to, _id, _quantity, "");
tokenSupply[_id] += _quantity;
}
/**
* @dev Mint tokens for each id in _ids
* @param _to The address to mint tokens to
* @param _ids Array of ids to mint
* @param _quantities Array of amounts of tokens to mint per id
*/
function batchMint(
address _to,
uint256[] memory _ids,
uint256[] memory _quantities
) public override {
for (uint256 i = 0; i < _ids.length; i++) {
uint256 _id = _ids[i];
require(creators[_id] ==_msgSender(), "ERC1155Tradable#batchMint: ONLY_CREATOR_ALLOWED");
uint256 quantity = _quantities[i];
tokenSupply[_id] += quantity;
}
_batchMint(_to, _ids, _quantities, "");
}
/**
* @dev Change the creator address for given tokens
* @param _to Address of the new creator
* @param _ids Array of Token IDs to change creator
*/
function setCreator(
address _to,
uint256[] memory _ids
) public override {
require(_to != address(0), "ERC1155Tradable#setCreator: INVALID_ADDRESS.");
for (uint256 i = 0; i < _ids.length; i++) {
uint256 id = _ids[i];
_setCreator(_to, id);
}
}
/**
* Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings.
*/
function isApprovedForAll(
address _owner,
address _operator
) public override(ERC1155, IERC1155) view returns (bool isOperator) {
// Whitelist OpenSea proxy contract for easy trading.
ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
if (address(proxyRegistry.proxies(_owner)) == _operator) {
return true;
}
return ERC1155.isApprovedForAll(_owner, _operator);
}
/**
* @dev Change the creator address for given token
* @param _to Address of the new creator
* @param _id Token IDs to change creator of
*/
function _setCreator(address _to, uint256 _id) internal creatorOnly(_id)
{
creators[_id] = _to;
}
/**
* @dev Returns whether the specified token exists by checking to see if it has a creator
* @param _id uint256 ID of the token to query the existence of
* @return bool whether the token exists
*/
function _exists(
uint256 _id
) internal view returns (bool) {
return creators[_id] != address(0);
}
/**
* @dev calculates the next token ID based on value of _currentTokenID
* @return uint256 for the next token ID
*/
function getNextTokenID() public view returns (uint256) {
return _currentTokenID + 1;
}
/**
* @dev increments the value of _currentTokenID
*/
function _incrementTokenTypeId() private {
_currentTokenID++;
}
/***********************************|
| ERC165 Functions |
|__________________________________*/
/**
* @notice Query if a contract implements an interface
* @param _interfaceID The interface identifier, as specified in ERC-165
* @return `true` if the contract implements `_interfaceID` and
*/
function supportsInterface(bytes4 _interfaceID) public override(ERC1155, ERC1155Metadata) virtual view returns (bool) {
if (_interfaceID == type(IERC1155).interfaceId || _interfaceID == type(IERC1155Tradable).interfaceId) {
return true;
}
return super.supportsInterface(_interfaceID);
}
}
IERC1155Metadata.sol 20 lines
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
interface IERC1155Metadata {
event URI(string _uri, uint256 indexed _id);
/****************************************|
| Functions |
|_______________________________________*/
/**
* @notice A distinct Uniform Resource Identifier (URI) for a given token.
* @dev URIs are defined in RFC 3986.
* URIs are assumed to be deterministically generated based on token ID
* Token IDs are assumed to be represented in their hex format in URIs
* @return URI string
*/
function uri(uint256 _id) external view returns (string memory);
}
IERC1155Tradable.sol 15 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC1155.sol";
interface IERC1155Tradable is IERC1155 {
function create(address _initialOwner, uint256 _initialSupply) external returns (uint256);
function mint(address _to, uint256 _id, uint256 _quantity) external;
function batchMint( address _to, uint256[] memory _ids, uint256[] memory _quantities) external;
function setCreator(address _to, uint256[] memory _ids) external;
}
Address.sol 216 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @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);
}
}
}
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @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);
}
}
Context.sol 23 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;
}
}
SafeMath.sol 226 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
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 24 lines
// SPDX-License-Identifier: MIT
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);
}
IERC1155Receiver.sol 53 lines
// SPDX-License-Identifier: MIT
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.
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);
}
Read Contract
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
creators 0xcd53d08e → address
getNextTokenID 0x4a198119 → uint256
isAllowedToCreate 0x73f25c38 → bool
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenSupply 0x2693ebf2 → uint256
totalSupply 0xbd85b039 → uint256
uri 0x0e89341c → string
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
batchMint 0x0ca83480
address _to
uint256[] _ids
uint256[] _quantities
create 0x0ecaea73
address _initialOwner
uint256 _initialSupply
returns: uint256
mint 0x156e29f6
address _to
uint256 _id
uint256 _quantity
safeBatchTransferFrom 0x2eb2c2d6
address _from
address _to
uint256[] _ids
uint256[] _amounts
bytes _data
safeTransferFrom 0xf242432a
address _from
address _to
uint256 _id
uint256 _amount
bytes _data
setAllowToCreate 0xd79cd255
address _account
bool _allow
setApprovalForAll 0xa22cb465
address _operator
bool _approved
setBaseMetadataURI 0x7e518ec8
string _newBaseMetadataURI
setCreator 0xd2a6b51a
address _to
uint256[] _ids
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address