Address Contract Verified
Address
0xe45662F0F2E3763F95D616186808CF5f6aD7702A
Balance
0 ETH
Nonce
1
Code Size
10354 bytes
Creator
0x238033Db...cdd3 at tx 0x574e32ce...66fc2b
Indexed Transactions
0
Contract Bytecode
10354 bytes
0x608060405234801561001057600080fd5b50600436106101365760003560e01c806382457e83116100b8578063abc8c7af1161007c578063abc8c7af146102db578063c86a9d4a146102ee578063e47d087114610301578063e985e9c514610314578063f242432a14610350578063f2fde38b1461036357600080fd5b806382457e831461026a5780638da5cb5b1461027d5780639e047ec1146102a2578063a22cb465146102b5578063a2bf68b9146102c857600080fd5b806350944a8f116100ff57806350944a8f146101d95780636f1a0af514610209578063715018a61461022957806373ad6c2d1461023157806375794a3c1461026157600080fd5b8062fdd58e1461013b57806301ffc9a7146101615780630e89341c146101845780632eb2c2d6146101a45780634e1273f4146101b9575b600080fd5b61014e610149366004611ae2565b610376565b6040519081526020015b60405180910390f35b61017461016f366004611b22565b61040f565b6040519015158152602001610158565b610197610192366004611b46565b61045f565b6040516101589190611ba5565b6101b76101b2366004611d04565b610501565b005b6101cc6101c7366004611e1b565b61054d565b6040516101589190611eba565b6101b76101e7366004611ecd565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b61021c610217366004611b46565b610677565b6040516101589190611f57565b6101b7610844565b6101b761023f366004611ecd565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b61014e60045481565b61014e610278366004612038565b610858565b6003546001600160a01b03165b6040516001600160a01b039091168152602001610158565b6101b76102b0366004612096565b610919565b6101b76102c33660046120e6565b610989565b60075461028a906001600160a01b031681565b60085461028a906001600160a01b031681565b61014e6102fc36600461211d565b610998565b6101b761030f366004612250565b610dfa565b61017461032236600461228c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205460ff1690565b6101b761035e3660046122bf565b610e69565b6101b7610371366004611ecd565b610eae565b60006001600160a01b0383166103e65760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201526930b634b21037bbb732b960b11b60648201526084015b60405180910390fd5b506000818152602081815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b03198216636cdb3d1360e11b148061044057506001600160e01b031982166303a24d0760e21b145b8061040957506301ffc9a760e01b6001600160e01b0319831614610409565b600081815260056020526040902080546060919061047c90612324565b80601f01602080910402602001604051908101604052809291908181526020018280546104a890612324565b80156104f55780601f106104ca576101008083540402835291602001916104f5565b820191906000526020600020905b8154815290600101906020018083116104d857829003601f168201915b50505050509050919050565b6001600160a01b03851633148061051d575061051d8533610322565b6105395760405162461bcd60e51b81526004016103dd9061235e565b6105468585858585610f27565b5050505050565b606081518351146105b25760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e677468604482015268040dad2e6dac2e8c6d60bb1b60648201526084016103dd565b6000835167ffffffffffffffff8111156105ce576105ce611bb8565b6040519080825280602002602001820160405280156105f7578160200160208202803683370190505b50905060005b845181101561066f5761064285828151811061061b5761061b6123ac565b6020026020010151858381518110610635576106356123ac565b6020026020010151610376565b828281518110610654576106546123ac565b6020908102919091010152610668816123d8565b90506105fd565b509392505050565b604080516101408101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e0820181905261010082015261012081019190915260008281526006602090815260409182902082516101408101845281548152600182015463ffffffff808216838601526001600160a01b03640100000000830481168488015260ff600160c01b8404811615156060860152600160c81b84041615156080850152600160d01b9092041660a083015260028301541660c08201526003820180548551818602810186019096528086529194929360e086019392908301828280156107a057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610782575b505050505081526020016004820180548060200260200160405190810160405280929190818152602001828054801561082457602002820191906000526020600020906000905b82829054906101000a900463ffffffff1663ffffffff16815260200190600401906020826003010492830192600103820291508084116107e75790505b50505091835250506005919091015460ff16151560209091015292915050565b61084c611112565b610856600061116c565b565b6007546000906001600160a01b031633146108a85760405162461bcd60e51b815260206004820152601060248201526f04e6f742061206d656d626572736869760841b60448201526064016103dd565b60006108b58585856111be565b60008181526006602052604090208181556001808201805460ff60c01b196001600160a01b038b16640100000000026001600160c01b031990921663ffffffff8a1617919091171690556005909101805460ff191690911790559150509392505050565b6008546001600160a01b031633146109675760405162461bcd60e51b81526020600482015260116024820152704e6f742061206d61726b6574706c61636560781b60448201526064016103dd565b610983848484846040518060200160405280600081525061122b565b50505050565b610994338383611363565b5050565b6008546000906001600160a01b031633146109e95760405162461bcd60e51b81526020600482015260116024820152704e6f742061206d61726b6574706c61636560781b60448201526064016103dd565b82518251808214610a3c5760405162461bcd60e51b815260206004820152601960248201527f526563697069656e747320213d2070657263656e74616765730000000000000060448201526064016103dd565b836000805b8251811015610a8357828181518110610a5c57610a5c6123ac565b602002602001015182610a6f91906123f1565b915080610a7b816123d8565b915050610a41565b506127108163ffffffff161115610adc5760405162461bcd60e51b815260206004820152601e60248201527f4665652070657263656e746167657320657863656564206d6178696d756d000060448201526064016103dd565b6001600160a01b03881615610b47576127108963ffffffff1610610b425760405162461bcd60e51b815260206004820152601b60248201527f4665652063616e2774206265206d6f7265207468656e2031303025000000000060448201526064016103dd565b610b9b565b63ffffffff891615610b9b5760405162461bcd60e51b815260206004820152601a60248201527f47616c6c657279206665652063616e27742061737369676e656400000000000060448201526064016103dd565b6000610ba88d8d8d6111be565b90506040518061014001604052808281526020018c63ffffffff1681526020018e6001600160a01b0316815260200160011515815260200160006001600160a01b03168b6001600160a01b03161415151581526020018b63ffffffff1681526020018a6001600160a01b0316815260200189815260200188815260200160001515815250600660008381526020019081526020016000206000820151816000015560208201518160010160006101000a81548163ffffffff021916908363ffffffff16021790555060408201518160010160046101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160010160186101000a81548160ff02191690831515021790555060808201518160010160196101000a81548160ff02191690831515021790555060a082015181600101601a6101000a81548163ffffffff021916908363ffffffff16021790555060c08201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060e0820151816003019080519060200190610d4d9291906119a6565b506101008201518051610d6a916004840191602090910190611a0b565b506101208201518160050160006101000a81548160ff0219169083151502179055509050507f041b7d65461f6f51e8fd92623a3848b22ce7077c215e4ea064d790e9efa08b8f818c8f60006001600160a01b03168d6001600160a01b031614158e8e8e8e604051610de2989796959493929190612415565b60405180910390a19c9b505050505050505050505050565b6007546001600160a01b03163314610e475760405162461bcd60e51b815260206004820152601060248201526f04e6f742061206d656d626572736869760841b60448201526064016103dd565b610e6483838360016040518060200160405280600081525061122b565b505050565b6001600160a01b038516331480610e855750610e858533610322565b610ea15760405162461bcd60e51b81526004016103dd9061235e565b610546858585858561122b565b610eb6611112565b6001600160a01b038116610f1b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103dd565b610f248161116c565b50565b8151835114610f895760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b60648201526084016103dd565b6001600160a01b038416610faf5760405162461bcd60e51b81526004016103dd90612488565b33610fbe818787878787611443565b60005b84518110156110a4576000858281518110610fde57610fde6123ac565b602002602001015190506000858381518110610ffc57610ffc6123ac565b602090810291909101810151600084815280835260408082206001600160a01b038e16835290935291909120549091508181101561104c5760405162461bcd60e51b81526004016103dd906124cd565b6000838152602081815260408083206001600160a01b038e8116855292528083208585039055908b16825281208054849290611089908490612517565b925050819055505050508061109d906123d8565b9050610fc1565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516110f492919061252a565b60405180910390a461110a81878787878761162b565b505050505050565b6003546001600160a01b031633146108565760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103dd565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60006111e3846004548463ffffffff1660405180602001604052806000815250611786565b60045460009081526005602052604090206111fe848261259e565b506004805490600061120f836123d8565b91905055506001600454611223919061265e565b949350505050565b6001600160a01b0384166112515760405162461bcd60e51b81526004016103dd90612488565b33600061125d856118a0565b9050600061126a856118a0565b905061127a838989858589611443565b6000868152602081815260408083206001600160a01b038c168452909152902054858110156112bb5760405162461bcd60e51b81526004016103dd906124cd565b6000878152602081815260408083206001600160a01b038d8116855292528083208985039055908a168252812080548892906112f8908490612517565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611358848a8a8a8a8a6118eb565b505050505050505050565b816001600160a01b0316836001600160a01b0316036113d65760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604482015268103337b91039b2b63360b91b60648201526084016103dd565b6001600160a01b03838116600081815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6008546001600160a01b0387811691161480159061146f57506007546001600160a01b03878116911614155b1561110a5760005b8351811015611622576008546001600160a01b031615801590611525575060085484516001600160a01b039091169063f9143287908690849081106114be576114be6123ac565b60200260200101516040518263ffffffff1660e01b81526004016114e491815260200190565b602060405180830381865afa158015611501573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115259190612671565b1561157e5760405162461bcd60e51b8152602060048201526024808201527f41756374696f6e656420746f6b656e2063616e2774206265207472616e7366656044820152631c9c995960e21b60648201526084016103dd565b60066000858381518110611594576115946123ac565b60209081029190910181015182528101919091526040016000206005015460ff16156116105760405162461bcd60e51b815260206004820152602560248201527f4d656d6265727368697020746f6b656e2063616e2774206265207472616e7366604482015264195c9c995960da1b60648201526084016103dd565b8061161a816123d8565b915050611477565b50505050505050565b6001600160a01b0384163b1561110a5760405163bc197c8160e01b81526001600160a01b0385169063bc197c819061166f908990899088908890889060040161268e565b6020604051808303816000875af19250505080156116aa575060408051601f3d908101601f191682019092526116a7918101906126ec565b60015b611756576116b6612709565b806308c379a0036116ef57506116ca612725565b806116d557506116f1565b8060405162461bcd60e51b81526004016103dd9190611ba5565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e2d455243313135356044820152732932b1b2b4bb32b91034b6b83632b6b2b73a32b960611b60648201526084016103dd565b6001600160e01b0319811663bc197c8160e01b146116225760405162461bcd60e51b81526004016103dd906127af565b6001600160a01b0384166117e65760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b60648201526084016103dd565b3360006117f2856118a0565b905060006117ff856118a0565b905061181083600089858589611443565b6000868152602081815260408083206001600160a01b038b16845290915281208054879290611840908490612517565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4611622836000898989896118eb565b604080516001808252818301909252606091600091906020808301908036833701905050905082816000815181106118da576118da6123ac565b602090810291909101015292915050565b6001600160a01b0384163b1561110a5760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061192f90899089908890889088906004016127f7565b6020604051808303816000875af192505050801561196a575060408051601f3d908101601f19168201909252611967918101906126ec565b60015b611976576116b6612709565b6001600160e01b0319811663f23a6e6160e01b146116225760405162461bcd60e51b81526004016103dd906127af565b8280548282559060005260206000209081019282156119fb579160200282015b828111156119fb57825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906119c6565b50611a07929150611ab1565b5090565b828054828255906000526020600020906007016008900481019282156119fb5791602002820160005b83821115611a7857835183826101000a81548163ffffffff021916908363ffffffff1602179055509260200192600401602081600301049283019260010302611a34565b8015611aa85782816101000a81549063ffffffff0219169055600401602081600301049283019260010302611a78565b5050611a079291505b5b80821115611a075760008155600101611ab2565b80356001600160a01b0381168114611add57600080fd5b919050565b60008060408385031215611af557600080fd5b611afe83611ac6565b946020939093013593505050565b6001600160e01b031981168114610f2457600080fd5b600060208284031215611b3457600080fd5b8135611b3f81611b0c565b9392505050565b600060208284031215611b5857600080fd5b5035919050565b6000815180845260005b81811015611b8557602081850181015186830182015201611b69565b506000602082860101526020601f19601f83011685010191505092915050565b602081526000611b3f6020830184611b5f565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff81118282101715611bf457611bf4611bb8565b6040525050565b600067ffffffffffffffff821115611c1557611c15611bb8565b5060051b60200190565b600082601f830112611c3057600080fd5b81356020611c3d82611bfb565b604051611c4a8282611bce565b83815260059390931b8501820192828101915086841115611c6a57600080fd5b8286015b84811015611c855780358352918301918301611c6e565b509695505050505050565b600082601f830112611ca157600080fd5b813567ffffffffffffffff811115611cbb57611cbb611bb8565b604051611cd2601f8301601f191660200182611bce565b818152846020838601011115611ce757600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a08688031215611d1c57600080fd5b611d2586611ac6565b9450611d3360208701611ac6565b9350604086013567ffffffffffffffff80821115611d5057600080fd5b611d5c89838a01611c1f565b94506060880135915080821115611d7257600080fd5b611d7e89838a01611c1f565b93506080880135915080821115611d9457600080fd5b50611da188828901611c90565b9150509295509295909350565b600082601f830112611dbf57600080fd5b81356020611dcc82611bfb565b604051611dd98282611bce565b83815260059390931b8501820192828101915086841115611df957600080fd5b8286015b84811015611c8557611e0e81611ac6565b8352918301918301611dfd565b60008060408385031215611e2e57600080fd5b823567ffffffffffffffff80821115611e4657600080fd5b611e5286838701611dae565b93506020850135915080821115611e6857600080fd5b50611e7585828601611c1f565b9150509250929050565b600081518084526020808501945080840160005b83811015611eaf57815187529582019590820190600101611e93565b509495945050505050565b602081526000611b3f6020830184611e7f565b600060208284031215611edf57600080fd5b611b3f82611ac6565b600081518084526020808501945080840160005b83811015611eaf5781516001600160a01b031687529582019590820190600101611efc565b600081518084526020808501945080840160005b83811015611eaf57815163ffffffff1687529582019590820190600101611f35565b602081528151602082015260006020830151611f7b604084018263ffffffff169052565b5060408301516001600160a01b0381166060840152506060830151801515608084015250608083015180151560a08401525060a083015163ffffffff811660c08401525060c08301516001600160a01b03811660e08401525060e08301516101406101008181860152611ff2610160860184611ee8565b9250808601519050610120601f1986850301818701526120128483611f21565b96015115159190940152509192915050565b803563ffffffff81168114611add57600080fd5b60008060006060848603121561204d57600080fd5b61205684611ac6565b9250602084013567ffffffffffffffff81111561207257600080fd5b61207e86828701611c90565b92505061208d60408501612024565b90509250925092565b600080600080608085870312156120ac57600080fd5b6120b585611ac6565b93506120c360208601611ac6565b93969395505050506040820135916060013590565b8015158114610f2457600080fd5b600080604083850312156120f957600080fd5b61210283611ac6565b91506020830135612112816120d8565b809150509250929050565b600080600080600080600060e0888a03121561213857600080fd5b61214188611ac6565b965060208089013567ffffffffffffffff8082111561215f57600080fd5b61216b8c838d01611c90565b985061217960408c01612024565b975061218760608c01612024565b965061219560808c01611ac6565b955060a08b01359150808211156121ab57600080fd5b6121b78c838d01611dae565b945060c08b01359150808211156121cd57600080fd5b508901601f81018b136121df57600080fd5b80356121ea81611bfb565b6040516121f78282611bce565b82815260059290921b830184019184810191508d83111561221757600080fd5b928401925b8284101561223c5761222d84612024565b8252928401929084019061221c565b809550505050505092959891949750929550565b60008060006060848603121561226557600080fd5b61226e84611ac6565b925061227c60208501611ac6565b9150604084013590509250925092565b6000806040838503121561229f57600080fd5b6122a883611ac6565b91506122b660208401611ac6565b90509250929050565b600080600080600060a086880312156122d757600080fd5b6122e086611ac6565b94506122ee60208701611ac6565b93506040860135925060608601359150608086013567ffffffffffffffff81111561231857600080fd5b611da188828901611c90565b600181811c9082168061233857607f821691505b60208210810361235857634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f455243313135353a2063616c6c6572206973206e6f7420746f6b656e206f776e60408201526d195c881bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016123ea576123ea6123c2565b5060010190565b63ffffffff81811683821601908082111561240e5761240e6123c2565b5092915050565b88815263ffffffff88811660208301526001600160a01b03888116604084015287151560608401529086166080830152841660a082015261010060c0820181905260009061246583820186611ee8565b905082810360e08401526124798185611f21565b9b9a5050505050505050505050565b60208082526025908201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604082015264647265737360d81b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b80820180821115610409576104096123c2565b60408152600061253d6040830185611e7f565b828103602084015261254f8185611e7f565b95945050505050565b601f821115610e6457600081815260208120601f850160051c8101602086101561257f5750805b601f850160051c820191505b8181101561110a5782815560010161258b565b815167ffffffffffffffff8111156125b8576125b8611bb8565b6125cc816125c68454612324565b84612558565b602080601f83116001811461260157600084156125e95750858301515b600019600386901b1c1916600185901b17855561110a565b600085815260208120601f198616915b8281101561263057888601518255948401946001909101908401612611565b508582101561264e5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b81810381811115610409576104096123c2565b60006020828403121561268357600080fd5b8151611b3f816120d8565b6001600160a01b0386811682528516602082015260a0604082018190526000906126ba90830186611e7f565b82810360608401526126cc8186611e7f565b905082810360808401526126e08185611b5f565b98975050505050505050565b6000602082840312156126fe57600080fd5b8151611b3f81611b0c565b600060033d11156127225760046000803e5060005160e01c5b90565b600060443d10156127335790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561276357505050505090565b828501915081518181111561277b5750505050505090565b843d87010160208285010111156127955750505050505090565b6127a460208286010187611bce565b509095945050505050565b60208082526028908201527f455243313135353a204552433131353552656365697665722072656a656374656040820152676420746f6b656e7360c01b606082015260800190565b6001600160a01b03868116825285166020820152604081018490526060810183905260a06080820181905260009061283190830184611b5f565b97965050505050505056fea26469706673582212203c08474de3bdb7addf5b5eb037ba101076079a9cb7a1ca6b3cfc76480e62d24464736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (200 runs)
AisNft.sol 205 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IMarketplace.sol";
contract AisNft is ERC1155, Ownable {
struct NftItem {
uint256 tokenId;
uint32 quantity;
address creator;
bool isListed;
bool isGallery;//new
uint32 galleryFee;
address galleryAddress;
address[] collaborators;
uint32[] collaboratorsFee;
bool isMembership;
}
uint256 public nextTokenId = 1001;
mapping(uint256 => string) _uris;
mapping(uint256 => NftItem) _idToNftItem;
address public membership;
address public marketplace;
event NftItemCreated(
uint256 tokenId, uint32 qty, address creator,
bool isGallery, uint32 galleryFee, address galleryAddress,
address[] collaborators, uint32[] collaboratorsFee
);
constructor() ERC1155("") {
}
modifier onlyMarketplace() {
require(msg.sender == marketplace, "Not a marketplace");
_;
}
modifier onlyMembership() {
require(msg.sender == membership, "Not a membership");
_;
}
modifier isFeePercentagesLessThanMaximum(uint32[] memory _feePercentages) {
uint32 totalPercent;
for (uint256 i = 0; i < _feePercentages.length; i++) {
totalPercent = totalPercent + _feePercentages[i];
}
require(totalPercent <= 10000, "Fee percentages exceed maximum");
_;
}
modifier correctFeeRecipientsAndPercentages(
uint256 _recipientsLength,
uint256 _percentagesLength
) {
require(
_recipientsLength == _percentagesLength,
"Recipients != percentages"
);
_;
}
function setMembership(address _membership) public {
membership = _membership;
}
function setMarketplace(address _marketplace) public {
marketplace = _marketplace;
}
function uri(uint256 _tokenId) override public view returns (string memory) {
return (_uris[_tokenId]);
}
function getNftItem(uint256 _tokenId) public view returns (NftItem memory){
return _idToNftItem[_tokenId];
}
function marketplaceTransfer(address from, address to, uint256 id, uint256 amount)
onlyMarketplace
external
{
_safeTransferFrom(from, to, id, amount, "");
}
function membershipTransfer(address from, address to, uint256 id)
onlyMembership
external
{
_safeTransferFrom(from, to, id, 1, "");
}
function createNftItem(
address _creator,
string memory _uri,
uint32 _quantity,
uint32 _galleryFee,
address _galleryAddress,
address[] memory _collaborators,
uint32[] memory _collaboratorsFee)
onlyMarketplace
correctFeeRecipientsAndPercentages(_collaborators.length, _collaboratorsFee.length)
isFeePercentagesLessThanMaximum(_collaboratorsFee)
external returns (uint256)
{
if (_galleryAddress != address(0)) {//new
require(_galleryFee < 10000, "Fee can't be more then 100%");
} else {
require(_galleryFee == 0, "Gallery fee can't assigned");
}
// mint
uint256 tokenId = _mintInternal(_creator, _uri, _quantity);
_idToNftItem[tokenId] = NftItem(
tokenId,
_quantity,
_creator,
true,
_galleryAddress != address(0),
_galleryFee,
_galleryAddress,
_collaborators,
_collaboratorsFee,
false
);
emit NftItemCreated(
tokenId, _quantity, _creator,
_galleryAddress != address(0), _galleryFee, _galleryAddress,
_collaborators, _collaboratorsFee
);
return tokenId;
}
function createMembershipToken(address _creator, string memory _uri, uint32 _quantity)
onlyMembership
external returns (uint256)
{
// mint
uint256 tokenId = _mintInternal(_creator, _uri, _quantity);
_idToNftItem[tokenId].tokenId = tokenId;
_idToNftItem[tokenId].quantity = _quantity;
_idToNftItem[tokenId].creator = _creator;
_idToNftItem[tokenId].isListed = false;
_idToNftItem[tokenId].isMembership = true;
return tokenId;
}
function _mintInternal(address _to, string memory _uri, uint32 _quantity) internal returns (uint256)
{
_mint(_to, nextTokenId, _quantity, "");
_uris[nextTokenId] = _uri;
nextTokenId++;
return nextTokenId - 1;
}
// overrides
/**
* @dev See {ERC1155-_beforeTokenTransfer}.
*
* Requirements:
*
* - Membership token can't be transferred beside contract
*/
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 (operator != marketplace && operator != membership) {
for (uint256 i = 0; i < ids.length; i++) {
if (marketplace != address(0) && IMarketplace(marketplace).isActiveAuction(ids[i])) {
revert("Auctioned token can't be transferred");
}
if (_idToNftItem[ids[i]].isMembership) {
revert("Membership token can't be transferred");
}
}
}
}
}
IMarketplace.sol 7 lines
pragma solidity ^0.8.13;
interface IMarketplace {
function isActiveAuction(uint256 _tokenId) external view returns (bool);
}
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;
}
}
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);
}
}
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;
}
}
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;
}
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);
}
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);
}
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);
}
Read Contract
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
getNftItem 0x6f1a0af5 → tuple
isApprovedForAll 0xe985e9c5 → bool
marketplace 0xabc8c7af → address
membership 0xa2bf68b9 → address
nextTokenId 0x75794a3c → uint256
owner 0x8da5cb5b → address
supportsInterface 0x01ffc9a7 → bool
uri 0x0e89341c → string
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
createMembershipToken 0x82457e83
address _creator
string _uri
uint32 _quantity
returns: uint256
createNftItem 0xc86a9d4a
address _creator
string _uri
uint32 _quantity
uint32 _galleryFee
address _galleryAddress
address[] _collaborators
uint32[] _collaboratorsFee
returns: uint256
marketplaceTransfer 0x9e047ec1
address from
address to
uint256 id
uint256 amount
membershipTransfer 0xe47d0871
address from
address to
uint256 id
renounceOwnership 0x715018a6
No parameters
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 id
uint256 amount
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setMarketplace 0x73ad6c2d
address _marketplace
setMembership 0x50944a8f
address _membership
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address