Address Contract Verified
Address
0x5dFAE9Ff7f132a584375a4Bd3694DDc60Af1082F
Balance
0 ETH
Nonce
1
Code Size
21037 bytes
Creator
0x14CcCBbF...Fdd3 at tx 0x07872634...5230ae
Indexed Transactions
0
Contract Bytecode
21037 bytes
0x60806040526004361061029e5760003560e01c806366ad5c8a1161016e578063b7e65700116100cb578063e985e9c51161007f578063f242432a11610064578063f242432a146107be578063f2fde38b146107de578063f5ecbdbc146107fe57600080fd5b8063e985e9c514610755578063eb8d72b71461079e57600080fd5b8063d1deba1f116100b0578063d1deba1f146106fa578063d547cfb71461070d578063dacbcbe21461072257600080fd5b8063b7e65700146106ba578063cbed8b9c146106da57600080fd5b80638608e5f8116101225780638ee74912116101075780638ee749121461063657806395d89b4114610685578063a22cb4651461069a57600080fd5b80638608e5f8146105f85780638da5cb5b1461061857600080fd5b80636f6120a6116101535780636f6120a6146105b0578063715018a6146105c35780638293744b146105d857600080fd5b806366ad5c8a1461057057806369b41f951461059057600080fd5b80632834a2571161021c57806342d65a8d116101d05780634be699cd116101b55780634be699cd1461051d5780634db8226a146105305780634e1273f41461054357600080fd5b806342d65a8d146104ea5780634ab4e6871461050a57600080fd5b80632eb2c2d6116102015780632eb2c2d61461045e57806330503c4e1461047e5780633d8b38f6146104ca57600080fd5b80632834a257146103ea5780632a55205a1461041f57600080fd5b806306fdde03116102735780630c955a80116102585780630c955a801461038a5780630e89341c146103aa57806310ddb137146103ca57600080fd5b806306fdde031461034857806307e0db171461036a57600080fd5b80621d3567146102a3578062fdd58e146102c557806301ffc9a7146102f857806302fe530514610328575b600080fd5b3480156102af57600080fd5b506102c36102be366004614832565b61081e565b005b3480156102d157600080fd5b506102e56102e03660046141cd565b610939565b6040519081526020015b60405180910390f35b34801561030457600080fd5b506103186103133660046142ee565b6109df565b60405190151581526020016102ef565b34801561033457600080fd5b506102c36103433660046143dd565b610a7c565b34801561035457600080fd5b5061035d610aed565b6040516102ef9190614cbc565b34801561037657600080fd5b506102c3610385366004614423565b610b7b565b34801561039657600080fd5b506102c36103a53660046142bb565b610c6f565b3480156103b657600080fd5b5061035d6103c536600461496a565b610df2565b3480156103d657600080fd5b506102c36103e5366004614423565b610e26565b3480156103f657600080fd5b5061040a61040536600461445b565b610ee9565b604080519283526020830191909152016102ef565b34801561042b57600080fd5b5061043f61043a366004614982565b611083565b604080516001600160a01b0390931683526020830191909152016102ef565b34801561046a57600080fd5b506102c3610479366004613e94565b6110be565b34801561048a57600080fd5b506104b27f0000000000000000000000005182a9ba9eacef7997056c247ea9b5e317224a1681565b6040516001600160a01b0390911681526020016102ef565b3480156104d657600080fd5b506103186104e53660046144d1565b611159565b3480156104f657600080fd5b506102c36105053660046144d1565b611225565b6102c3610518366004614027565b61131f565b6102c361052b36600461460c565b611374565b6102c361053e366004614121565b6113c8565b34801561054f57600080fd5b5061056361055e3660046141f8565b611411565b6040516102ef9190614c44565b34801561057c57600080fd5b506102c361058b366004614832565b611587565b34801561059c57600080fd5b5061035d6105ab366004614423565b6115e2565b6102c36105be366004614524565b611689565b3480156105cf57600080fd5b506102c36116d2565b3480156105e457600080fd5b506102c36105f3366004613fa5565b611738565b34801561060457600080fd5b5061040a6106133660046146a6565b611872565b34801561062457600080fd5b506000546001600160a01b03166104b2565b34801561064257600080fd5b506102e561065136600461474c565b6002602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b34801561069157600080fd5b5061035d6119fa565b3480156106a657600080fd5b506102c36106b5366004613ff3565b611a07565b3480156106c657600080fd5b506102c36106d53660046141cd565b611a12565b3480156106e657600080fd5b506102c36106f536600461490a565b611a9e565b6102c36107083660046147a3565b611b93565b34801561071957600080fd5b5061035d611d2f565b34801561072e57600080fd5b507f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756104b2565b34801561076157600080fd5b50610318610770366004613e5c565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205460ff1690565b3480156107aa57600080fd5b506102c36107b93660046144d1565b611d3c565b3480156107ca57600080fd5b506102c36107d9366004613f3e565b611df5565b3480156107ea57600080fd5b506102c36107f9366004613e40565b611e90565b34801561080a57600080fd5b5061035d6108193660046148ba565b611f72565b337f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03161461085357600080fd5b61ffff8416600090815260016020526040902080546108719061502b565b905083511480156108b0575061ffff841660009081526001602052604090819020905161089e9190614b0c565b60405180910390208380519060200120145b6109275760405162461bcd60e51b815260206004820152602b60248201527f4c7a52656365697665723a20696e76616c696420736f757263652073656e646960448201527f6e6720636f6e747261637400000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610933848484846120c1565b50505050565b60006001600160a01b0383166109b75760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a2061646472657373207a65726f206973206e6f742061207660448201527f616c6964206f776e657200000000000000000000000000000000000000000000606482015260840161091e565b5060009081526003602090815260408083206001600160a01b03949094168352929052205490565b60006001600160e01b031982167fd9b67a26000000000000000000000000000000000000000000000000000000001480610a4257506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b80610a7657507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b6000546001600160a01b03163314610ad65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b8051610ae9906006906020840190613b34565b5050565b60078054610afa9061502b565b80601f0160208091040260200160405190810160405280929190818152602001828054610b269061502b565b8015610b735780601f10610b4857610100808354040283529160200191610b73565b820191906000526020600020905b815481529060010190602001808311610b5657829003601f168201915b505050505081565b6000546001600160a01b03163314610bd55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6040517f07e0db1700000000000000000000000000000000000000000000000000000000815261ffff821660048201527f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316906307e0db17906024015b600060405180830381600087803b158015610c5457600080fd5b505af1158015610c68573d6000803e3d6000fd5b5050505050565b6000815167ffffffffffffffff811115610c9957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610cc2578160200160208202803683370190505b50905060005b8251811015610dd6576000838281518110610cf357634e487b7160e01b600052603260045260246000fd5b602002602001015190506001838381518110610d1f57634e487b7160e01b600052603260045260246000fd5b60209081029190910101526040517f23b872dd000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018290527f0000000000000000000000005182a9ba9eacef7997056c247ea9b5e317224a166001600160a01b0316906323b872dd90606401600060405180830381600087803b158015610db157600080fd5b505af1158015610dc5573d6000803e3d6000fd5b505060019093019250610cc8915050565b50610ae9338383604051806020016040528060008152506121b3565b60606006610dff83612396565b604051602001610e10929190614b18565b6040516020818303038152906040529050919050565b6000546001600160a01b03163314610e805760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6040517f10ddb13700000000000000000000000000000000000000000000000000000000815261ffff821660048201527f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316906310ddb13790602401610c3a565b6000806000855167ffffffffffffffff811115610f1657634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610f3f578160200160208202803683370190505b50905060005b8651811015610f8d576001828281518110610f7057634e487b7160e01b600052603260045260246000fd5b602090810291909101015280610f8581615093565b915050610f45565b506000808783604051602001610fa593929190614c06565b60408051601f19818403018152908290527f40a7bb1000000000000000000000000000000000000000000000000000000000825291506001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516906340a7bb1090611025908b90309086906000908d908d90600401614d63565b604080518083038186803b15801561103c57600080fd5b505afa158015611050573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107491906149a3565b93509350505094509492505050565b600954600a5460009182916001600160a01b0390911690612710906110a89086614fc9565b6110b29190614fb5565b915091505b9250929050565b6001600160a01b0385163314806110da57506110da8533610770565b61114c5760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161091e565b610c6885858585856124ec565b61ffff83166000908152600160205260408120805482919061117a9061502b565b80601f01602080910402602001604051908101604052809291908181526020018280546111a69061502b565b80156111f35780601f106111c8576101008083540402835291602001916111f3565b820191906000526020600020905b8154815290600101906020018083116111d657829003601f168201915b50505050509050838360405161120a929190614ae0565b60405180910390208180519060200120149150509392505050565b6000546001600160a01b0316331461127f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6040517f42d65a8d0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516906342d65a8d906112e890869086908690600401614db7565b600060405180830381600087803b15801561130257600080fd5b505af1158015611316573d6000803e3d6000fd5b50505050505050565b6113688a8a8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c92508b91508a905089898961277c565b50505050505050505050565b6113bd338a8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c92508b91508a9050898989612a0c565b505050505050505050565b6113688a8a8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c92508b91508a9050898989612a0c565b6060815183511461148a5760405162461bcd60e51b815260206004820152602960248201527f455243313135353a206163636f756e747320616e6420696473206c656e67746860448201527f206d69736d617463680000000000000000000000000000000000000000000000606482015260840161091e565b6000835167ffffffffffffffff8111156114b457634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156114dd578160200160208202803683370190505b50905060005b845181101561157f5761154485828151811061150f57634e487b7160e01b600052603260045260246000fd5b602002602001015185838151811061153757634e487b7160e01b600052603260045260246000fd5b6020026020010151610939565b82828151811061156457634e487b7160e01b600052603260045260246000fd5b602090810291909101015261157881615093565b90506114e3565b509392505050565b3330146115d65760405162461bcd60e51b815260206004820181905260248201527f4c7a52656365697665723a2063616c6c6572206d757374206265204c7a417070604482015260640161091e565b61093384848484612ce3565b61ffff811660009081526001602052604090208054606091906116049061502b565b80601f01602080910402602001604051908101604052809291908181526020018280546116309061502b565b801561167d5780601f106116525761010080835404028352916020019161167d565b820191906000526020600020905b81548152906001019060200180831161166057829003601f168201915b50505050509050919050565b6113bd338a8a8a8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508c92508b91508a905089898961277c565b6000546001600160a01b0316331461172c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6117366000612e91565b565b6000546001600160a01b031633146117925760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b60005b815181101561186d577f0000000000000000000000005182a9ba9eacef7997056c247ea9b5e317224a166001600160a01b03166323b872dd30858585815181106117ef57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561184957600080fd5b505af115801561185d573d6000803e3d6000fd5b5050600190920191506117959050565b505050565b604080516001808252818301909252600091829182916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090506000826000815181106118de57634e487b7160e01b600052603260045260246000fd5b60200260200101818152505060008160008151811061190d57634e487b7160e01b600052603260045260246000fd5b602002602001018181525050600080838360405160200161193093929190614c06565b60405160208183030381529060405290507f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03166340a7bb108e30848c8c8c6040518763ffffffff1660e01b815260040161199796959493929190614d63565b604080518083038186803b1580156119ae57600080fd5b505afa1580156119c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e691906149a3565b945094505050509850989650505050505050565b60088054610afa9061502b565b610ae9338383612eee565b6000546001600160a01b03163314611a6c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b600a556009805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6000546001600160a01b03163314611af85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6040517fcbed8b9c0000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675169063cbed8b9c90611b659088908890889088908890600401614f23565b600060405180830381600087803b158015611b7f57600080fd5b505af11580156113bd573d6000803e3d6000fd5b61ffff85166000908152600260205260408082209051611bb4908790614af0565b908152604080516020928190038301902067ffffffffffffffff871660009081529252902054905080611c295760405162461bcd60e51b815260206004820152601d60248201527f4c7a52656365697665723a206e6f2073746f726564206d657373616765000000604482015260640161091e565b808383604051611c3a929190614ae0565b604051809103902014611c8f5760405162461bcd60e51b815260206004820152601b60248201527f4c7a52656365697665723a20696e76616c6964207061796c6f61640000000000604482015260640161091e565b61ffff86166000908152600260205260408082209051611cb0908890614af0565b90815260408051918290036020908101832067ffffffffffffffff8916600090815291522091909155633356ae4560e11b815230906366ad5c8a90611d019089908990899089908990600401614dd5565b600060405180830381600087803b158015611d1b57600080fd5b505af1158015611368573d6000803e3d6000fd5b60068054610afa9061502b565b6000546001600160a01b03163314611d965760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b61ffff83166000908152600160205260409020611db4908383613bb8565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab838383604051611de893929190614db7565b60405180910390a1505050565b6001600160a01b038516331480611e115750611e118533610770565b611e835760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260448201527f20617070726f7665640000000000000000000000000000000000000000000000606482015260840161091e565b610c688585858585612fe3565b6000546001600160a01b03163314611eea5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161091e565b6001600160a01b038116611f665760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161091e565b611f6f81612e91565b50565b6040517f096568f60000000000000000000000000000000000000000000000000000000081523060048201526060907f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03169063f5ecbdbc90829063096568f69060240160206040518083038186803b158015611ff557600080fd5b505afa158015612009573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061202d919061443f565b6040516001600160e01b031960e084901b16815261ffff918216600482015290871660248201523060448201526064810185905260840160006040518083038186803b15801561207c57600080fd5b505afa158015612090573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526120b89190810190614326565b95945050505050565b604051633356ae4560e11b815230906366ad5c8a906120ea908790879087908790600401614e15565b600060405180830381600087803b15801561210457600080fd5b505af1925050508015612115575060015b610933578080519060200120600260008661ffff1661ffff1681526020019081526020016000208460405161214a9190614af0565b90815260408051918290036020908101832067ffffffffffffffff87166000908152915220919091557fe6f254030bcb01ffd20558175c13fcaed6d1520be7becee4c961b65f79243b0d906121a6908690869086908690614e15565b60405180910390a1610933565b6001600160a01b0384166122135760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161091e565b81518351146122755760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161091e565b3360005b845181101561232e578381815181106122a257634e487b7160e01b600052603260045260246000fd5b6020026020010151600360008784815181106122ce57634e487b7160e01b600052603260045260246000fd5b602002602001015181526020019081526020016000206000886001600160a01b03166001600160a01b0316815260200190815260200160002060008282546123169190614f9d565b9091555081905061232681615093565b915050612279565b50846001600160a01b031660006001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161237f929190614c57565b60405180910390a4610c688160008787878761319a565b6060816123d657505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b811561240057806123ea81615093565b91506123f99050600a83614fb5565b91506123da565b60008167ffffffffffffffff81111561242957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612453576020820181803683370190505b5090505b84156124e457612468600183614fe8565b9150612475600a866150ae565b612480906030614f9d565b60f81b8183815181106124a357634e487b7160e01b600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506124dd600a86614fb5565b9450612457565b949350505050565b815183511461254e5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161091e565b6001600160a01b0384166125b25760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161091e565b3360005b845181101561270e5760008582815181106125e157634e487b7160e01b600052603260045260246000fd5b60200260200101519050600085838151811061260d57634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526003835260408082206001600160a01b038e1683529093529190912054909150818110156126b45760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161091e565b60008381526003602090815260408083206001600160a01b038e8116855292528083208585039055908b168252812080548492906126f3908490614f9d565b925050819055505050508061270790615093565b90506125b6565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb878760405161275e929190614c57565b60405180910390a461277481878787878761319a565b505050505050565b84518651146127f35760405162461bcd60e51b815260206004820152602d60248201527f4f4e4654313135353a2069647320616e6420616d6f756e7473206d757374206260448201527f652073616d65206c656e67746800000000000000000000000000000000000000606482015260840161091e565b336001600160a01b038a16148061280f575061280f8933610770565b6128815760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161091e565b61288e898989898961334f565b60008787876040516020016128a593929190614ccf565b60405160208183030381529060405290506128f98982878787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061335a92505050565b604051630f428ae960e31b815261ffff8a1660048201523060248201526000907f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b031690637a1457489060440160206040518083038186803b15801561296557600080fd5b505afa158015612979573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299d91906149c6565b9050886040516129ad9190614af0565b60405180910390208a61ffff168c6001600160a01b03167f2d31495ecbe799a81d5475c03585aa019860601fed836229d70e335b732eab3d8b8b866040516129f793929190614c7c565b60405180910390a45050505050505050505050565b336001600160a01b038a161480612a285750612a288933610770565b612a9a5760405162461bcd60e51b815260206004820152603260248201527f455243313135353a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000606482015260840161091e565b612aa7898989898961348b565b6040805160018082528183019092526000916020808301908036833750506040805160018082528183019092529293506000929150602080830190803683370190505090508782600081518110612b0e57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250508681600081518110612b3c57634e487b7160e01b600052603260045260246000fd5b6020026020010181815250506000898383604051602001612b5f93929190614ccf565b6040516020818303038152906040529050612bb38b82898989898080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061335a92505050565b604051630f428ae960e31b815261ffff8c1660048201523060248201526000907f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b031690637a1457489060440160206040518083038186803b158015612c1f57600080fd5b505afa158015612c33573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c5791906149c6565b90508a604051612c679190614af0565b60405180910390208c61ffff168e6001600160a01b03167f65f8f231660ef9add3da95eb0bbdae4c246f6c10e274fae37b17190637080d4c8d8d86604051612ccc93929190928352602083019190915267ffffffffffffffff16604082015260600190565b60405180910390a450505050505050505050505050565b600080600083806020019051810190612cfc9190614359565b925092509250600060148401519050825160011415612e3157612d71888285600081518110612d3b57634e487b7160e01b600052603260045260246000fd5b602002602001015185600081518110612d6457634e487b7160e01b600052603260045260246000fd5b6020026020010151613496565b7f8bccaf86bd8794bd0e54aefcb70b3fc3311241ce1d3079856c598be6f28d22ed888285600081518110612db557634e487b7160e01b600052603260045260246000fd5b602002602001015185600081518110612dde57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516040805161ffff90961686526001600160a01b039094169185019190915291830152606082015267ffffffffffffffff8816608082015260a00160405180910390a1612e87565b600183511115612e8757612e47888285856134bc565b7f33d59524159626dcbabfbceab8649c13e2c5dbe300a211f844fcff8697e81cc2888285858a604051612e7e959493929190614d08565b60405180910390a15b5050505050505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b816001600160a01b0316836001600160a01b03161415612f765760405162461bcd60e51b815260206004820152602960248201527f455243313135353a2073657474696e6720617070726f76616c2073746174757360448201527f20666f722073656c660000000000000000000000000000000000000000000000606482015260840161091e565b6001600160a01b03838116600081815260046020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0384166130475760405162461bcd60e51b815260206004820152602560248201527f455243313135353a207472616e7366657220746f20746865207a65726f206164604482015264647265737360d81b606482015260840161091e565b336000613053856134e2565b90506000613060856134e2565b905060008681526003602090815260408083206001600160a01b038c168452909152902054858110156130fb5760405162461bcd60e51b815260206004820152602a60248201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60448201527f72207472616e7366657200000000000000000000000000000000000000000000606482015260840161091e565b60008781526003602090815260408083206001600160a01b038d8116855292528083208985039055908a1682528120805488929061313a908490614f9d565b909155505060408051888152602081018890526001600160a01b03808b16928c821692918816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46113bd848a8a8a8a8a61353b565b6001600160a01b0384163b156127745760405163bc197c8160e01b81526001600160a01b0385169063bc197c81906131de9089908990889088908890600401614b65565b602060405180830381600087803b1580156131f857600080fd5b505af1925050508015613228575060408051601f3d908101601f191682019092526132259181019061430a565b60015b6132de57613234615104565b806308c379a0141561326e575061324961511c565b806132545750613270565b8060405162461bcd60e51b815260040161091e9190614cbc565b505b60405162461bcd60e51b815260206004820152603460248201527f455243313135353a207472616e7366657220746f206e6f6e204552433131353560448201527f526563656976657220696d706c656d656e746572000000000000000000000000606482015260840161091e565b6001600160e01b0319811663bc197c8160e01b146113165760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161091e565b610c68858383613646565b61ffff8516600090815260016020526040902080546133789061502b565b151590506133ee5760405162461bcd60e51b815260206004820152603260248201527f4c7a53656e643a2064657374696e6174696f6e20636861696e206973206e6f7460448201527f2061207472757374656420736f757263652e0000000000000000000000000000606482015260840161091e565b61ffff85166000908152600160205260409081902090517fc58031000000000000000000000000000000000000000000000000000000000081526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675169163c5803100913491613472918a91908a908a908a908a90600401614e54565b6000604051808303818588803b158015611d1b57600080fd5b610c688583836138a8565b61093383838360405180604001604052806002815260200161060f60f31b815250613a27565b61093383838360405180604001604052806002815260200161060f60f31b8152506121b3565b6040805160018082528183019092526060916000919060208083019080368337019050509050828160008151811061352a57634e487b7160e01b600052603260045260246000fd5b602090810291909101015292915050565b6001600160a01b0384163b156127745760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e619061357f9089908990889088908890600401614bc3565b602060405180830381600087803b15801561359957600080fd5b505af19250505080156135c9575060408051601f3d908101601f191682019092526135c69181019061430a565b60015b6135d557613234615104565b6001600160e01b0319811663f23a6e6160e01b146113165760405162461bcd60e51b815260206004820152602860248201527f455243313135353a204552433131353552656365697665722072656a656374656044820152676420746f6b656e7360c01b606482015260840161091e565b6001600160a01b0383166136a85760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161091e565b805182511461370a5760405162461bcd60e51b815260206004820152602860248201527f455243313135353a2069647320616e6420616d6f756e7473206c656e677468206044820152670dad2e6dac2e8c6d60c31b606482015260840161091e565b604080516020810190915260009081905233905b835181101561383b57600084828151811061374957634e487b7160e01b600052603260045260246000fd5b60200260200101519050600084838151811061377557634e487b7160e01b600052603260045260246000fd5b60209081029190910181015160008481526003835260408082206001600160a01b038c1683529093529190912054909150818110156138025760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161091e565b60009283526003602090815260408085206001600160a01b038b168652909152909220910390558061383381615093565b91505061371e565b5060006001600160a01b0316846001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb868660405161388c929190614c57565b60405180910390a4604080516020810190915260009052610933565b6001600160a01b03831661390a5760405162461bcd60e51b815260206004820152602360248201527f455243313135353a206275726e2066726f6d20746865207a65726f206164647260448201526265737360e81b606482015260840161091e565b336000613916846134e2565b90506000613923846134e2565b6040805160208082018352600091829052888252600381528282206001600160a01b038b16835290522054909150848110156139ad5760405162461bcd60e51b8152602060048201526024808201527f455243313135353a206275726e20616d6f756e7420657863656564732062616c604482015263616e636560e01b606482015260840161091e565b60008681526003602090815260408083206001600160a01b038b81168086529184528285208a8703905582518b81529384018a90529092908816917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a4604080516020810190915260009052611316565b6001600160a01b038416613a875760405162461bcd60e51b815260206004820152602160248201527f455243313135353a206d696e7420746f20746865207a65726f206164647265736044820152607360f81b606482015260840161091e565b336000613a93856134e2565b90506000613aa0856134e2565b905060008681526003602090815260408083206001600160a01b038b16845290915281208054879290613ad4908490614f9d565b909155505060408051878152602081018790526001600160a01b03808a1692600092918716917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62910160405180910390a46113168360008989898961353b565b828054613b409061502b565b90600052602060002090601f016020900481019282613b625760008555613ba8565b82601f10613b7b57805160ff1916838001178555613ba8565b82800160010185558215613ba8579182015b82811115613ba8578251825591602001919060010190613b8d565b50613bb4929150613c2c565b5090565b828054613bc49061502b565b90600052602060002090601f016020900481019282613be65760008555613ba8565b82601f10613bff5782800160ff19823516178555613ba8565b82800160010185558215613ba8579182015b82811115613ba8578235825591602001919060010190613c11565b5b80821115613bb45760008155600101613c2d565b6000613c4c83614f75565b604051613c598282615066565b809250848152858585011115613c6e57600080fd5b8484602083013760006020868301015250509392505050565b8035613c92816151a6565b919050565b600082601f830112613ca7578081fd5b81356020613cb482614f51565b604051613cc18282615066565b8381528281019150858301600585901b87018401881015613ce0578586fd5b855b85811015613cfe57813584529284019290840190600101613ce2565b5090979650505050505050565b600082601f830112613d1b578081fd5b81516020613d2882614f51565b604051613d358282615066565b8381528281019150858301600585901b87018401881015613d54578586fd5b855b85811015613cfe57815184529284019290840190600101613d56565b80358015158114613c9257600080fd5b60008083601f840112613d93578182fd5b50813567ffffffffffffffff811115613daa578182fd5b6020830191508360208285010111156110b757600080fd5b600082601f830112613dd2578081fd5b613de183833560208501613c41565b9392505050565b600082601f830112613df8578081fd5b8151613e0381614f75565b604051613e108282615066565b828152856020848701011115613e24578384fd5b6120b8836020830160208801614fff565b8035613c92816151d1565b600060208284031215613e51578081fd5b8135613de1816151a6565b60008060408385031215613e6e578081fd5b8235613e79816151a6565b91506020830135613e89816151a6565b809150509250929050565b600080600080600060a08688031215613eab578081fd5b8535613eb6816151a6565b94506020860135613ec6816151a6565b9350604086013567ffffffffffffffff80821115613ee2578283fd5b613eee89838a01613c97565b94506060880135915080821115613f03578283fd5b613f0f89838a01613c97565b93506080880135915080821115613f24578283fd5b50613f3188828901613dc2565b9150509295509295909350565b600080600080600060a08688031215613f55578283fd5b8535613f60816151a6565b94506020860135613f70816151a6565b93506040860135925060608601359150608086013567ffffffffffffffff811115613f99578182fd5b613f3188828901613dc2565b60008060408385031215613fb7578182fd5b8235613fc2816151a6565b9150602083013567ffffffffffffffff811115613fdd578182fd5b613fe985828601613c97565b9150509250929050565b60008060408385031215614005578182fd5b8235614010816151a6565b915061401e60208401613d72565b90509250929050565b6000806000806000806000806000806101008b8d031215614046578788fd5b61404f8b613c87565b995061405d60208c01613e35565b985060408b013567ffffffffffffffff8082111561407957898afd5b6140858e838f01613d82565b909a50985060608d013591508082111561409d578687fd5b6140a98e838f01613c97565b975060808d01359150808211156140be578687fd5b6140ca8e838f01613c97565b96506140d860a08e01613c87565b95506140e660c08e01613c87565b945060e08d01359150808211156140fb578384fd5b506141088d828e01613d82565b915080935050809150509295989b9194979a5092959850565b6000806000806000806000806000806101008b8d031215614140578384fd5b8a3561414b816151a6565b995060208b013561415b816151d1565b985060408b013567ffffffffffffffff80821115614177578586fd5b6141838e838f01613d82565b909a50985060608d0135975060808d0135965060a08d013591506141a6826151a6565b90945060c08c0135906141b8826151a6565b90935060e08c013590808211156140fb578384fd5b600080604083850312156141df578182fd5b82356141ea816151a6565b946020939093013593505050565b6000806040838503121561420a578182fd5b823567ffffffffffffffff80821115614221578384fd5b818501915085601f830112614234578384fd5b8135602061424182614f51565b60405161424e8282615066565b8381528281019150858301600585901b870184018b101561426d578889fd5b8896505b84871015614298578035614284816151a6565b835260019690960195918301918301614271565b50965050860135925050808211156142ae578283fd5b50613fe985828601613c97565b6000602082840312156142cc578081fd5b813567ffffffffffffffff8111156142e2578182fd5b6124e484828501613c97565b6000602082840312156142ff578081fd5b8135613de1816151bb565b60006020828403121561431b578081fd5b8151613de1816151bb565b600060208284031215614337578081fd5b815167ffffffffffffffff81111561434d578182fd5b6124e484828501613de8565b60008060006060848603121561436d578081fd5b835167ffffffffffffffff80821115614384578283fd5b61439087838801613de8565b945060208601519150808211156143a5578283fd5b6143b187838801613d0b565b935060408601519150808211156143c6578283fd5b506143d386828701613d0b565b9150509250925092565b6000602082840312156143ee578081fd5b813567ffffffffffffffff811115614404578182fd5b8201601f81018413614414578182fd5b6124e484823560208401613c41565b600060208284031215614434578081fd5b8135613de1816151d1565b600060208284031215614450578081fd5b8151613de1816151d1565b60008060008060608587031215614470578182fd5b843561447b816151d1565b9350602085013567ffffffffffffffff80821115614497578384fd5b6144a388838901613c97565b945060408701359150808211156144b8578384fd5b506144c587828801613d82565b95989497509550505050565b6000806000604084860312156144e5578081fd5b83356144f0816151d1565b9250602084013567ffffffffffffffff81111561450b578182fd5b61451786828701613d82565b9497909650939450505050565b600080600080600080600080600060e08a8c031215614541578283fd5b61454a8a613e35565b985060208a013567ffffffffffffffff80821115614566578485fd5b6145728d838e01613d82565b909a50985060408c013591508082111561458a578485fd5b6145968d838e01613c97565b975060608c01359150808211156145ab578485fd5b6145b78d838e01613c97565b96506145c560808d01613c87565b95506145d360a08d01613c87565b945060c08c01359150808211156145e8578384fd5b506145f58c828d01613d82565b915080935050809150509295985092959850929598565b600080600080600080600080600060e08a8c031215614629578283fd5b8935614634816151d1565b985060208a013567ffffffffffffffff80821115614650578485fd5b61465c8d838e01613d82565b909a50985060408c0135975060608c0135965060808c0135915061467f826151a6565b90945060a08b013590614691826151a6565b90935060c08b013590808211156145e8578384fd5b60008060008060008060008060c0898b0312156146c1578182fd5b88356146cc816151d1565b9750602089013567ffffffffffffffff808211156146e8578384fd5b6146f48c838d01613d82565b909950975060408b0135965060608b0135955087915061471660808c01613d72565b945060a08b013591508082111561472b578384fd5b506147388b828c01613d82565b999c989b5096995094979396929594505050565b600080600060608486031215614760578081fd5b833561476b816151d1565b9250602084013567ffffffffffffffff811115614786578182fd5b61479286828701613dc2565b925050604084013590509250925092565b6000806000806000608086880312156147ba578283fd5b85356147c5816151d1565b9450602086013567ffffffffffffffff808211156147e1578485fd5b6147ed89838a01613dc2565b9550604088013591506147ff826151e1565b90935060608701359080821115614814578283fd5b5061482188828901613d82565b969995985093965092949392505050565b60008060008060808587031215614847578182fd5b8435614852816151d1565b9350602085013567ffffffffffffffff8082111561486e578384fd5b61487a88838901613dc2565b94506040870135915061488c826151e1565b909250606086013590808211156148a1578283fd5b506148ae87828801613dc2565b91505092959194509250565b600080600080608085870312156148cf578182fd5b84356148da816151d1565b935060208501356148ea816151d1565b925060408501356148fa816151a6565b9396929550929360600135925050565b600080600080600060808688031215614921578283fd5b853561492c816151d1565b9450602086013561493c816151d1565b935060408601359250606086013567ffffffffffffffff81111561495e578182fd5b61482188828901613d82565b60006020828403121561497b578081fd5b5035919050565b60008060408385031215614994578182fd5b50508035926020909101359150565b600080604083850312156149b5578182fd5b505080516020909101519092909150565b6000602082840312156149d7578081fd5b8151613de1816151e1565b6000815180845260208085019450808401835b83811015614a11578151875295820195908201906001016149f5565b509495945050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008151808452614a5d816020860160208601614fff565b601f01601f19169290920160200192915050565b60008154614a7e8161502b565b60018281168015614a965760018114614aa757614ad6565b60ff19841687528287019450614ad6565b8560005260208060002060005b85811015614acd5781548a820152908401908201614ab4565b50505082870194505b5050505092915050565b8183823760009101908152919050565b60008251614b02818460208701614fff565b9190910192915050565b6000613de18284614a71565b6000614b248285614a71565b8351614b34818360208801614fff565b7f2e6a736f6e0000000000000000000000000000000000000000000000000000009101908152600501949350505050565b60006001600160a01b03808816835280871660208401525060a06040830152614b9160a08301866149e2565b8281036060840152614ba381866149e2565b90508281036080840152614bb78185614a45565b98975050505050505050565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152614bfb60a0830184614a45565b979650505050505050565b6001600160a01b0384168152606060208201526000614c2860608301856149e2565b8281036040840152614c3a81856149e2565b9695505050505050565b602081526000613de160208301846149e2565b604081526000614c6a60408301856149e2565b82810360208401526120b881856149e2565b606081526000614c8f60608301866149e2565b8281036020840152614ca181866149e2565b91505067ffffffffffffffff83166040830152949350505050565b602081526000613de16020830184614a45565b606081526000614ce26060830186614a45565b8281036020840152614cf481866149e2565b90508281036040840152614c3a81856149e2565b61ffff861681526001600160a01b038516602082015260a060408201526000614d3460a08301866149e2565b8281036060840152614d4681866149e2565b91505067ffffffffffffffff831660808301529695505050505050565b61ffff871681526001600160a01b038616602082015260a060408201526000614d8f60a0830187614a45565b85151560608401528281036080840152614daa818587614a1c565b9998505050505050505050565b61ffff841681526040602082015260006120b8604083018486614a1c565b61ffff86168152608060208201526000614df26080830187614a45565b67ffffffffffffffff861660408401528281036060840152614bb7818587614a1c565b61ffff85168152608060208201526000614e326080830186614a45565b67ffffffffffffffff851660408401528281036060840152614bfb8185614a45565b61ffff871681526000602060c081840152818854614e718161502b565b8060c087015260e0600180841660008114614e935760018114614ea857614ed3565b60ff1985168984015261010089019550614ed3565b8d8852868820885b85811015614ecb5781548b8201860152908301908801614eb0565b8a0184019650505b50505050508381036040850152614eea8189614a45565b915050614f0260608401876001600160a01b03169052565b6001600160a01b038516608084015282810360a0840152614daa8185614a45565b600061ffff808816835280871660208401525084604083015260806060830152614bfb608083018486614a1c565b600067ffffffffffffffff821115614f6b57614f6b6150ee565b5060051b60200190565b600067ffffffffffffffff821115614f8f57614f8f6150ee565b50601f01601f191660200190565b60008219821115614fb057614fb06150c2565b500190565b600082614fc457614fc46150d8565b500490565b6000816000190483118215151615614fe357614fe36150c2565b500290565b600082821015614ffa57614ffa6150c2565b500390565b60005b8381101561501a578181015183820152602001615002565b838111156109335750506000910152565b600181811c9082168061503f57607f821691505b6020821081141561506057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8201601f1916810167ffffffffffffffff8111828210171561508c5761508c6150ee565b6040525050565b60006000198214156150a7576150a76150c2565b5060010190565b6000826150bd576150bd6150d8565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b600060033d111561511957600481823e5160e01c5b90565b600060443d101561512a5790565b6040516003193d81016004833e81513d67ffffffffffffffff816024840111818411171561515a57505050505090565b82850191508151818111156151725750505050505090565b843d870101602082850101111561518c5750505050505090565b61519b60208286010187615066565b509095945050505050565b6001600160a01b0381168114611f6f57600080fd5b6001600160e01b031981168114611f6f57600080fd5b61ffff81168114611f6f57600080fd5b67ffffffffffffffff81168114611f6f57600080fdfea2646970667358221220db4c74db7dcd04bafa2dd6c359c0006f42b75fcec146c8f10b0a330249dec97164736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: Yes (1337 runs)
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_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 511 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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 owner nor approved"
);
_safeTransferFrom(from, to, id, amount, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: transfer caller is not owner nor approved"
);
_safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
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}.
*
* 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`
*
* 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}.
*
* 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 a {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 `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 _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 v4.4.1 (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 be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
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);
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
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;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
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);
}
1155.sol 72 lines
pragma solidity ^0.8.4;
import "../token/onft/ONFT1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract TinyGirls is ONFT1155 {
string public name = "TinyGirls";
string public symbol = "TG";
//@notice Old TinyGirls Contract
IERC721 public immutable oldContract;
//@notice Support for ERC2981
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
//@notice Royalty Variables
address private _royaltyAddress;
uint256 private _royaltyPercentage;
constructor(address _layerZeroEndpoint, address _oldContract, address royaltyAddress, uint256 royaltyPercentage) ONFT1155("", _layerZeroEndpoint) {
oldContract = IERC721(_oldContract);
_royaltyAddress = royaltyAddress;
_royaltyPercentage = royaltyPercentage;
baseTokenURI = "ipfs://QmTkA2ue7mqfe7zYSNE4BYoanm6bcSM5WHz2S5LDuvjxbz/";
}
//@notice Migrates a oldContract token to current
function remint(uint256[] memory tokenIds) external {
uint256[] memory amounts = new uint256[](tokenIds.length);
unchecked {
for(uint256 i; i < tokenIds.length; i++) {
uint256 currentId = tokenIds[i];
amounts[i] = 1;
oldContract.transferFrom(msg.sender, address(this), currentId);
}
}
_mintBatch(msg.sender, tokenIds, amounts, "");
}
function withdraw(address user, uint256[] memory tokenIds) external onlyOwner {
unchecked {
for(uint256 i; i < tokenIds.length;i++) {
oldContract.transferFrom(address(this), user, tokenIds[i]);
}
}
}
//@notice Update royalty percentage
//@param percentage to edit
function editRoyaltyFee(address user, uint256 bps) external onlyOwner {
_royaltyPercentage = bps;
_royaltyAddress = user;
}
//@notice View royalty info for tokens
function royaltyInfo(uint256, uint256 value) external view returns (address, uint256) {
return (_royaltyAddress, value * _royaltyPercentage / 10000);
}
function uri(uint256 tokenId) override public view returns (string memory) {
// Tokens minted above the supply cap will not have associated metadata.
return string(abi.encodePacked(baseTokenURI, Strings.toString(tokenId), ".json"));
}
function setURI(string memory newURI) external onlyOwner {
baseTokenURI = newURI;
}
}
ILayerZeroEndpoint.sol 87 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external;
// @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}
ILayerZeroReceiver.sol 12 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroReceiver {
// @notice LayerZero endpoint will invoke this function to deliver the message on the destination
// @param _srcChainId - the source endpoint identifier
// @param _srcAddress - the source sending contract address from the source chain
// @param _nonce - the ordered message nonce
// @param _payload - the signed payload is the UA bytes has encoded to be sent
function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;
}
ILayerZeroUserApplicationConfig.sol 25 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}
LzApp.sol 84 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "../interfaces/ILayerZeroReceiver.sol";
import "../interfaces/ILayerZeroUserApplicationConfig.sol";
import "../interfaces/ILayerZeroEndpoint.sol";
/*
* a generic LzReceiver implementation
*/
abstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig {
ILayerZeroEndpoint internal immutable lzEndpoint;
mapping(uint16 => bytes) internal trustedRemoteLookup;
event SetTrustedRemote(uint16 _srcChainId, bytes _srcAddress);
constructor(address _endpoint) {
lzEndpoint = ILayerZeroEndpoint(_endpoint);
}
function lzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) external override {
// lzReceive must be called by the endpoint for security
require(_msgSender() == address(lzEndpoint));
// if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote.
require(_srcAddress.length == trustedRemoteLookup[_srcChainId].length && keccak256(_srcAddress) == keccak256(trustedRemoteLookup[_srcChainId]), "LzReceiver: invalid source sending contract");
_blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
// abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging
function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;
function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParam) internal {
require(trustedRemoteLookup[_dstChainId].length != 0, "LzSend: destination chain is not a trusted source.");
lzEndpoint.send{value: msg.value}(_dstChainId, trustedRemoteLookup[_dstChainId], _payload, _refundAddress, _zroPaymentAddress, _adapterParam);
}
//---------------------------UserApplication config----------------------------------------
function getConfig(uint16, uint16 _chainId, address, uint _configType) external view returns (bytes memory) {
return lzEndpoint.getConfig(lzEndpoint.getSendVersion(address(this)), _chainId, address(this), _configType);
}
// generic config for LayerZero user Application
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner {
lzEndpoint.setConfig(_version, _chainId, _configType, _config);
}
function setSendVersion(uint16 _version) external override onlyOwner {
lzEndpoint.setSendVersion(_version);
}
function setReceiveVersion(uint16 _version) external override onlyOwner {
lzEndpoint.setReceiveVersion(_version);
}
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner {
lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress);
}
// allow owner to set it multiple times.
function setTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external onlyOwner {
trustedRemoteLookup[_srcChainId] = _srcAddress;
emit SetTrustedRemote(_srcChainId, _srcAddress);
}
function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) {
bytes memory trustedSource = trustedRemoteLookup[_srcChainId];
return keccak256(trustedSource) == keccak256(_srcAddress);
}
//--------------------------- VIEW FUNCTION ----------------------------------------
// interacting with the LayerZero Endpoint and remote contracts
function getTrustedRemote(uint16 _chainId) external view returns (bytes memory) {
return trustedRemoteLookup[_chainId];
}
function getLzEndpoint() external view returns (address) {
return address(lzEndpoint);
}
}
NonblockingLzApp.sol 50 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./LzApp.sol";
/*
* the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel
* this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking
* NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress)
*/
abstract contract NonblockingLzApp is LzApp {
constructor(address _endpoint) LzApp(_endpoint) {}
mapping(uint16 => mapping(bytes => mapping(uint => bytes32))) public failedMessages;
event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload);
// overriding the virtual function in LzReceiver
function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override {
// try-catch all errors/exceptions
try this.nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload) {
// do nothing
} catch {
// error / exception
failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload);
emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload);
}
}
function nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) public virtual {
// only internal transaction
require(_msgSender() == address(this), "LzReceiver: caller must be LzApp");
_nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
//@notice override this function
function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual;
function retryMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes calldata _payload) external payable virtual {
// assert there is message to retry
bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce];
require(payloadHash != bytes32(0), "LzReceiver: no stored message");
require(keccak256(_payload) == payloadHash, "LzReceiver: invalid payload");
// clear the stored message
failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0);
// execute the message. revert if it fails again
this.nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
}
IONFT1155.sol 43 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ONFT standard
*/
interface IONFT1155 {
event SendToChain(address indexed _sender, uint16 indexed _dstChainId, bytes indexed _toAddress, uint _tokenId, uint _amount, uint64 _nonce);
event SendBatchToChain(address indexed _sender, uint16 indexed _dstChainId, bytes indexed _toAddress, uint[] _tokenIds, uint[] _amounts, uint64 _nonce);
event ReceiveFromChain(uint16 _srcChainId, address _toAddress, uint _tokenId, uint _amount, uint64 _nonce);
event ReceiveBatchFromChain(uint16 _srcChainId, address _toAddress, uint[] _tokenIds, uint[] _amounts, uint64 _nonce);
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenId - token Id to transfer
// _amount - amount of the tokens to transfer
// _refundAddress - address on src that will receive refund for any overpayment of L0 fees
// _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro
// _adapterParam - flexible bytes array to indicate messaging adapter services in L0
function send(uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable;
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenIds - token Ids to transfer
// _amounts - amounts of the tokens to transfer
// _refundAddress - address on src that will receive refund for any overpayment of L0 fees
// _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro
// _adapterParam - flexible bytes array to indicate messaging adapter services in L0
function sendBatch(uint16 _dstChainId, bytes calldata _toAddress, uint[] memory _tokenIds, uint[] memory amounts, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable;
// _dstChainId - L0 defined chain id to send tokens too
// _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain
// _tokenId - token Id to transfer
// _amount - amount of the tokens to transfer
// _useZro - indicates to use zro to pay L0 fees
// _adapterParam - flexible bytes array to indicate messaging adapter services in L0
function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);
// _dstChainId - L0 defined chain id to send tokens too
// _tokenIds - tokens Id to transfer
function estimateSendBatchFee(uint16 _dstChainId, uint[] memory _tokenIds, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee);
}
ONFT1155.sol 179 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IONFT1155.sol";
import "../../lzApp/NonblockingLzApp.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
// NOTE: this ONFT contract has no public minting logic.
// must implement your own minting logic in child classes
contract ONFT1155 is IONFT1155, NonblockingLzApp, ERC1155 {
string public baseTokenURI;
constructor(string memory uri_, address _lzEndpoint) ERC1155(uri_) NonblockingLzApp(_lzEndpoint) {}
function estimateSendFee(
uint16 _dstChainId,
bytes calldata, /*_toAddress*/
uint, /*_tokenId*/
uint, /*_amount*/
bool _useZro,
bytes calldata _adapterParams
) external view virtual override returns (uint nativeFee, uint zroFee) {
// by sending a uint array, we can decode the payload on the other side the same way regardless if its a batch
uint[] memory tokenIds = new uint[](1);
uint[] memory amounts = new uint[](1);
tokenIds[0] = 0;
amounts[0] = 0;
bytes memory payload = abi.encode(address(0x0), tokenIds, amounts);
return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams);
}
function estimateSendBatchFee(
uint16 _dstChainId,
uint[] memory _tokenIds,
bytes calldata _adapterParams
) external view virtual override returns (uint nativeFee, uint zroFee) {
uint[] memory _amounts = new uint256[](_tokenIds.length);
for(uint i;i<_tokenIds.length;i++) {
_amounts[i] = 1;
}
bytes memory payload = abi.encode(address(0x0), _tokenIds, _amounts);
return lzEndpoint.estimateFees(_dstChainId, address(this), payload, false, _adapterParams);
}
function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable virtual {
_send(_from, _dstChainId, _toAddress, _tokenId, _amount, _refundAddress, _zroPaymentAddress, _adapterParam);
}
function sendBatchFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable virtual {
_sendBatch(_from, _dstChainId, _toAddress, _tokenIds, _amounts, _refundAddress, _zroPaymentAddress, _adapterParam);
}
function send(uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable virtual override {
_send(_msgSender(), _dstChainId, _toAddress, _tokenId, _amount, _refundAddress, _zroPaymentAddress, _adapterParam);
}
function sendBatch(uint16 _dstChainId, bytes calldata _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) external payable virtual override {
_sendBatch(_msgSender(), _dstChainId, _toAddress, _tokenIds, _amounts, _refundAddress, _zroPaymentAddress, _adapterParam);
}
function _send(address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) internal virtual {
require(_msgSender() == _from || isApprovedForAll(_from, _msgSender()), "ERC1155: transfer caller is not owner nor approved");
// on the src chain we burn the tokens before sending
_beforeSend(_from, _dstChainId, _toAddress, _tokenId, _amount);
// by sending a uint array, we can decode the payload on the other side the same way regardless if its a batch
uint[] memory tokenIds = new uint[](1);
uint[] memory amounts = new uint[](1);
tokenIds[0] = _tokenId;
amounts[0] = _amount;
bytes memory payload = abi.encode(_toAddress, tokenIds, amounts);
// push the tx to L0
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParam);
uint64 nonce = lzEndpoint.getOutboundNonce(_dstChainId, address(this));
emit SendToChain(_from, _dstChainId, _toAddress, _tokenId, _amount, nonce);
_afterSend(_from, _dstChainId, _toAddress, _tokenId, _amount);
}
function _sendBatch(address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParam) internal virtual {
require(_tokenIds.length == _amounts.length, "ONFT1155: ids and amounts must be same length");
require(_msgSender() == _from || isApprovedForAll(_from, _msgSender()), "ERC1155: transfer caller is not owner nor approved");
// on the src chain we burn the tokens before sending
_beforeSendBatch(_from, _dstChainId, _toAddress, _tokenIds, _amounts);
bytes memory payload = abi.encode(_toAddress, _tokenIds, _amounts);
_lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParam);
uint64 nonce = lzEndpoint.getOutboundNonce(_dstChainId, address(this));
emit SendBatchToChain(_from, _dstChainId, _toAddress, _tokenIds, _amounts, nonce);
_afterSendBatch(_from, _dstChainId, _toAddress, _tokenIds, _amounts);
}
function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override {
_beforeReceive(_srcChainId, _srcAddress, _payload);
// decode and load the toAddress
(bytes memory toAddress, uint[] memory tokenIds, uint[] memory amounts) = abi.decode(_payload, (bytes, uint[], uint[]));
address localToAddress;
assembly {
localToAddress := mload(add(toAddress, 20))
}
// mint the tokens on the dst chain
if (tokenIds.length == 1) {
_afterReceive(_srcChainId, localToAddress, tokenIds[0], amounts[0]);
emit ReceiveFromChain(_srcChainId, localToAddress, tokenIds[0], amounts[0], _nonce);
} else if (tokenIds.length > 1) {
_afterReceiveBatch(_srcChainId, localToAddress, tokenIds, amounts);
emit ReceiveBatchFromChain(_srcChainId, localToAddress, tokenIds, amounts, _nonce);
}
}
function _beforeSend(
address _from,
uint16, /* _dstChainId */
bytes memory, /* _toAddress */
uint _tokenId,
uint _amount
) internal virtual {
_burn(_from, _tokenId, _amount);
}
function _beforeSendBatch(
address _from,
uint16, /* _dstChainId */
bytes memory, /* _toAddress */
uint[] memory _tokenIds,
uint[] memory _amounts
) internal virtual {
_burnBatch(_from, _tokenIds, _amounts);
}
function _afterSend(
address, /* _from */
uint16, /* _dstChainId */
bytes memory, /* _toAddress */
uint, /* _tokenId */
uint /* _amount */
) internal virtual {}
function _afterSendBatch(
address, /* _from */
uint16, /* _dstChainId */
bytes memory, /* _toAddress */
uint[] memory, /* _tokenIds */
uint[] memory /* _amounts */
) internal virtual {}
function _beforeReceive(
uint16, /* _srcChainId */
bytes memory, /* _srcAddress */
bytes memory /* _payload */
) internal virtual {}
function _afterReceive(
uint16, /* _srcChainId */
address _toAddress,
uint _tokenId,
uint _amount
) internal virtual {
_mint(_toAddress, _tokenId, _amount, "0x");
}
function _afterReceiveBatch(
uint16, /* _srcChainId */
address _toAddress,
uint[] memory _tokenIds,
uint[] memory _amounts
) internal virtual {
_mintBatch(_toAddress, _tokenIds, _amounts, "0x");
}
}
Read Contract
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
baseTokenURI 0xd547cfb7 → string
estimateSendBatchFee 0x2834a257 → uint256, uint256
estimateSendFee 0x8608e5f8 → uint256, uint256
failedMessages 0x8ee74912 → bytes32
getConfig 0xf5ecbdbc → bytes
getLzEndpoint 0xdacbcbe2 → address
getTrustedRemote 0x69b41f95 → bytes
isApprovedForAll 0xe985e9c5 → bool
isTrustedRemote 0x3d8b38f6 → bool
name 0x06fdde03 → string
oldContract 0x30503c4e → address
owner 0x8da5cb5b → address
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
uri 0x0e89341c → string
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
editRoyaltyFee 0xb7e65700
address user
uint256 bps
forceResumeReceive 0x42d65a8d
uint16 _srcChainId
bytes _srcAddress
lzReceive 0x001d3567
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
nonblockingLzReceive 0x66ad5c8a
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
remint 0x0c955a80
uint256[] tokenIds
renounceOwnership 0x715018a6
No parameters
retryMessage 0xd1deba1f
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 id
uint256 amount
bytes data
send 0x4be699cd
uint16 _dstChainId
bytes _toAddress
uint256 _tokenId
uint256 _amount
address _refundAddress
address _zroPaymentAddress
bytes _adapterParam
sendBatch 0x6f6120a6
uint16 _dstChainId
bytes _toAddress
uint256[] _tokenIds
uint256[] _amounts
address _refundAddress
address _zroPaymentAddress
bytes _adapterParam
sendBatchFrom 0x4ab4e687
address _from
uint16 _dstChainId
bytes _toAddress
uint256[] _tokenIds
uint256[] _amounts
address _refundAddress
address _zroPaymentAddress
bytes _adapterParam
sendFrom 0x4db8226a
address _from
uint16 _dstChainId
bytes _toAddress
uint256 _tokenId
uint256 _amount
address _refundAddress
address _zroPaymentAddress
bytes _adapterParam
setApprovalForAll 0xa22cb465
address operator
bool approved
setConfig 0xcbed8b9c
uint16 _version
uint16 _chainId
uint256 _configType
bytes _config
setReceiveVersion 0x10ddb137
uint16 _version
setSendVersion 0x07e0db17
uint16 _version
setTrustedRemote 0xeb8d72b7
uint16 _srcChainId
bytes _srcAddress
setURI 0x02fe5305
string newURI
transferOwnership 0xf2fde38b
address newOwner
withdraw 0x8293744b
address user
uint256[] tokenIds
Recent Transactions
No transactions found for this address