Address Contract Partially Verified
Address
0x1DBE39E071f2e580C1C0C49CFB19B9Edb5b89B2D
Balance
0 ETH
Nonce
1
Code Size
20831 bytes
Creator
0xC8ce3Bd5...848a at tx 0x676bebe7...904bdb
Indexed Transactions
0
Contract Bytecode
20831 bytes
0x608060405234801561001057600080fd5b50600436106101e45760003560e01c806369b520171161010f5780639abc8320116100a2578063e2c7f33811610071578063e2c7f33814610566578063e985e9c514610582578063f242432a146105b2578063f2fde38b146105ce576101e4565b80639abc8320146104f25780639e42639914610510578063a22cb4651461052c578063d0414c9d14610548576101e4565b806382295a2d116100de57806382295a2d146104805780638d2bb0931461049c5780638da5cb5b146104b857806398faf29b146104d6576101e4565b806369b520171461040e5780636c52c3fb1461042a578063704fe71014610446578063715018a614610476576101e4565b80631f320331116101875780633a330022116101565780633a3300221461038657806341f43434146103a25780634e1273f4146103c057806358884432146103f0576101e4565b80631f320331146102ed5780632a55205a1461031d5780632eb2c2d61461034e578063337648b21461036a576101e4565b806306fdde03116101c357806306fdde0314610265578063084e9e24146102835780630e89341c1461029f57806318160ddd146102cf576101e4565b8062fdd58e146101e957806301ffc9a71461021957806302fe530514610249575b600080fd5b61020360048036038101906101fe91906131e9565b6105ea565b6040516102109190613238565b60405180910390f35b610233600480360381019061022e91906132ab565b6106b2565b60405161024091906132f3565b60405180910390f35b610263600480360381019061025e9190613454565b6106c4565b005b61026d61072a565b60405161027a9190613525565b60405180910390f35b61029d600480360381019061029891906135e8565b6107b8565b005b6102b960048036038101906102b49190613691565b61098f565b6040516102c69190613525565b60405180910390f35b6102d76109cd565b6040516102e49190613238565b60405180910390f35b610307600480360381019061030291906136be565b6109d3565b6040516103149190613238565b60405180910390f35b610337600480360381019061033291906136fe565b6109f8565b60405161034592919061374d565b60405180910390f35b6103686004803603810190610363919061383e565b610ac9565b005b610384600480360381019061037f91906139ee565b610b1c565b005b6103a0600480360381019061039b9190613a66565b610c3a565b005b6103aa610c86565b6040516103b79190613af2565b60405180910390f35b6103da60048036038101906103d59190613bd0565b610c98565b6040516103e79190613d06565b60405180910390f35b6103f8610db1565b6040516104059190613d28565b60405180910390f35b61042860048036038101906104239190613d43565b610dd7565b005b610444600480360381019061043f9190613a66565b61104a565b005b610460600480360381019061045b9190613691565b611096565b60405161046d9190613525565b60405180910390f35b61047e611136565b005b61049a60048036038101906104959190613e5c565b61114a565b005b6104b660048036038101906104b19190613eb8565b6111d0565b005b6104c061146b565b6040516104cd9190613d28565b60405180910390f35b6104f060048036038101906104eb9190613f61565b611495565b005b6104fa611568565b6040516105079190613525565b60405180910390f35b61052a6004803603810190610525919061400a565b6115f6565b005b61054660048036038101906105419190614117565b611aa4565b005b610550611abd565b60405161055d9190613d28565b60405180910390f35b610580600480360381019061057b9190614157565b611ae3565b005b61059c600480360381019061059791906141aa565b611afb565b6040516105a991906132f3565b60405180910390f35b6105cc60048036038101906105c791906141ea565b611b8f565b005b6105e860048036038101906105e39190613a66565b611be2565b005b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361065a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610651906142f3565b60405180910390fd5b60008083815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b60006106bd82611c65565b9050919050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461071e57600080fd5b61072781611cdf565b50565b6006805461073790614342565b80601f016020809104026020016040519081016040528092919081815260200182805461076390614342565b80156107b05780601f10610785576101008083540402835291602001916107b0565b820191906000526020600020905b81548152906001019060200180831161079357829003601f168201915b505050505081565b6107d78473ffffffffffffffffffffffffffffffffffffffff16611cf9565b15610987578373ffffffffffffffffffffffffffffffffffffffff1663f23a6e6187878686866040518663ffffffff1660e01b815260040161081d9594939291906143c8565b6020604051808303816000875af192505050801561085957506040513d601f19601f820116820180604052508101906108569190614437565b60015b6108fe57610865614471565b806308c379a0036108c15750610879614493565b8061088457506108c3565b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b89190613525565b60405180910390fd5b505b6040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f590614595565b60405180910390fd5b63f23a6e6160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614610985576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097c90614627565b60405180910390fd5b505b505050505050565b60606003600160008481526020019081526020016000206040516020016109b79291906146e6565b6040516020818303038152906040529050919050565b60075481565b6000602052816000526040600020602052806000526040600020600091509150505481565b6000806000600560008681526020019081526020016000206040518060400160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016000820160149054906101000a900462ffffff1662ffffff1662ffffff1681525050905080600001519250612710816020015162ffffff1685610ab59190614739565b610abf91906147c2565b9150509250929050565b843373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610b0757610b0633611d1c565b5b610b148686868686611e19565b505050505050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b7657600080fd5b8051825114610bba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bb19061483f565b60405180910390fd5b60005b8251811015610c3557818181518110610bd957610bd861485f565b5b602002602001015160016000858481518110610bf857610bf761485f565b5b602002602001015181526020019081526020016000209080519060200190610c2192919061309e565b508080610c2d9061488e565b915050610bbd565b505050565b610c42611eba565b80600960006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6daaeb6d7670e522a718067333cd4e81565b60608151835114610cde576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd590614948565b60405180910390fd5b6000835167ffffffffffffffff811115610cfb57610cfa613329565b5b604051908082528060200260200182016040528015610d295781602001602082028036833780820191505090505b50905060005b8451811015610da657610d76858281518110610d4e57610d4d61485f565b5b6020026020010151858381518110610d6957610d6861485f565b5b60200260200101516105ea565b828281518110610d8957610d8861485f565b5b60200260200101818152505080610d9f9061488e565b9050610d2f565b508091505092915050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e3157600080fd5b81518551148015610e43575080518551145b610e82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e799061483f565b60405180910390fd5b610e9d86868660405180602001604052806000815250611f38565b60005b8551811015610f95576000828281518110610ebe57610ebd61485f565b5b60200260200101511115610f2657610f25868281518110610ee257610ee161485f565b5b6020026020010151848381518110610efd57610efc61485f565b5b6020026020010151848481518110610f1857610f1761485f565b5b6020026020010151612198565b5b838181518110610f3957610f3861485f565b5b602002602001015160016000888481518110610f5857610f5761485f565b5b602002602001015181526020019081526020016000209080519060200190610f8192919061309e565b508080610f8d9061488e565b915050610ea0565b50600080600090505b86518110156110275760005b865181101561101357868181518110610fc657610fc561485f565b5b6020026020010151888381518110610fe157610fe061485f565b5b6020026020010151610ff39190614739565b83610ffe9190614968565b9250808061100b9061488e565b915050610faa565b50808061101f9061488e565b915050610f9e565b50806007600082825461103a9190614968565b9250508190555050505050505050565b611052611eba565b80600860006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600160205280600052604060002060009150905080546110b590614342565b80601f01602080910402602001604051908101604052809291908181526020018280546110e190614342565b801561112e5780601f106111035761010080835404028352916020019161112e565b820191906000526020600020905b81548152906001019060200180831161111157829003601f168201915b505050505081565b61113e611eba565b6111486000612294565b565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146111a457600080fd5b806001600084815260200190815260200160002090805190602001906111cb92919061309e565b505050565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461122a57600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff1603611299576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161129090614a0a565b60405180910390fd5b600160008086815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546112f99190614968565b925050819055506001600760008282546113139190614968565b925050819055508260016000868152602001908152602001600020908051906020019061134192919061309e565b50600081111561135757611356848383612198565b5b600061136161235a565b90508673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628860016040516113db929190614a65565b60405180910390a48573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6288600160405161145a929190614a65565b60405180910390a450505050505050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146114ef57600080fd5b61150a86868660405180602001604052806000815250612362565b600081111561151f5761151e858383612198565b5b8260016000878152602001908152602001600020908051906020019061154692919061309e565b5083600760008282546115599190614968565b92505081905550505050505050565b6003805461157590614342565b80601f01602080910402602001604051908101604052809291908181526020018280546115a190614342565b80156115ee5780601f106115c3576101008083540402835291602001916115ee565b820191906000526020600020905b8154815290600101906020018083116115d157829003601f168201915b505050505081565b600860009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461165057600080fd5b85518451148015611662575082518451145b6116a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116989061483f565b60405180910390fd5b60006116ab61235a565b905060005b8551811015611a805760016000808884815181106116d1576116d061485f565b5b6020026020010151815260200190815260200160002060008a84815181106116fc576116fb61485f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461174d9190614968565b925050819055506117a78260008a848151811061176d5761176c61485f565b5b60200260200101518985815181106117885761178761485f565b5b60200260200101516001604051806020016040528060008152506107b8565b60008311156117d6576117d58682815181106117c6576117c561485f565b5b60200260200101518585612198565b5b8481815181106117e9576117e861485f565b5b6020026020010151600160008884815181106118085761180761485f565b5b60200260200101518152602001908152602001600020908051906020019061183192919061309e565b50600073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff160361191f578781815181106118795761187861485f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628985815181106118fa576118f961485f565b5b60200260200101516001604051611912929190614a65565b60405180910390a4611a6d565b8673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628985815181106119995761199861485f565b5b602002602001015160016040516119b1929190614a65565b60405180910390a48781815181106119cc576119cb61485f565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62898581518110611a4c57611a4b61485f565b5b60200260200101516001604051611a64929190614a65565b60405180910390a45b8080611a789061488e565b9150506116b0565b50845160076000828254611a949190614968565b9250508190555050505050505050565b81611aae81611d1c565b611ab88383612512565b505050565b600960009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611aeb611eba565b611af6838383612198565b505050565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b843373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611bcd57611bcc33611d1c565b5b611bda8686868686612528565b505050505050565b611bea611eba565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603611c59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c5090614b00565b60405180910390fd5b611c6281612294565b50565b60007f2a55205a000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161480611cd85750611cd7826125c9565b5b9050919050565b8060039080519060200190611cf592919061309e565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b60006daaeb6d7670e522a718067333cd4e73ffffffffffffffffffffffffffffffffffffffff163b1115611e16576daaeb6d7670e522a718067333cd4e73ffffffffffffffffffffffffffffffffffffffff1663c617113430836040518363ffffffff1660e01b8152600401611d93929190614b20565b602060405180830381865afa158015611db0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd49190614b5e565b611e1557806040517fede71dcc000000000000000000000000000000000000000000000000000000008152600401611e0c9190613d28565b60405180910390fd5b5b50565b611e2161235a565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff161480611e675750611e6685611e6161235a565b611afb565b5b611ea6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e9d90614bfd565b60405180910390fd5b611eb385858585856126ab565b5050505050565b611ec261235a565b73ffffffffffffffffffffffffffffffffffffffff16611ee061146b565b73ffffffffffffffffffffffffffffffffffffffff1614611f36576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f2d90614c69565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603611fa7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f9e90614cfb565b60405180910390fd5b8151835114611feb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fe290614d8d565b60405180910390fd5b6000611ff561235a565b9050612006816000878787876129cc565b60005b8451811015612172578381815181106120255761202461485f565b5b60200260200101516000808784815181106120435761204261485f565b5b6020026020010151815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546120a59190614968565b925050819055508573ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628885815181106121265761212561485f565b5b60200260200101518886815181106121415761214061485f565b5b6020026020010151604051612157929190614dad565b60405180910390a4808061216a9061488e565b915050612009565b50612182816000878787876129d4565b612191816000878787876129dc565b5050505050565b6127108111156121dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121d490614e22565b60405180910390fd5b60405180604001604052808373ffffffffffffffffffffffffffffffffffffffff1681526020018262ffffff168152506005600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160000160146101000a81548162ffffff021916908362ffffff160217905550905050505050565b6000600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036123d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123c890614cfb565b60405180910390fd5b60006123db61235a565b905060006123e885612bb3565b905060006123f585612bb3565b9050612406836000898585896129cc565b8460008088815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546124659190614968565b925050819055508673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6289896040516124e3929190614dad565b60405180910390a46124fa836000898585896129d4565b612509836000898989896107b8565b50505050505050565b61252461251d61235a565b8383612c2d565b5050565b61253061235a565b73ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff16148061257657506125758561257061235a565b611afb565b5b6125b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125ac90614eb4565b60405180910390fd5b6125c28585858585612d99565b5050505050565b60007fd9b67a26000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061269457507f0e89341c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806126a457506126a382613034565b5b9050919050565b81518351146126ef576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126e690614d8d565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361275e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161275590614f46565b60405180910390fd5b600061276861235a565b90506127788187878787876129cc565b60005b84518110156129295760008582815181106127995761279861485f565b5b6020026020010151905060008583815181106127b8576127b761485f565b5b60200260200101519050600080600084815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015612859576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161285090614fd8565b60405180910390fd5b81810360008085815260200190815260200160002060008c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160008085815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461290e9190614968565b92505081905550505050806129229061488e565b905061277b565b508473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb87876040516129a0929190614ff8565b60405180910390a46129b68187878787876129d4565b6129c48187878787876129dc565b505050505050565b505050505050565b505050505050565b6129fb8473ffffffffffffffffffffffffffffffffffffffff16611cf9565b15612bab578373ffffffffffffffffffffffffffffffffffffffff1663bc197c8187878686866040518663ffffffff1660e01b8152600401612a4195949392919061502f565b6020604051808303816000875af1925050508015612a7d57506040513d601f19601f82011682018060405250810190612a7a9190614437565b60015b612b2257612a89614471565b806308c379a003612ae55750612a9d614493565b80612aa85750612ae7565b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612adc9190613525565b60405180910390fd5b505b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612b1990614595565b60405180910390fd5b63bc197c8160e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614612ba9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612ba090614627565b60405180910390fd5b505b505050505050565b60606000600167ffffffffffffffff811115612bd257612bd1613329565b5b604051908082528060200260200182016040528015612c005781602001602082028036833780820191505090505b5090508281600081518110612c1857612c1761485f565b5b60200260200101818152505080915050919050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603612c9b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612c9290615109565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051612d8c91906132f3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612e08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612dff90614f46565b60405180910390fd5b6000612e1261235a565b90506000612e1f85612bb3565b90506000612e2c85612bb3565b9050612e3c8389898585896129cc565b600080600088815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905085811015612ed3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612eca90614fd8565b60405180910390fd5b85810360008089815260200190815260200160002060008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508560008089815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254612f889190614968565b925050819055508773ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628a8a604051613005929190614dad565b60405180910390a461301b848a8a86868a6129d4565b613029848a8a8a8a8a6107b8565b505050505050505050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b8280546130aa90614342565b90600052602060002090601f0160209004810192826130cc5760008555613113565b82601f106130e557805160ff1916838001178555613113565b82800160010185558215613113579182015b828111156131125782518255916020019190600101906130f7565b5b5090506131209190613124565b5090565b5b8082111561313d576000816000905550600101613125565b5090565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061318082613155565b9050919050565b61319081613175565b811461319b57600080fd5b50565b6000813590506131ad81613187565b92915050565b6000819050919050565b6131c6816131b3565b81146131d157600080fd5b50565b6000813590506131e3816131bd565b92915050565b60008060408385031215613200576131ff61314b565b5b600061320e8582860161319e565b925050602061321f858286016131d4565b9150509250929050565b613232816131b3565b82525050565b600060208201905061324d6000830184613229565b92915050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b61328881613253565b811461329357600080fd5b50565b6000813590506132a58161327f565b92915050565b6000602082840312156132c1576132c061314b565b5b60006132cf84828501613296565b91505092915050565b60008115159050919050565b6132ed816132d8565b82525050565b600060208201905061330860008301846132e4565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61336182613318565b810181811067ffffffffffffffff821117156133805761337f613329565b5b80604052505050565b6000613393613141565b905061339f8282613358565b919050565b600067ffffffffffffffff8211156133bf576133be613329565b5b6133c882613318565b9050602081019050919050565b82818337600083830152505050565b60006133f76133f2846133a4565b613389565b90508281526020810184848401111561341357613412613313565b5b61341e8482856133d5565b509392505050565b600082601f83011261343b5761343a61330e565b5b813561344b8482602086016133e4565b91505092915050565b60006020828403121561346a5761346961314b565b5b600082013567ffffffffffffffff81111561348857613487613150565b5b61349484828501613426565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156134d75780820151818401526020810190506134bc565b838111156134e6576000848401525b50505050565b60006134f78261349d565b61350181856134a8565b93506135118185602086016134b9565b61351a81613318565b840191505092915050565b6000602082019050818103600083015261353f81846134ec565b905092915050565b600067ffffffffffffffff82111561356257613561613329565b5b61356b82613318565b9050602081019050919050565b600061358b61358684613547565b613389565b9050828152602081018484840111156135a7576135a6613313565b5b6135b28482856133d5565b509392505050565b600082601f8301126135cf576135ce61330e565b5b81356135df848260208601613578565b91505092915050565b60008060008060008060c087890312156136055761360461314b565b5b600061361389828a0161319e565b965050602061362489828a0161319e565b955050604061363589828a0161319e565b945050606061364689828a016131d4565b935050608061365789828a016131d4565b92505060a087013567ffffffffffffffff81111561367857613677613150565b5b61368489828a016135ba565b9150509295509295509295565b6000602082840312156136a7576136a661314b565b5b60006136b5848285016131d4565b91505092915050565b600080604083850312156136d5576136d461314b565b5b60006136e3858286016131d4565b92505060206136f48582860161319e565b9150509250929050565b600080604083850312156137155761371461314b565b5b6000613723858286016131d4565b9250506020613734858286016131d4565b9150509250929050565b61374781613175565b82525050565b6000604082019050613762600083018561373e565b61376f6020830184613229565b9392505050565b600067ffffffffffffffff82111561379157613790613329565b5b602082029050602081019050919050565b600080fd5b60006137ba6137b584613776565b613389565b905080838252602082019050602084028301858111156137dd576137dc6137a2565b5b835b8181101561380657806137f288826131d4565b8452602084019350506020810190506137df565b5050509392505050565b600082601f8301126138255761382461330e565b5b81356138358482602086016137a7565b91505092915050565b600080600080600060a0868803121561385a5761385961314b565b5b60006138688882890161319e565b95505060206138798882890161319e565b945050604086013567ffffffffffffffff81111561389a57613899613150565b5b6138a688828901613810565b935050606086013567ffffffffffffffff8111156138c7576138c6613150565b5b6138d388828901613810565b925050608086013567ffffffffffffffff8111156138f4576138f3613150565b5b613900888289016135ba565b9150509295509295909350565b600067ffffffffffffffff82111561392857613927613329565b5b602082029050602081019050919050565b600061394c6139478461390d565b613389565b9050808382526020820190506020840283018581111561396f5761396e6137a2565b5b835b818110156139b657803567ffffffffffffffff8111156139945761399361330e565b5b8086016139a18982613426565b85526020850194505050602081019050613971565b5050509392505050565b600082601f8301126139d5576139d461330e565b5b81356139e5848260208601613939565b91505092915050565b60008060408385031215613a0557613a0461314b565b5b600083013567ffffffffffffffff811115613a2357613a22613150565b5b613a2f85828601613810565b925050602083013567ffffffffffffffff811115613a5057613a4f613150565b5b613a5c858286016139c0565b9150509250929050565b600060208284031215613a7c57613a7b61314b565b5b6000613a8a8482850161319e565b91505092915050565b6000819050919050565b6000613ab8613ab3613aae84613155565b613a93565b613155565b9050919050565b6000613aca82613a9d565b9050919050565b6000613adc82613abf565b9050919050565b613aec81613ad1565b82525050565b6000602082019050613b076000830184613ae3565b92915050565b600067ffffffffffffffff821115613b2857613b27613329565b5b602082029050602081019050919050565b6000613b4c613b4784613b0d565b613389565b90508083825260208201905060208402830185811115613b6f57613b6e6137a2565b5b835b81811015613b985780613b84888261319e565b845260208401935050602081019050613b71565b5050509392505050565b600082601f830112613bb757613bb661330e565b5b8135613bc7848260208601613b39565b91505092915050565b60008060408385031215613be757613be661314b565b5b600083013567ffffffffffffffff811115613c0557613c04613150565b5b613c1185828601613ba2565b925050602083013567ffffffffffffffff811115613c3257613c31613150565b5b613c3e85828601613810565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b613c7d816131b3565b82525050565b6000613c8f8383613c74565b60208301905092915050565b6000602082019050919050565b6000613cb382613c48565b613cbd8185613c53565b9350613cc883613c64565b8060005b83811015613cf9578151613ce08882613c83565b9750613ceb83613c9b565b925050600181019050613ccc565b5085935050505092915050565b60006020820190508181036000830152613d208184613ca8565b905092915050565b6000602082019050613d3d600083018461373e565b92915050565b60008060008060008060c08789031215613d6057613d5f61314b565b5b6000613d6e89828a0161319e565b965050602087013567ffffffffffffffff811115613d8f57613d8e613150565b5b613d9b89828a01613810565b955050604087013567ffffffffffffffff811115613dbc57613dbb613150565b5b613dc889828a01613810565b945050606087013567ffffffffffffffff811115613de957613de8613150565b5b613df589828a016139c0565b935050608087013567ffffffffffffffff811115613e1657613e15613150565b5b613e2289828a01613ba2565b92505060a087013567ffffffffffffffff811115613e4357613e42613150565b5b613e4f89828a01613810565b9150509295509295509295565b60008060408385031215613e7357613e7261314b565b5b6000613e81858286016131d4565b925050602083013567ffffffffffffffff811115613ea257613ea1613150565b5b613eae85828601613426565b9150509250929050565b60008060008060008060c08789031215613ed557613ed461314b565b5b6000613ee389828a0161319e565b9650506020613ef489828a0161319e565b9550506040613f0589828a016131d4565b945050606087013567ffffffffffffffff811115613f2657613f25613150565b5b613f3289828a01613426565b9350506080613f4389828a0161319e565b92505060a0613f5489828a016131d4565b9150509295509295509295565b60008060008060008060c08789031215613f7e57613f7d61314b565b5b6000613f8c89828a0161319e565b9650506020613f9d89828a016131d4565b9550506040613fae89828a016131d4565b945050606087013567ffffffffffffffff811115613fcf57613fce613150565b5b613fdb89828a01613426565b9350506080613fec89828a0161319e565b92505060a0613ffd89828a016131d4565b9150509295509295509295565b60008060008060008060c087890312156140275761402661314b565b5b600087013567ffffffffffffffff81111561404557614044613150565b5b61405189828a01613ba2565b965050602061406289828a0161319e565b955050604087013567ffffffffffffffff81111561408357614082613150565b5b61408f89828a01613810565b945050606087013567ffffffffffffffff8111156140b0576140af613150565b5b6140bc89828a016139c0565b93505060806140cd89828a0161319e565b92505060a06140de89828a016131d4565b9150509295509295509295565b6140f4816132d8565b81146140ff57600080fd5b50565b600081359050614111816140eb565b92915050565b6000806040838503121561412e5761412d61314b565b5b600061413c8582860161319e565b925050602061414d85828601614102565b9150509250929050565b6000806000606084860312156141705761416f61314b565b5b600061417e868287016131d4565b935050602061418f8682870161319e565b92505060406141a0868287016131d4565b9150509250925092565b600080604083850312156141c1576141c061314b565b5b60006141cf8582860161319e565b92505060206141e08582860161319e565b9150509250929050565b600080600080600060a086880312156142065761420561314b565b5b60006142148882890161319e565b95505060206142258882890161319e565b9450506040614236888289016131d4565b9350506060614247888289016131d4565b925050608086013567ffffffffffffffff81111561426857614267613150565b5b614274888289016135ba565b9150509295509295909350565b7f455243313135353a2062616c616e636520717565727920666f7220746865207a60008201527f65726f2061646472657373000000000000000000000000000000000000000000602082015250565b60006142dd602b836134a8565b91506142e882614281565b604082019050919050565b6000602082019050818103600083015261430c816142d0565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000600282049050600182168061435a57607f821691505b60208210810361436d5761436c614313565b5b50919050565b600081519050919050565b600082825260208201905092915050565b600061439a82614373565b6143a4818561437e565b93506143b48185602086016134b9565b6143bd81613318565b840191505092915050565b600060a0820190506143dd600083018861373e565b6143ea602083018761373e565b6143f76040830186613229565b6144046060830185613229565b8181036080830152614416818461438f565b90509695505050505050565b6000815190506144318161327f565b92915050565b60006020828403121561444d5761444c61314b565b5b600061445b84828501614422565b91505092915050565b60008160e01c9050919050565b600060033d11156144905760046000803e61448d600051614464565b90505b90565b600060443d10614520576144a5613141565b60043d036004823e80513d602482011167ffffffffffffffff821117156144cd575050614520565b808201805167ffffffffffffffff8111156144eb5750505050614520565b80602083010160043d038501811115614508575050505050614520565b61451782602001850186613358565b82955050505050505b90565b7f455243313135353a207472616e7366657220746f206e6f6e204552433131353560008201527f526563656976657220696d706c656d656e746572000000000000000000000000602082015250565b600061457f6034836134a8565b915061458a82614523565b604082019050919050565b600060208201905081810360008301526145ae81614572565b9050919050565b7f455243313135353a204552433131353552656365697665722072656a6563746560008201527f6420746f6b656e73000000000000000000000000000000000000000000000000602082015250565b60006146116028836134a8565b915061461c826145b5565b604082019050919050565b6000602082019050818103600083015261464081614604565b9050919050565b600081905092915050565b60008190508160005260206000209050919050565b6000815461467481614342565b61467e8186614647565b9450600182166000811461469957600181146146aa576146dd565b60ff198316865281860193506146dd565b6146b385614652565b60005b838110156146d5578154818901526001820191506020810190506146b6565b838801955050505b50505092915050565b60006146f28285614667565b91506146fe8284614667565b91508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000614744826131b3565b915061474f836131b3565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156147885761478761470a565b5b828202905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006147cd826131b3565b91506147d8836131b3565b9250826147e8576147e7614793565b5b828204905092915050565b7f455243313135353a20417272617973206c656e677468206d69736d6174636800600082015250565b6000614829601f836134a8565b9150614834826147f3565b602082019050919050565b600060208201905081810360008301526148588161481c565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000614899826131b3565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036148cb576148ca61470a565b5b600182019050919050565b7f455243313135353a206163636f756e747320616e6420696473206c656e67746860008201527f206d69736d617463680000000000000000000000000000000000000000000000602082015250565b60006149326029836134a8565b915061493d826148d6565b604082019050919050565b6000602082019050818103600083015261496181614925565b9050919050565b6000614973826131b3565b915061497e836131b3565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156149b3576149b261470a565b5b828201905092915050565b7f6d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b60006149f46018836134a8565b91506149ff826149be565b602082019050919050565b60006020820190508181036000830152614a23816149e7565b9050919050565b6000819050919050565b6000614a4f614a4a614a4584614a2a565b613a93565b6131b3565b9050919050565b614a5f81614a34565b82525050565b6000604082019050614a7a6000830185613229565b614a876020830184614a56565b9392505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614aea6026836134a8565b9150614af582614a8e565b604082019050919050565b60006020820190508181036000830152614b1981614add565b9050919050565b6000604082019050614b35600083018561373e565b614b42602083018461373e565b9392505050565b600081519050614b58816140eb565b92915050565b600060208284031215614b7457614b7361314b565b5b6000614b8284828501614b49565b91505092915050565b7f455243313135353a207472616e736665722063616c6c6572206973206e6f742060008201527f6f776e6572206e6f7220617070726f7665640000000000000000000000000000602082015250565b6000614be76032836134a8565b9150614bf282614b8b565b604082019050919050565b60006020820190508181036000830152614c1681614bda565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000614c536020836134a8565b9150614c5e82614c1d565b602082019050919050565b60006020820190508181036000830152614c8281614c46565b9050919050565b7f455243313135353a206d696e7420746f20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b6000614ce56021836134a8565b9150614cf082614c89565b604082019050919050565b60006020820190508181036000830152614d1481614cd8565b9050919050565b7f455243313135353a2069647320616e6420616d6f756e7473206c656e6774682060008201527f6d69736d61746368000000000000000000000000000000000000000000000000602082015250565b6000614d776028836134a8565b9150614d8282614d1b565b604082019050919050565b60006020820190508181036000830152614da681614d6a565b9050919050565b6000604082019050614dc26000830185613229565b614dcf6020830184613229565b9392505050565b7f45524332393831526f79616c746965733a20546f6f2068696768000000000000600082015250565b6000614e0c601a836134a8565b9150614e1782614dd6565b602082019050919050565b60006020820190508181036000830152614e3b81614dff565b9050919050565b7f455243313135353a2063616c6c6572206973206e6f74206f776e6572206e6f7260008201527f20617070726f7665640000000000000000000000000000000000000000000000602082015250565b6000614e9e6029836134a8565b9150614ea982614e42565b604082019050919050565b60006020820190508181036000830152614ecd81614e91565b9050919050565b7f455243313135353a207472616e7366657220746f20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b6000614f306025836134a8565b9150614f3b82614ed4565b604082019050919050565b60006020820190508181036000830152614f5f81614f23565b9050919050565b7f455243313135353a20696e73756666696369656e742062616c616e636520666f60008201527f72207472616e7366657200000000000000000000000000000000000000000000602082015250565b6000614fc2602a836134a8565b9150614fcd82614f66565b604082019050919050565b60006020820190508181036000830152614ff181614fb5565b9050919050565b600060408201905081810360008301526150128185613ca8565b905081810360208301526150268184613ca8565b90509392505050565b600060a082019050615044600083018861373e565b615051602083018761373e565b81810360408301526150638186613ca8565b905081810360608301526150778185613ca8565b9050818103608083015261508b818461438f565b90509695505050505050565b7f455243313135353a2073657474696e6720617070726f76616c2073746174757360008201527f20666f722073656c660000000000000000000000000000000000000000000000602082015250565b60006150f36029836134a8565b91506150fe82615097565b604082019050919050565b60006020820190508181036000830152615122816150e6565b905091905056fea26469706673582212204d3a78dc0abd06680871aef98be23308b0095daf2827cc31bd5803a5274f554c64736f6c634300080d0033
Verified Source Code Partial Match
Compiler: v0.8.13+commit.abaa5c0e
EVM: london
Optimization: No
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
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;
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
ERC1155.sol 534 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/ERC1155.sol)
pragma solidity 0.8.13;
import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./IERC1155MetadataURI.sol";
import "./Address.sol";
import "./Context.sol";
import "./ERC165.sol";
import "./Strings.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)) public balances;
// Mapping from token ID to the IPFS cid
mapping(uint256 => string) public cids;
// 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.
string public baseUri;
/**
* @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 id)
public
view
virtual
override
returns (string memory)
{
return string(abi.encodePacked(baseUri, cids[id]));
}
/**
* @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: balance query for the zero address"
);
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 {
baseUri = 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 TransferSingle(operator, address(0), to, ids[i], amounts[i]);
}
_afterTokenTransfer(operator, address(0), to, ids, amounts, data);
_doSafeBatchTransferAcceptanceCheck(
operator,
address(0),
to,
ids,
amounts,
data
);
}
/**
* @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
) public {
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;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "./Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
IERC1155.sol 125 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
ERC2981Base.sol 27 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "./ERC165.sol";
import "./IERC2981Royalties.sol";
/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155
abstract contract ERC2981Base is ERC165, IERC2981Royalties {
struct RoyaltyInfo {
address recipient;
uint24 amount;
}
/// @inheritdoc ERC165
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IERC2981Royalties).interfaceId ||
super.supportsInterface(interfaceId);
}
}
LondonToken.sol 341 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "./Ownable.sol";
import "./ERC1155.sol";
import "./ERC2981PerTokenRoyalties.sol";
import {DefaultOperatorFilterer} from "./DefaultOperatorFilterer.sol";
/// @custom:security-contact [email protected]
contract LondonToken is
ERC1155,
Ownable,
ERC2981PerTokenRoyalties,
DefaultOperatorFilterer
{
constructor(
string memory uri_,
address minter_,
address gatewayManager_,
string memory contractName_
) ERC1155(uri_) {
mintingManager = minter_;
gatewayManager = gatewayManager_;
name = contractName_;
}
string public name = "Verse Works v0.4.0";
uint256 public totalSupply;
address public mintingManager;
address public gatewayManager;
modifier onlyMinter() {
require(msg.sender == mintingManager);
_;
}
modifier onlyGatewayManager() {
require(msg.sender == gatewayManager);
_;
}
/**
* @dev OS Operator filtering
*/
function setApprovalForAll(address operator, bool approved)
public
override
onlyAllowedOperatorApproval(operator)
{
super.setApprovalForAll(operator, approved);
}
/**
* @dev OS Operator filtering
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes memory data
) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId, amount, data);
}
/**
* @dev OS Operator filtering
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public virtual override onlyAllowedOperator(from) {
super.safeBatchTransferFrom(from, to, ids, amounts, data);
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
* In additionit sets the royalties for `royaltyRecipient` of the value `royaltyValue`.
*
* 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 account,
uint256 id,
uint256 amount,
string memory cid,
address royaltyRecipient,
uint256 royaltyValue
) public onlyMinter {
_mint(account, id, amount, "");
if (royaltyValue > 0) {
_setTokenRoyalty(id, royaltyRecipient, royaltyValue);
}
cids[id] = cid;
totalSupply += amount;
}
/**
* @dev Batch 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,
string[] memory tokenCids,
address[] memory royaltyRecipients,
uint256[] memory royaltyValues
) public onlyMinter {
require(
ids.length == royaltyRecipients.length &&
ids.length == royaltyValues.length,
"ERC1155: Arrays length mismatch"
);
_mintBatch(to, ids, amounts, "");
for (uint256 i; i < ids.length; i++) {
if (royaltyValues[i] > 0) {
_setTokenRoyalty(
ids[i],
royaltyRecipients[i],
royaltyValues[i]
);
}
// update IPFS CID
cids[ids[i]] = tokenCids[i];
}
uint256 count;
for (uint256 i = 0; i < ids.length; i++) {
for (uint256 j = 0; j < amounts.length; j++) {
count += ids[i] * amounts[j];
}
}
totalSupply += count;
}
/**
* @dev Checks for supported interface.
*
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155, ERC2981Base)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
* In additionit sets the royalties for `royaltyRecipient` of the value `royaltyValue`.
* Method emits two transfer events.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function mintWithCreator(
address creator,
address to,
uint256 tokenId,
string memory cid,
address royaltyRecipient,
uint256 royaltyValue
) public onlyMinter {
require(to != address(0), "mint to the zero address");
balances[tokenId][to] += 1;
totalSupply += 1;
cids[tokenId] = cid;
if (royaltyValue > 0) {
_setTokenRoyalty(tokenId, royaltyRecipient, royaltyValue);
}
address operator = _msgSender();
emit TransferSingle(operator, address(0), creator, tokenId, 1);
emit TransferSingle(operator, creator, to, tokenId, 1);
}
/**
* @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
* In additionit sets the royalties for `royaltyRecipient` of the value `royaltyValue`.
* Method emits two transfer events.
*
* Emits a {TransferSingle} events for intermediate artist.
*
* 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 batchMintWithCreator(
address[] memory to,
address creator,
uint256[] memory tokenIds,
string[] memory tokenCids,
address royaltyRecipient,
uint256 royaltyValue
) public onlyMinter {
require(
tokenIds.length == to.length && tokenIds.length == tokenCids.length,
"ERC1155: Arrays length mismatch"
);
address operator = _msgSender();
for (uint256 i = 0; i < tokenIds.length; i++) {
balances[tokenIds[i]][to[i]] += 1;
// check if recipient can accept NFT
_doSafeTransferAcceptanceCheck(
operator,
address(0),
to[i],
tokenIds[i],
1,
""
);
// update royalties
if (royaltyValue > 0) {
_setTokenRoyalty(tokenIds[i], royaltyRecipient, royaltyValue);
}
// update IPFS CID
cids[tokenIds[i]] = tokenCids[i];
// emit events based on creator provided
if (creator == address(0)) {
emit TransferSingle(
operator,
address(0),
to[i],
tokenIds[i],
1
);
} else {
emit TransferSingle(
operator,
address(0),
creator,
tokenIds[i],
1
);
emit TransferSingle(operator, creator, to[i], tokenIds[i], 1);
}
}
// update total supply
totalSupply += tokenIds.length;
}
/**
* @dev Sets base URI for metadata.
*
*/
function setURI(string memory newuri) public onlyGatewayManager {
_setURI(newuri);
}
/**
* @dev Sets new minter for the contract.
*
*/
function setMintingManager(address minter_) public onlyOwner {
mintingManager = minter_;
}
/**
* @dev Sets new gateway manager for the contract.
*
*/
function setGatewayManager(address gatewayManager_) public onlyOwner {
gatewayManager = gatewayManager_;
}
/**
* @dev Sets royalties for `tokenId` and `tokenRecipient` with royalty value `royaltyValue`.
*
*/
function setRoyalties(
uint256 tokenId,
address royaltyRecipient,
uint256 royaltyValue
) public onlyOwner {
_setTokenRoyalty(tokenId, royaltyRecipient, royaltyValue);
}
/**
* @dev Sets IPFS cid metadata hash for token id `tokenId`.
*
*/
function setCID(uint256 tokenId, string memory cid)
public
onlyGatewayManager
{
cids[tokenId] = cid;
}
/**
* @dev Sets IPFS cid metadata hash for token id `tokenId`.
*
*/
function setCIDs(uint256[] memory tokenIds, string[] memory cids_)
public
onlyGatewayManager
{
require(
tokenIds.length == cids_.length,
"ERC1155: Arrays length mismatch"
);
for (uint256 i = 0; i < tokenIds.length; i++) {
cids[tokenIds[i]] = cids_[i];
}
}
}
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 "./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);
}
OperatorFilterer.sol 60 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {IOperatorFilterRegistry} from "./IOperatorFilterRegistry.sol";
/**
* @title OperatorFilterer
* @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another
* registrant's entries in the OperatorFilterRegistry.
* @dev This smart contract is meant to be inherited by token contracts so they can use the following:
* - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.
* - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.
*/
abstract contract OperatorFilterer {
error OperatorNotAllowed(address operator);
IOperatorFilterRegistry public constant OPERATOR_FILTER_REGISTRY =
IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);
constructor(address subscriptionOrRegistrantToCopy, bool subscribe) {
// If an inheriting token contract is deployed to a network without the registry deployed, the modifier
// will not revert, but the contract will need to be registered with the registry once it is deployed in
// order for the modifier to filter addresses.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (subscribe) {
OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);
} else {
if (subscriptionOrRegistrantToCopy != address(0)) {
OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);
} else {
OPERATOR_FILTER_REGISTRY.register(address(this));
}
}
}
}
modifier onlyAllowedOperator(address from) virtual {
// Allow spending tokens from addresses with balance
// Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred
// from an EOA.
if (from != msg.sender) {
_checkFilterOperator(msg.sender);
}
_;
}
modifier onlyAllowedOperatorApproval(address operator) virtual {
_checkFilterOperator(operator);
_;
}
function _checkFilterOperator(address operator) internal view virtual {
// Check registry code length to facilitate testing in environments without a deployed registry.
if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {
if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {
revert OperatorNotAllowed(operator);
}
}
}
}
IERC2981Royalties.sol 17 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
/// @title IERC2981Royalties
/// @dev Interface for the ERC2981 - Token Royalty standard
interface IERC2981Royalties {
/// @notice Called with the sale price to determine how much royalty
// is owed and to whom.
/// @param _tokenId - the NFT asset queried for royalty information
/// @param _value - the sale price of the NFT asset specified by _tokenId
/// @return _receiver - address of who should be sent the royalty payment
/// @return _royaltyAmount - the royalty payment amount for value sale price
function royaltyInfo(uint256 _tokenId, uint256 _value)
external
view
returns (address _receiver, uint256 _royaltyAmount);
}
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);
}
DefaultOperatorFilterer.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import {OperatorFilterer} from "./OperatorFilterer.sol";
/**
* @title DefaultOperatorFilterer
* @notice Inherits from OperatorFilterer and automatically subscribes to the default OpenSea subscription.
*/
abstract contract DefaultOperatorFilterer is OperatorFilterer {
address constant DEFAULT_SUBSCRIPTION = address(0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6);
constructor() OperatorFilterer(DEFAULT_SUBSCRIPTION, true) {}
}
IOperatorFilterRegistry.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IOperatorFilterRegistry {
function isOperatorAllowed(address registrant, address operator) external view returns (bool);
function register(address registrant) external;
function registerAndSubscribe(address registrant, address subscription) external;
function registerAndCopyEntries(address registrant, address registrantToCopy) external;
function unregister(address addr) external;
function updateOperator(address registrant, address operator, bool filtered) external;
function updateOperators(address registrant, address[] calldata operators, bool filtered) external;
function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;
function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;
function subscribe(address registrant, address registrantToSubscribe) external;
function unsubscribe(address registrant, bool copyExistingEntries) external;
function subscriptionOf(address addr) external returns (address registrant);
function subscribers(address registrant) external returns (address[] memory);
function subscriberAt(address registrant, uint256 index) external returns (address);
function copyEntriesOf(address registrant, address registrantToCopy) external;
function isOperatorFiltered(address registrant, address operator) external returns (bool);
function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);
function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);
function filteredOperators(address addr) external returns (address[] memory);
function filteredCodeHashes(address addr) external returns (bytes32[] memory);
function filteredOperatorAt(address registrant, uint256 index) external returns (address);
function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);
function isRegistered(address addr) external returns (bool);
function codeHashOf(address addr) external returns (bytes32);
}
ERC2981PerTokenRoyalties.sol 36 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import "./ERC165.sol";
import "./ERC2981Base.sol";
/// @dev This is a contract used to add ERC2981 support to ERC721 and 1155
abstract contract ERC2981PerTokenRoyalties is ERC2981Base {
mapping(uint256 => RoyaltyInfo) internal _royalties;
/// @dev Sets token royalties
/// @param tokenId the token id fir which we register the royalties
/// @param recipient recipient of the royalties
/// @param value percentage (using 2 decimals - 10000 = 100, 0 = 0)
function _setTokenRoyalty(
uint256 tokenId,
address recipient,
uint256 value
) internal {
require(value <= 10000, "ERC2981Royalties: Too high");
_royalties[tokenId] = RoyaltyInfo(recipient, uint24(value));
}
/// @inheritdoc IERC2981Royalties
function royaltyInfo(uint256 tokenId, uint256 value)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
RoyaltyInfo memory royalties = _royalties[tokenId];
receiver = royalties.recipient;
royaltyAmount = (value * royalties.amount) / 10000;
}
}
Read Contract
OPERATOR_FILTER_REGISTRY 0x41f43434 → address
balanceOf 0x00fdd58e → uint256
balanceOfBatch 0x4e1273f4 → uint256[]
balances 0x1f320331 → uint256
baseUri 0x9abc8320 → string
cids 0x704fe710 → string
gatewayManager 0xd0414c9d → address
isApprovedForAll 0xe985e9c5 → bool
mintingManager 0x58884432 → address
name 0x06fdde03 → string
owner 0x8da5cb5b → address
royaltyInfo 0x2a55205a → address, uint256
supportsInterface 0x01ffc9a7 → bool
totalSupply 0x18160ddd → uint256
uri 0x0e89341c → string
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
_doSafeTransferAcceptanceCheck 0x084e9e24
address operator
address from
address to
uint256 id
uint256 amount
bytes data
batchMintWithCreator 0x9e426399
address[] to
address creator
uint256[] tokenIds
string[] tokenCids
address royaltyRecipient
uint256 royaltyValue
mint 0x98faf29b
address account
uint256 id
uint256 amount
string cid
address royaltyRecipient
uint256 royaltyValue
mintBatch 0x69b52017
address to
uint256[] ids
uint256[] amounts
string[] tokenCids
address[] royaltyRecipients
uint256[] royaltyValues
mintWithCreator 0x8d2bb093
address creator
address to
uint256 tokenId
string cid
address royaltyRecipient
uint256 royaltyValue
renounceOwnership 0x715018a6
No parameters
safeBatchTransferFrom 0x2eb2c2d6
address from
address to
uint256[] ids
uint256[] amounts
bytes data
safeTransferFrom 0xf242432a
address from
address to
uint256 tokenId
uint256 amount
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setCID 0x82295a2d
uint256 tokenId
string cid
setCIDs 0x337648b2
uint256[] tokenIds
string[] cids_
setGatewayManager 0x3a330022
address gatewayManager_
setMintingManager 0x6c52c3fb
address minter_
setRoyalties 0xe2c7f338
uint256 tokenId
address royaltyRecipient
uint256 royaltyValue
setURI 0x02fe5305
string newuri
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address