Address Contract Partially Verified
Address
0xc36cF0cFcb5d905B8B513860dB0CFE63F6Cf9F5c
Balance
0 ETH
Nonce
1
Code Size
11680 bytes
Creator
0x0D24dE9d...a667 at tx 0x1577e4e7...c4615f
Indexed Transactions
0
Contract Bytecode
11680 bytes
0x608060405234801561001057600080fd5b50600436106101c35760003560e01c80635e81b958116100f9578063a22cb46511610097578063cc10e40111610071578063cc10e40114610b38578063e44591f014610ba8578063e985e9c514610bc5578063f242432a14610bf3576101c3565b8063a22cb46514610a7f578063a9e7d53114610aad578063adebf6f214610b1b576101c3565b80637269a327116100d35780637269a32714610a1a5780638413e8b314610a375780638da5cb5b14610a5a5780639cca1c6414610a62576101c3565b80635e81b958146109a75780636352211e146109c45780636f969c2d146109fd576101c3565b8063352949d3116101665780634e1273f4116101405780634e1273f41461068057806354dbdbf41461078e578063598af9e7146108535780635b286d4a14610889576101c3565b8063352949d3146104d657806336fc1079146105445780633db0f8ab146105b2576101c3565b8063183fb254116101a2578063183fb2541461025e5780632693ebf21461037557806328fd70ec146103925780632eb2c2d6146103af576101c3565b8062fdd58e146101c857806301ffc9a71461020657806308d7d46914610241575b600080fd5b6101f4600480360360408110156101de57600080fd5b506001600160a01b038135169060200135610c86565b60408051918252519081900360200190f35b61022d6004803603602081101561021c57600080fd5b50356001600160e01b031916610cf6565b604080519115158252519081900360200190f35b6101f46004803603602081101561025757600080fd5b5035610d3d565b6103736004803603608081101561027457600080fd5b81359190810190604081016020820135600160201b81111561029557600080fd5b8201836020820111156102a757600080fd5b803590602001918460208302840111600160201b831117156102c857600080fd5b919390929091602081019035600160201b8111156102e557600080fd5b8201836020820111156102f757600080fd5b803590602001918460208302840111600160201b8311171561031857600080fd5b919390929091602081019035600160201b81111561033557600080fd5b82018360208201111561034757600080fd5b803590602001918460018302840111600160201b8311171561036857600080fd5b509092509050610d4f565b005b6101f46004803603602081101561038b57600080fd5b50356110dd565b6101f4600480360360208110156103a857600080fd5b50356110ef565b610373600480360360a08110156103c557600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b8111156103f857600080fd5b82018360208201111561040a57600080fd5b803590602001918460208302840111600160201b8311171561042b57600080fd5b919390929091602081019035600160201b81111561044857600080fd5b82018360208201111561045a57600080fd5b803590602001918460208302840111600160201b8311171561047b57600080fd5b919390929091602081019035600160201b81111561049857600080fd5b8201836020820111156104aa57600080fd5b803590602001918460018302840111600160201b831117156104cb57600080fd5b509092509050611101565b610373600480360360208110156104ec57600080fd5b810190602081018135600160201b81111561050657600080fd5b82018360208201111561051857600080fd5b803590602001918460208302840111600160201b8311171561053957600080fd5b5090925090506116f6565b6103736004803603604081101561055a57600080fd5b810190602081018135600160201b81111561057457600080fd5b82018360208201111561058657600080fd5b803590602001918460018302840111600160201b831117156105a757600080fd5b91935091503561175f565b610373600480360360608110156105c857600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156105f257600080fd5b82018360208201111561060457600080fd5b803590602001918460208302840111600160201b8311171561062557600080fd5b919390929091602081019035600160201b81111561064257600080fd5b82018360208201111561065457600080fd5b803590602001918460208302840111600160201b8311171561067557600080fd5b509092509050611821565b61073e6004803603604081101561069657600080fd5b810190602081018135600160201b8111156106b057600080fd5b8201836020820111156106c257600080fd5b803590602001918460208302840111600160201b831117156106e357600080fd5b919390929091602081019035600160201b81111561070057600080fd5b82018360208201111561071257600080fd5b803590602001918460208302840111600160201b8311171561073357600080fd5b509092509050611b49565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561077a578181015183820152602001610762565b505050509050019250505060405180910390f35b610373600480360360608110156107a457600080fd5b81359190810190604081016020820135600160201b8111156107c557600080fd5b8201836020820111156107d757600080fd5b803590602001918460208302840111600160201b831117156107f857600080fd5b919390929091602081019035600160201b81111561081557600080fd5b82018360208201111561082757600080fd5b803590602001918460018302840111600160201b8311171561084857600080fd5b509092509050611c94565b6101f46004803603606081101561086957600080fd5b506001600160a01b03813581169160208101359091169060400135611f3b565b6103736004803603608081101561089f57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156108c957600080fd5b8201836020820111156108db57600080fd5b803590602001918460208302840111600160201b831117156108fc57600080fd5b919390929091602081019035600160201b81111561091957600080fd5b82018360208201111561092b57600080fd5b803590602001918460208302840111600160201b8311171561094c57600080fd5b919390929091602081019035600160201b81111561096957600080fd5b82018360208201111561097b57600080fd5b803590602001918460208302840111600160201b8311171561099c57600080fd5b509092509050611f6d565b61022d600480360360208110156109bd57600080fd5b5035612187565b6109e1600480360360208110156109da57600080fd5b50356121a8565b604080516001600160a01b039092168252519081900360200190f35b6101f460048036036020811015610a1357600080fd5b50356121c3565b61022d60048036036020811015610a3057600080fd5b50356121d9565b61037360048036036040811015610a4d57600080fd5b50803590602001356121f9565b6109e161233f565b6101f460048036036020811015610a7857600080fd5b503561234e565b61037360048036036040811015610a9557600080fd5b506001600160a01b038135169060200135151561235a565b61037360048036036020811015610ac357600080fd5b810190602081018135600160201b811115610add57600080fd5b820183602082011115610aef57600080fd5b803590602001918460208302840111600160201b83111715610b1057600080fd5b5090925090506123c8565b61022d60048036036020811015610b3157600080fd5b5035612485565b6101f460048036036040811015610b4e57600080fd5b810190602081018135600160201b811115610b6857600080fd5b820183602082011115610b7a57600080fd5b803590602001918460018302840111600160201b83111715610b9b57600080fd5b919350915035151561248f565b61022d60048036036020811015610bbe57600080fd5b503561259d565b61022d60048036036040811015610bdb57600080fd5b506001600160a01b03813581169160200135166125a9565b610373600480360360a0811015610c0957600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b811115610c4857600080fd5b820183602082011115610c5a57600080fd5b803590602001918460018302840111600160201b83111715610c7b57600080fd5b5090925090506125d7565b6000610c9182612187565b15610ccb576000828152600460205260409020546001600160a01b03848116911614610cbe576000610cc1565b60015b60ff169050610cf0565b5060008181526002602090815260408083206001600160a01b03861684529091529020545b92915050565b60006001600160e01b031982166301ffc9a760e01b1480610d2757506001600160e01b03198216636cdb3d1360e11b145b15610d3457506001610d38565b5060005b919050565b60056020526000908152604090205481565b3360009081526009602052604090205460ff16610da1576040805162461bcd60e51b815260206004820152601b6024820152600080516020612d13833981519152604482015290519081900360640190fd5b610daa87612485565b610dfb576040805162461bcd60e51b815260206004820152601c60248201527f4944206d7573742062652061206e6f6e2d66756e6769626c6520494400000000604482015290519081900360640190fd5b60005b858110156110d3576000888152600860205260409020541580610e615750600088815260086020526040902054610e5e868684818110610e3a57fe5b60008d8152600760209081526040909120549391020135905063ffffffff6128da16565b11155b610eb2576040805162461bcd60e51b815260206004820152601b60248201527f546f6b656e20737570706c79206c696d69742065786365656465640000000000604482015290519081900360640190fd5b6000888152600260205260408120610f2291898985818110610ed057fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002054868684818110610f0d57fe5b905060200201356128da90919063ffffffff16565b600089815260026020526040812090898985818110610f3d57fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002081905550610fa4858583818110610f8057fe5b60008c8152600760209081526040909120549391020135905063ffffffff6128da16565b600089815260076020526040902055868682818110610fbf57fe5b905060200201356001600160a01b03166001600160a01b031660006001600160a01b0316336001600160a01b0316600080516020612c5c8339815191528b89898781811061100957fe5b604080519485526020918202939093013590840152508051918290030190a461105587878381811061103757fe5b905060200201356001600160a01b03166001600160a01b03166128e7565b156110cb576110cb333389898581811061106b57fe5b905060200201356001600160a01b03168b89898781811061108857fe5b9050602002013588888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506128ed92505050565b600101610dfe565b5050505050505050565b60076020526000908152604090205481565b60086020526000908152604090205481565b6001600160a01b03871661115c576040805162461bcd60e51b815260206004820152601b60248201527f63616e6e6f742073656e6420746f207a65726f20616464726573730000000000604482015290519081900360640190fd5b8483146111b0576040805162461bcd60e51b815260206004820152601760248201527f4172726179206c656e677468206d757374206d61746368000000000000000000604482015290519081900360640190fd5b6001600160a01b0388163314806111ef57506001600160a01b038816600090815260036020908152604080832033845290915290205460ff1615156001145b61122a5760405162461bcd60e51b815260040180806020018281038252602f815260200180612c7c602f913960400191505060405180910390fd5b60005b858110156115895761125087878381811061124457fe5b9050602002013561259d565b1561142357886001600160a01b03166004600089898581811061126f57fe5b60209081029290920135835250810191909152604001600020546001600160a01b03161461129c57600080fd5b87600460008989858181106112ad57fe5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555061134e8585838181106112f557fe5b905060200201356002600061131b8b8b8781811061130f57fe5b905060200201356121c3565b8152602080820192909252604090810160009081206001600160a01b038f1682529092529020549063ffffffff612a5d16565b600260006113618a8a8681811061130f57fe5b8152602080820192909252604090810160009081206001600160a01b038e1682529092529020556113e485858381811061139757fe5b90506020020135600260006113b18b8b8781811061130f57fe5b8152602080820192909252604090810160009081206001600160a01b038e1682529092529020549063ffffffff6128da16565b600260006113f78a8a8681811061130f57fe5b8152602080820192909252604090810160009081206001600160a01b038d168252909252902055611581565b61149085858381811061143257fe5b90506020020135600260008a8a8681811061144957fe5b90506020020135815260200190815260200160002060008c6001600160a01b03166001600160a01b0316815260200190815260200160002054612a5d90919063ffffffff16565b600260008989858181106114a057fe5b90506020020135815260200190815260200160002060008b6001600160a01b03166001600160a01b0316815260200190815260200160002081905550611534600260008989858181106114ef57fe5b90506020020135815260200190815260200160002060008a6001600160a01b03166001600160a01b0316815260200190815260200160002054868684818110610f0d57fe5b6002600089898581811061154457fe5b90506020020135815260200190815260200160002060008a6001600160a01b03166001600160a01b03168152602001908152602001600020819055505b60010161122d565b50866001600160a01b0316886001600160a01b0316336001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb898989896040518080602001806020018381038352878782818152602001925060200280828437600083820152601f01601f19169091018481038352858152602090810191508690860280828437600083820152604051601f909101601f19169092018290039850909650505050505050a461164d876001600160a01b03166128e7565b156110d3576110d333898989898080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050604080516020808d0282810182019093528c82529093508c92508b91829185019084908082843760009201919091525050604080516020601f8c018190048102820181019092528a815292508a9150899081908401838280828437600092019190915250612a6f92505050565b6001546001600160a01b0316331461170d57600080fd5b60005b8181101561175a576009600084848481811061172857fe5b602090810292909201356001600160a01b0316835250810191909152604001600020805460ff19169055600101611710565b505050565b3360009081526009602052604090205460ff166117b1576040805162461bcd60e51b815260206004820152601b6024820152600080516020612d13833981519152604482015290519081900360640190fd5b816117bb57600080fd5b807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b848460405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a2505050565b6001600160a01b03851633148061186057506001600160a01b038516600090815260036020908152604080832033845290915290205460ff1615156001145b61189b5760405162461bcd60e51b815260040180806020018281038252602a815260200180612ce9602a913960400191505060405180910390fd5b82158015906118a957508281145b6118b257600080fd5b60005b83811015611b41576118d88585838181106118cc57fe5b90506020020135612485565b15611a02578282828181106118e957fe5b905060200201356002600087878581811061190057fe5b9050602002013581526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002054101561194457600080fd5b6119b183838381811061195357fe5b905060200201356002600088888681811061196a57fe5b9050602002013581526020019081526020016000206000896001600160a01b03166001600160a01b0316815260200190815260200160002054612a5d90919063ffffffff16565b600260008787858181106119c157fe5b9050602002013581526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002081905550611adf565b611a1185858381811061124457fe5b611a1a57600080fd5b828282818110611a2657fe5b90506020020135600114611a3957600080fd5b6000611a4a86868481811061130f57fe5b60008181526002602090815260408083206001600160a01b038c168452909152902054909150611a8190600163ffffffff612a5d16565b60008281526002602090815260408083206001600160a01b038c168452909152812091909155600490878785818110611ab657fe5b6020908102929092013583525081019190915260400160002080546001600160a01b0319169055505b60006001600160a01b03871633600080516020612c5c833981519152888886818110611b0757fe5b90506020020135878787818110611b1a57fe5b604080519485526020918202939093013590840152508051918290030190a46001016118b5565b505050505050565b6060838214611b5757600080fd5b604080518581526020808702820101909152606090858015611b83578160200160208202803883390190505b50905060005b85811015611c8a576000858583818110611b9f57fe5b905060200201359050611bb181612187565b15611c1c57878783818110611bc257fe5b600084815260046020908152604090912054910292909201356001600160a01b039081169216919091149050611bf9576000611bfc565b60015b60ff16838381518110611c0b57fe5b602002602001018181525050611c81565b600081815260026020526040812090898985818110611c3757fe5b905060200201356001600160a01b03166001600160a01b03166001600160a01b0316815260200190815260200160002054838381518110611c7457fe5b6020026020010181815250505b50600101611b89565b5095945050505050565b3360009081526009602052604090205460ff16611ce6576040805162461bcd60e51b815260206004820152601b6024820152600080516020612d13833981519152604482015290519081900360640190fd5b611cef8561259d565b611cf857600080fd5b6000858152600560205260409020546001810190611d1d90859063ffffffff6128da16565b6000878152600560205260408120919091555b84811015611f32576000868683818110611d4657fe5b905060200201356001600160a01b03169050600082840189179050600860008a81526020019081526020016000205460001480611dad5750600089815260086020908152604080832054600790925290912054611daa90600163ffffffff6128da16565b11155b611dfe576040805162461bcd60e51b815260206004820152601b60248201527f546f6b656e20737570706c79206c696d69742065786365656465640000000000604482015290519081900360640190fd5b600081815260046020908152604080832080546001600160a01b0319166001600160a01b0387161790558b83526007909152902054611e3e9060016128da565b60008a815260076020908152604080832093909355600281528282206001600160a01b038616835290522054611e7b90600163ffffffff6128da16565b60008a81526002602090815260408083206001600160a01b03871680855290835281842094909455805185815260019281019290925280513392600080516020612c5c83398151915292908290030190a4611ede826001600160a01b03166128e7565b15611f2857611f283333848460018b8b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506128ed92505050565b5050600101611d30565b50505050505050565b6001600160a01b0392831660009081526006602090815260408083209490951682529283528381209181529152205490565b848314611fc1576040805162461bcd60e51b815260206004820152601a60248201527f417272617973206d7573742062652073616d65206c656e677468000000000000604482015290519081900360640190fd5b828114612015576040805162461bcd60e51b815260206004820152601a60248201527f417272617973206d7573742062652073616d65206c656e677468000000000000604482015290519081900360640190fd5b60005b818110156110d357600087878381811061202e57fe5b905060200201359050600086868481811061204557fe5b905060200201359050600085858581811061205c57fe5b9050602002013590508160066000336001600160a01b03166001600160a01b0316815260200190815260200160002060008d6001600160a01b03166001600160a01b03168152602001908152602001600020600085815260200190815260200160002054146120ca57600080fd5b8060066000336001600160a01b03166001600160a01b0316815260200190815260200160002060008d6001600160a01b03166001600160a01b03168152602001908152602001600020600085815260200190815260200160002081905550828b6001600160a01b0316336001600160a01b03167f3a9c85c6b31f7a9d7fe1478f53e1be42e85db97ca30d1789cfef9196dbc472c98585604051808381526020018281526020019250505060405180910390a4505050600101612018565b6000600160ff1b808316148015610cf05750506001600160801b0316151590565b6000908152600460205260409020546001600160a01b031690565b6fffffffffffffffffffffffffffffffff191690565b6000600160ff1b808316148015610cf05750506001600160801b03161590565b3360009081526009602052604090205460ff1661224b576040805162461bcd60e51b815260206004820152601b6024820152600080516020612d13833981519152604482015290519081900360640190fd5b6000811161225857600080fd5b61226182612187565b156122da576000612271836121c3565b6000818152600860205260409020549091501561228d57600080fd5b6000818152600860209081526040918290208490558151848152915183927f4a92cb8a98b3c42468f2ffd7b4dc17755416ebcfd17fd0040895ea07895c0fae92908290030190a25061233b565b600082815260086020526040902054156122f357600080fd5b6000828152600860209081526040918290208390558151838152915184927f4a92cb8a98b3c42468f2ffd7b4dc17755416ebcfd17fd0040895ea07895c0fae92908290030190a25b5050565b6001546001600160a01b031681565b6001600160801b031690565b3360008181526003602090815260408083206001600160a01b03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6001546001600160a01b031633146123df57600080fd5b60005b8181101561175a577f77b942a0834ead73d2e76c27f611bd4f14e4cd55de82e1d4bbd5521905f69f0f83838381811061241757fe5b60408051602092830294909401356001600160a01b03168452519283900301919050a160016009600085858581811061244c57fe5b602090810292909201356001600160a01b0316835250810191909152604001600020805460ff19169115159190911790556001016123e2565b600160ff1b161590565b3360009081526009602052604081205460ff166124e1576040805162461bcd60e51b815260206004820152601b6024820152600080516020612d13833981519152604482015290519081900360640190fd5b50600080546001019081905560801b81156124fd57600160ff1b175b604080518281526000602082018190528251909283923392600080516020612c5c833981519152929181900390910190a4821561259657807f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b858560405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a25b9392505050565b600160ff1b9081161490565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205460ff1690565b6001600160a01b038516612632576040805162461bcd60e51b815260206004820152601b60248201527f63616e6e6f742073656e6420746f207a65726f20616464726573730000000000604482015290519081900360640190fd5b6001600160a01b03861633148061267157506001600160a01b038616600090815260036020908152604080832033845290915290205460ff1615156001145b6126ac5760405162461bcd60e51b815260040180806020018281038252602f815260200180612c7c602f913960400191505060405180910390fd5b6126b58461259d565b156127a6576000848152600460205260409020546001600160a01b038781169116146126e057600080fd5b600084815260046020526040812080546001600160a01b0319166001600160a01b038816179055612710856121c3565b60008181526002602090815260408083206001600160a01b038c168452909152902054909150612746908563ffffffff612a5d16565b60008281526002602090815260408083206001600160a01b038c8116855292528083209390935588168152205461277d90856128da565b60009182526002602090815260408084206001600160a01b038a16855290915290912055612834565b60008481526002602090815260408083206001600160a01b038a1684529091529020546127d9908463ffffffff612a5d16565b60008581526002602090815260408083206001600160a01b038b8116855292528083209390935587168152205461281090846128da565b60008581526002602090815260408083206001600160a01b038a1684529091529020555b846001600160a01b0316866001600160a01b0316336001600160a01b0316600080516020612c5c8339815191528787604051808381526020018281526020019250505060405180910390a4612891856001600160a01b03166128e7565b15611b4157611b41338787878787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506128ed92505050565b81810182811015610cf057fe5b3b151590565b63f23a6e6160e01b6001600160e01b031916846001600160a01b031663f23a6e6188888787876040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561299b578181015183820152602001612983565b50505050905090810190601f1680156129c85780820380516001836020036101000a031916815260200191505b509650505050505050602060405180830381600087803b1580156129eb57600080fd5b505af11580156129ff573d6000803e3d6000fd5b505050506040513d6020811015612a1557600080fd5b50516001600160e01b03191614611b415760405162461bcd60e51b8152600401808060200182810382526039815260200180612d336039913960400191505060405180910390fd5b600082821115612a6957fe5b50900390565b63bc197c8160e01b6001600160e01b031916846001600160a01b031663bc197c8188888787876040518663ffffffff1660e01b815260040180866001600160a01b03166001600160a01b03168152602001856001600160a01b03166001600160a01b03168152602001806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b83811015612b1c578181015183820152602001612b04565b50505050905001848103835286818151815260200191508051906020019060200280838360005b83811015612b5b578181015183820152602001612b43565b50505050905001848103825285818151815260200191508051906020019080838360005b83811015612b97578181015183820152602001612b7f565b50505050905090810190601f168015612bc45780820380516001836020036101000a031916815260200191505b5098505050505050505050602060405180830381600087803b158015612be957600080fd5b505af1158015612bfd573d6000803e3d6000fd5b505050506040513d6020811015612c1357600080fd5b50516001600160e01b03191614611b415760405162461bcd60e51b815260040180806020018281038252603e815260200180612cab603e913960400191505060405180910390fdfec3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f624e656564206f70657261746f7220617070726f76616c20666f7220337264207061727479207472616e73666572732e636f6e74726163742072657475726e656420616e20756e6b6e6f776e2076616c75652066726f6d206f6e45524331313535426174636852656365697665644e656564206f70657261746f7220617070726f76616c20666f7220337264207061727479206275726e2e43726561746f72207065726d697373696f6e2072657175697265640000000000636f6e74726163742072657475726e656420616e20756e6b6e6f776e2076616c75652066726f6d206f6e455243313135355265636569766564a265627a7a72315820e8a61d55a194b2f42d83bad5cb50743bb2cae21f6bc9f7b12d8f0056879d500e64736f6c63430005110032
Verified Source Code Partial Match
Compiler: v0.5.17+commit.d19bba13
EVM: istanbul
Optimization: Yes (200 runs)
Gala.sol 415 lines
import "./SafeMath.sol";
import "./Address.sol";
import "./Common.sol";
import "./IERC1155TokenReceiver.sol";
import "./IERC1155.sol";
pragma solidity ^0.5.0;
contract Gala is IERC1155, ERC165, CommonConstants {
using SafeMath for uint256;
using Address for address;
uint256 constant TYPE_MASK = uint256(uint128(~0)) << 128;
uint256 constant NF_INDEX_MASK = uint128(~0);
uint256 constant TYPE_NF_BIT = 1 << 255;
uint256 nonce;
address public owner;
mapping(uint256 => mapping(address => uint256)) internal balances; // id => (owner => balance)
mapping(address => mapping(address => bool)) internal operatorApproval; // owner => (operator => approved)
mapping(uint256 => address) nfOwners;
mapping(uint256 => uint256) public maxIndex;
mapping(address => mapping(address => mapping(uint256 => uint256))) allowances;
mapping(uint256 => uint256) public tokenSupply;
mapping(uint256 => uint256) public tokenSupplyLimit;
mapping(address => bool) internal creators;
event Approval(
address indexed _owner,
address indexed _spender,
uint256 indexed _id,
uint256 _oldValue,
uint256 _value
);
event SupplyLimit(uint256 indexed _id, uint256 _supplyLimit);
event TransferSingle(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256 _id,
uint256 _value
);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event URI(string _value, uint256 indexed _id);
event TransferBatch(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256[] _ids,
uint256[] _values
);
event Creator(address _creator);
constructor() public {
owner = msg.sender;
creators[msg.sender] = true;
}
modifier creatorOnly() {
require(creators[msg.sender], "Creator permission required");
_;
}
modifier ownerOnly() {
require(msg.sender == owner);
_;
}
function create(string calldata _uri, bool _isNF) external creatorOnly returns (uint256 _type) {
_type = (++nonce << 128);
if (_isNF) _type = _type | TYPE_NF_BIT;
emit TransferSingle(msg.sender, address(0x0), address(0x0), _type, 0);
if (bytes(_uri).length > 0) emit URI(_uri, _type);
return _type;
}
function mintNonFungible(
uint256 _type,
address[] calldata _to,
bytes calldata _data
) external creatorOnly {
require(isNonFungible(_type));
uint256 index = maxIndex[_type] + 1;
maxIndex[_type] = _to.length.add(maxIndex[_type]);
for (uint256 i = 0; i < _to.length; ++i) {
address distributeTo = _to[i];
uint256 id = _type | (index + i);
require(
tokenSupplyLimit[_type] == 0 ||
tokenSupply[_type].add(1) <= tokenSupplyLimit[_type],
"Token supply limit exceeded"
);
nfOwners[id] = distributeTo;
tokenSupply[_type] = tokenSupply[_type].add(1);
balances[_type][distributeTo] = balances[_type][distributeTo].add(1);
emit TransferSingle(msg.sender, address(0x0), distributeTo, id, 1);
if (distributeTo.isContract()) {
_doSafeTransferAcceptanceCheck(msg.sender, msg.sender, distributeTo, id, 1, _data);
}
}
}
function mintFungible(
uint256 _id,
address[] calldata _to,
uint256[] calldata _quantities,
bytes calldata _data
) external creatorOnly {
require(isFungible(_id), "ID must be a non-fungible ID");
for (uint256 i = 0; i < _to.length; ++i) {
require(
tokenSupplyLimit[_id] == 0 ||
tokenSupply[_id].add(_quantities[i]) <= tokenSupplyLimit[_id],
"Token supply limit exceeded"
);
balances[_id][_to[i]] = _quantities[i].add(balances[_id][_to[i]]);
tokenSupply[_id] = tokenSupply[_id].add(_quantities[i]);
emit TransferSingle(msg.sender, address(0x0), _to[i], _id, _quantities[i]);
if (_to[i].isContract()) {
_doSafeTransferAcceptanceCheck(
msg.sender,
msg.sender,
_to[i],
_id,
_quantities[i],
_data
);
}
}
}
function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes calldata _data
) external {
require(_to != address(0x0), "cannot send to zero address");
require(
_from == msg.sender || operatorApproval[_from][msg.sender] == true,
"Need operator approval for 3rd party transfers."
);
if (isNonFungible(_id)) {
require(nfOwners[_id] == _from);
nfOwners[_id] = _to;
// You could keep balance of NF type in base type id like so:
uint256 baseType = getNonFungibleBaseType(_id);
balances[baseType][_from] = balances[baseType][_from].sub(_value);
balances[baseType][_to] = balances[baseType][_to].add(_value);
} else {
balances[_id][_from] = balances[_id][_from].sub(_value);
balances[_id][_to] = balances[_id][_to].add(_value);
}
emit TransferSingle(msg.sender, _from, _to, _id, _value);
if (_to.isContract()) {
_doSafeTransferAcceptanceCheck(msg.sender, _from, _to, _id, _value, _data);
}
}
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external {
require(_to != address(0x0), "cannot send to zero address");
require(_ids.length == _values.length, "Array length must match");
require(
_from == msg.sender || operatorApproval[_from][msg.sender] == true,
"Need operator approval for 3rd party transfers."
);
for (uint256 i = 0; i < _ids.length; ++i) {
if (isNonFungible(_ids[i])) {
require(nfOwners[_ids[i]] == _from);
nfOwners[_ids[i]] = _to;
balances[getNonFungibleBaseType(_ids[i])][_from] = balances[getNonFungibleBaseType(
_ids[i]
)][_from]
.sub(_values[i]);
balances[getNonFungibleBaseType(_ids[i])][_to] = balances[getNonFungibleBaseType(
_ids[i]
)][_to]
.add(_values[i]);
} else {
balances[_ids[i]][_from] = balances[_ids[i]][_from].sub(_values[i]);
balances[_ids[i]][_to] = _values[i].add(balances[_ids[i]][_to]);
}
}
emit TransferBatch(msg.sender, _from, _to, _ids, _values);
if (_to.isContract()) {
_doSafeBatchTransferAcceptanceCheck(msg.sender, _from, _to, _ids, _values, _data);
}
}
function balanceOf(address _owner, uint256 _id) external view returns (uint256) {
if (isNonFungibleItem(_id)) return nfOwners[_id] == _owner ? 1 : 0;
return balances[_id][_owner];
}
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
external
view
returns (uint256[] memory)
{
require(_owners.length == _ids.length);
uint256[] memory balances_ = new uint256[](_owners.length);
for (uint256 i = 0; i < _owners.length; ++i) {
uint256 id = _ids[i];
if (isNonFungibleItem(id)) {
balances_[i] = nfOwners[id] == _owners[i] ? 1 : 0;
} else {
balances_[i] = balances[id][_owners[i]];
}
}
return balances_;
}
function setApprovalForAll(address _operator, bool _approved) external {
operatorApproval[msg.sender][_operator] = _approved;
emit ApprovalForAll(msg.sender, _operator, _approved);
}
function isApprovedForAll(address _owner, address _operator) external view returns (bool) {
return operatorApproval[_owner][_operator];
}
function setSupplyLimit(uint256 _typeOrId, uint256 _supplyLimit) external creatorOnly {
require(_supplyLimit > 0);
if (isNonFungibleItem(_typeOrId)) {
uint256 typeId = getNonFungibleBaseType(_typeOrId);
require(tokenSupplyLimit[typeId] == 0);
tokenSupplyLimit[typeId] = _supplyLimit;
emit SupplyLimit(typeId, _supplyLimit);
} else {
require(tokenSupplyLimit[_typeOrId] == 0);
tokenSupplyLimit[_typeOrId] = _supplyLimit;
emit SupplyLimit(_typeOrId, _supplyLimit);
}
}
function approveBatch(
address _spender,
uint256[] calldata _ids,
uint256[] calldata _currentValues,
uint256[] calldata _values
) external {
require(_ids.length == _currentValues.length, "Arrays must be same length");
require(_currentValues.length == _values.length, "Arrays must be same length");
for (uint256 i = 0; i < _values.length; i++) {
uint256 id = _ids[i];
uint256 currentValue = _currentValues[i];
uint256 value = _values[i];
require(allowances[msg.sender][_spender][id] == currentValue);
allowances[msg.sender][_spender][id] = value;
emit Approval(msg.sender, _spender, id, currentValue, value);
}
}
function isNonFungible(uint256 _id) public pure returns (bool) {
return _id & TYPE_NF_BIT == TYPE_NF_BIT;
}
function isFungible(uint256 _id) public pure returns (bool) {
return _id & TYPE_NF_BIT == 0;
}
function getNonFungibleIndex(uint256 _id) public pure returns (uint256) {
return _id & NF_INDEX_MASK;
}
function getNonFungibleBaseType(uint256 _id) public pure returns (uint256) {
return _id & TYPE_MASK;
}
function isNonFungibleBaseType(uint256 _id) public pure returns (bool) {
// A base type has the NF bit but does not have an index.
return (_id & TYPE_NF_BIT == TYPE_NF_BIT) && (_id & NF_INDEX_MASK == 0);
}
function isNonFungibleItem(uint256 _id) public pure returns (bool) {
// A base type has the NF bit but does has an index.
return (_id & TYPE_NF_BIT == TYPE_NF_BIT) && (_id & NF_INDEX_MASK != 0);
}
function ownerOf(uint256 _id) public view returns (address) {
return nfOwners[_id];
}
/////////////////////////////////////////// ERC165 //////////////////////////////////////////////
bytes4 private constant INTERFACE_SIGNATURE_ERC165 = 0x01ffc9a7;
bytes4 private constant INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26;
function supportsInterface(bytes4 _interfaceId) public view returns (bool) {
if (
_interfaceId == INTERFACE_SIGNATURE_ERC165 ||
_interfaceId == INTERFACE_SIGNATURE_ERC1155
) {
return true;
}
return false;
}
/////////////////////////////////////////// Internal //////////////////////////////////////////////
function _doSafeTransferAcceptanceCheck(
address _operator,
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes memory _data
) internal {
require(
ERC1155TokenReceiver(_to).onERC1155Received(_operator, _from, _id, _value, _data) ==
ERC1155_ACCEPTED,
"contract returned an unknown value from onERC1155Received"
);
}
function _doSafeBatchTransferAcceptanceCheck(
address _operator,
address _from,
address _to,
uint256[] memory _ids,
uint256[] memory _values,
bytes memory _data
) internal {
require(
ERC1155TokenReceiver(_to).onERC1155BatchReceived(
_operator,
_from,
_ids,
_values,
_data
) == ERC1155_BATCH_ACCEPTED,
"contract returned an unknown value from onERC1155BatchReceived"
);
}
/////////////////////////////////////////// ERC1155 //////////////////////////////////////////////
function batchAuthorizeCreators(address[] calldata _addresses) external ownerOnly {
for (uint256 i = 0; i < _addresses.length; ++i) {
emit Creator(_addresses[i]);
creators[_addresses[i]] = true;
}
}
function batchDeauthorizeCreators(address[] calldata _addresses) external ownerOnly {
for (uint256 i = 0; i < _addresses.length; ++i) {
delete creators[_addresses[i]];
}
}
function allowance(
address _owner,
address _spender,
uint256 _id
) external view returns (uint256) {
return allowances[_owner][_spender][_id];
}
function burn(
address _from,
uint256[] calldata _ids,
uint256[] calldata _values
) external {
require(
_from == msg.sender || operatorApproval[_from][msg.sender] == true,
"Need operator approval for 3rd party burn."
);
require(_ids.length > 0 && _ids.length == _values.length);
for (uint256 i = 0; i < _ids.length; i++) {
if (isFungible(_ids[i])) {
require(balances[_ids[i]][_from] >= _values[i]);
balances[_ids[i]][_from] = balances[_ids[i]][_from].sub(_values[i]);
} else {
require(isNonFungible(_ids[i]));
require(_values[i] == 1);
uint256 baseType = getNonFungibleBaseType(_ids[i]);
// --totalSupply?
balances[baseType][_from] = balances[baseType][_from].sub(1);
delete nfOwners[_ids[i]];
}
emit TransferSingle(msg.sender, _from, address(0x0), _ids[i], _values[i]);
}
}
function setNewUri(string calldata _uri, uint256 _id) external creatorOnly {
require(bytes(_uri).length > 0);
emit URI(_uri, _id);
}
}
Common.sol 7 lines
pragma solidity ^0.5.0;
contract CommonConstants {
bytes4 internal constant ERC1155_ACCEPTED = 0xf23a6e61;
bytes4 internal constant ERC1155_BATCH_ACCEPTED = 0xbc197c81;
}
ERC165.sol 6 lines
pragma solidity ^0.5.0;
interface ERC165 {
function supportsInterface(bytes4 _interfaceId) external view returns (bool);
}
Address.sol 12 lines
pragma solidity ^0.5.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
}
IERC1155.sol 51 lines
pragma solidity ^0.5.0;
import "./ERC165.sol";
/* is ERC165 */
interface IERC1155 {
event TransferSingle(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256 _id,
uint256 _value
);
event TransferBatch(
address indexed _operator,
address indexed _from,
address indexed _to,
uint256[] _ids,
uint256[] _values
);
event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
event URI(string _value, uint256 indexed _id);
function safeTransferFrom(
address _from,
address _to,
uint256 _id,
uint256 _value,
bytes calldata _data
) external;
function safeBatchTransferFrom(
address _from,
address _to,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external;
function balanceOf(address _owner, uint256 _id) external view returns (uint256);
function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
external
view
returns (uint256[] memory);
function setApprovalForAll(address _operator, bool _approved) external;
function isApprovedForAll(address _owner, address _operator) external view returns (bool);
}
SafeMath.sol 28 lines
pragma solidity ^0.5.0;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
IERC1155TokenReceiver.sol 20 lines
pragma solidity ^0.5.0;
interface ERC1155TokenReceiver {
function onERC1155Received(
address _operator,
address _from,
uint256 _id,
uint256 _value,
bytes calldata _data
) external returns (bytes4);
function onERC1155BatchReceived(
address _operator,
address _from,
uint256[] calldata _ids,
uint256[] calldata _values,
bytes calldata _data
) external returns (bytes4);
}
Read Contract
allowance 0x598af9e7 → uint256
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
getNonFungibleBaseType 0x6f969c2d → uint256
getNonFungibleIndex 0x9cca1c64 → uint256
isApprovedForAll 0xe985e9c5 → bool
isFungible 0xadebf6f2 → bool
isNonFungible 0xe44591f0 → bool
isNonFungibleBaseType 0x7269a327 → bool
isNonFungibleItem 0x5e81b958 → bool
maxIndex 0x08d7d469 → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
tokenSupply 0x2693ebf2 → uint256
tokenSupplyLimit 0x28fd70ec → uint256
Write Contract 12 functions
These functions modify contract state and require a wallet transaction to execute.
approveBatch 0x5b286d4a
address _spender
uint256[] _ids
uint256[] _currentValues
uint256[] _values
batchAuthorizeCreators 0xa9e7d531
address[] _addresses
batchDeauthorizeCreators 0x352949d3
address[] _addresses
burn 0x3db0f8ab
address _from
uint256[] _ids
uint256[] _values
create 0xcc10e401
string _uri
bool _isNF
returns: uint256
mintFungible 0x183fb254
uint256 _id
address[] _to
uint256[] _quantities
bytes _data
mintNonFungible 0x54dbdbf4
uint256 _type
address[] _to
bytes _data
safeBatchTransferFrom 0x2eb2c2d6
address _from
address _to
uint256[] _ids
uint256[] _values
bytes _data
safeTransferFrom 0xf242432a
address _from
address _to
uint256 _id
uint256 _value
bytes _data
setApprovalForAll 0xa22cb465
address _operator
bool _approved
setNewUri 0x36fc1079
string _uri
uint256 _id
setSupplyLimit 0x8413e8b3
uint256 _typeOrId
uint256 _supplyLimit
Token Balances (2)
View Transfers →Recent Transactions
No transactions found for this address