Address Contract Verified
Address
0x51d0B69886DcDe7a4fb9b39722868056804AFbca
Balance
0.400000 ETH
Nonce
1
Code Size
15838 bytes
Creator
0x4B5922AB...6BE4 at tx 0xa6cc4e83...58e7c5
Indexed Transactions
0
Contract Bytecode
15838 bytes
0x6080604052600436106102135760003560e01c806347535d7b11610118578063a035b1fe116100a0578063b88d4fde1161006f578063b88d4fde14610625578063c87b56dd14610645578063e1ff178a14610665578063e70d799814610685578063e985e9c5146106a55761021a565b8063a035b1fe146105a9578063a22cb465146105bf578063a464c98b146105df578063ae7b741c1461060f5761021a565b806370a08231116100e757806370a08231146105115780637299054c14610531578063750af3ab146105515780638a1bbf861461058157806395d89b41146105945761021a565b806347535d7b146104975780634f6ccce7146104b15780635c3e9cc2146104d15780636352211e146104f15761021a565b80631d64b7c11161019b5780632f745c591161016a5780632f745c59146103f25780632fea3088146104125780633a4fb2dd1461043257806342842e0e1461045257806343bc1612146104725761021a565b80631d64b7c11461035e57806323b872dd1461037e57806325e160631461039e57806328de3c9b146103be5761021a565b8063081812fc116101e2578063081812fc146102bc578063095ea7b3146102f4578063167ff46f14610314578063168557a51461032957806318160ddd146103495761021a565b806301ffc9a71461021f578063047fc9aa1461025457806306d97bea1461027857806306fdde031461029a5761021a565b3661021a57005b600080fd5b34801561022b57600080fd5b5061023f61023a366004612ca4565b6106ee565b60405190151581526020015b60405180910390f35b34801561026057600080fd5b5061026a600b5481565b60405190815260200161024b565b34801561028457600080fd5b50610298610293366004612d0f565b610701565b005b3480156102a657600080fd5b506102af610a32565b60405161024b9190613a3c565b3480156102c857600080fd5b506102dc6102d7366004612c8c565b610ac4565b6040516001600160a01b03909116815260200161024b565b34801561030057600080fd5b5061029861030f366004612c61565b610b59565b34801561032057600080fd5b50610298610c6f565b34801561033557600080fd5b50600a546102dc906001600160a01b031681565b34801561035557600080fd5b5060085461026a565b34801561036a57600080fd5b50610298610379366004612cdc565b610cca565b34801561038a57600080fd5b50610298610399366004612b70565b610f1d565b3480156103aa57600080fd5b506102986103b9366004612b00565b610f4e565b3480156103ca57600080fd5b506103de6103d9366004612c8c565b611099565b60405161024b989796959493929190613b91565b3480156103fe57600080fd5b5061026a61040d366004612c61565b611171565b34801561041e57600080fd5b506102af61042d366004612f41565b611207565b34801561043e57600080fd5b506102af61044d366004612e72565b611246565b34801561045e57600080fd5b5061029861046d366004612b70565b6113ce565b34801561047e57600080fd5b50600c546102dc9061010090046001600160a01b031681565b3480156104a357600080fd5b50600c5461023f9060ff1681565b3480156104bd57600080fd5b5061026a6104cc366004612c8c565b6113e9565b3480156104dd57600080fd5b506102af6104ec366004612c8c565b61148a565b3480156104fd57600080fd5b506102dc61050c366004612c8c565b611524565b34801561051d57600080fd5b5061026a61052c366004612b00565b61159b565b34801561053d57600080fd5b5061026a61054c366004612f8f565b611622565b34801561055d57600080fd5b5061023f61056c366004612c8c565b60116020526000908152604090205460ff1681565b61029861058f366004612d52565b611673565b3480156105a057600080fd5b506102af611ac4565b3480156105b557600080fd5b5061026a600d5481565b3480156105cb57600080fd5b506102986105da366004612c2d565b611ad3565b3480156105eb57600080fd5b5061023f6105fa366004612c8c565b60126020526000908152604090205460ff1681565b34801561061b57600080fd5b5061026a600e5481565b34801561063157600080fd5b50610298610640366004612bb0565b611ba5565b34801561065157600080fd5b506102af610660366004612c8c565b611bdd565b34801561067157600080fd5b50610298610680366004612dfb565b611e21565b34801561069157600080fd5b506102af6106a0366004612fba565b611e8a565b3480156106b157600080fd5b5061023f6106c0366004612b38565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b60006106f982611f3c565b90505b919050565b600c5460ff1661072c5760405162461bcd60e51b815260040161072390613afa565b60405180910390fd5b612711600b5411156107505760405162461bcd60e51b815260040161072390613b1a565b600a546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561079457600080fd5b505afa1580156107a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107cc9190612b1c565b6001600160a01b03161461080b5760405162461bcd60e51b815260206004820152600660248201526510b7bbb732b960d11b6044820152606401610723565b60008181526012602052604090205460ff16156108545760405162461bcd60e51b815260206004820152600760248201526618db185a5b595960ca1b6044820152606401610723565b6000818152601260209081526040808320805460ff191660011790555161087d918591016130d4565b60408051601f1981840301815291815281516020928301206000818152601190935291205490915060ff16156108c55760405162461bcd60e51b815260040161072390613a4f565b6000818152601160205260408120805460ff19166001179055600b546108f1906032906101a490611622565b905060006109066101f4610398600b54611622565b9050600061091960016019600b54611622565b905060006109358161092d6001600a613c8b565b600b54611622565b60408051610100810182524381523360208083019182528284018c8152606084018a90526080840189905260a08401869052600060c0850181905260e08501899052600b548152600f8352949094208351815591516001830180546001600160a01b0319166001600160a01b0390921691909117905592518051949550919390926109c792600285019291019061295a565b50606082015160038201556080820151600482015560a0820151600582015560c082015160068201805460ff191691151591909117905560e090910151600790910155600b54610a18903390611f61565b600b54610a26906001613c1b565b600b5550505050505050565b606060008054610a4190613cce565b80601f0160208091040260200160405190810160405280929190818152602001828054610a6d90613cce565b8015610aba5780601f10610a8f57610100808354040283529160200191610aba565b820191906000526020600020905b815481529060010190602001808311610a9d57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610b3d5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610723565b506000908152600460205260409020546001600160a01b031690565b6000610b6482611524565b9050806001600160a01b0316836001600160a01b03161415610bd25760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610723565b336001600160a01b0382161480610bee5750610bee81336106c0565b610c605760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610723565b610c6a83836120af565b505050565b600c5461010090046001600160a01b03163314610cbb5760405162461bcd60e51b815260206004820152600a60248201526910b337b93134b23232b760b11b6044820152606401610723565b600c805460ff19166001179055565b600c5460ff16610cec5760405162461bcd60e51b815260040161072390613afa565b612711600b541115610d105760405162461bcd60e51b815260040161072390613b1a565b600e54610d1f90610258613c1b565b4211610d565760405162461bcd60e51b8152600401610723906020808252600490820152631dd85a5d60e21b604082015260600190565b42600e55604051600090610d6e9083906020016130d4565b60408051601f1981840301815291815281516020928301206000818152601190935291205490915060ff1615610db65760405162461bcd60e51b815260040161072390613a4f565b6000818152601160205260408120805460ff19166001179055600b54610de2906046906101ea90611622565b90506000610df7610190610370600b54611622565b90506000610e0a60016019600b54611622565b90506000610e1e8161092d6001600a613c8b565b60408051610100810182524381523360208083019182528284018b8152606084018a90526080840189905260a08401869052600160c0850181905260e08501899052600b546000908152600f84529590952084518155925194830180546001600160a01b0319166001600160a01b03909616959095179094559251805194955091939092610eb392600285019291019061295a565b50606082015160038201556080820151600482015560a0820151600582015560c082015160068201805460ff191691151591909117905560e090910151600790910155600b54610f04903390611f61565b600b54610f12906001613c1b565b600b55505050505050565b610f27338261211d565b610f435760405162461bcd60e51b815260040161072390613b40565b610c6a838383612214565b600c5461010090046001600160a01b03163314610f9a5760405162461bcd60e51b815260206004820152600a60248201526910b337b93134b23232b760b11b6044820152606401610723565b736fba46974b2b1befefa034e236a32e1f10c5a148600081610fbd600a47613c58565b604051600081818185875af1925050503d8060008114610ff9576040519150601f19603f3d011682016040523d82523d6000602084013e610ffe565b606091505b505090508061101f5760405162461bcd60e51b815260040161072390613acc565b60405183906000906001600160a01b0383169047908381818185875af1925050503d806000811461106c576040519150601f19603f3d011682016040523d82523d6000602084013e611071565b606091505b50509050806110925760405162461bcd60e51b815260040161072390613acc565b5050505050565b600f6020526000908152604090208054600182015460028301805492936001600160a01b03909216926110cb90613cce565b80601f01602080910402602001604051908101604052809291908181526020018280546110f790613cce565b80156111445780601f1061111957610100808354040283529160200191611144565b820191906000526020600020905b81548152906001019060200180831161112757829003601f168201915b505050506003830154600484015460058501546006860154600790960154949592949193509160ff169088565b600061117c8361159b565b82106111de5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610723565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6060611212846123bf565b61121b846123bf565b8360405160200161122e939291906131c2565b60405160208183030381529060405290509392505050565b60e0810151606090819060005b818110156112cf578261129a8660600151876080015161127e6102266103ac878d61054c9190613c1b565b611290605061025861054c898f613c1b565b6106a0878d613c1b565b6040516020016112ab9291906130f0565b604051602081830303815290604052925080806112c790613d09565b915050611253565b50816112e360146103b68760400151611207565b6040516020016112f49291906130f0565b604051602081830303815290604052915060138460a00151600a811061132a57634e487b7160e01b600052603260045260246000fd5b016004856060015161133c9190613d24565b1561136b576040518060400160405280600c81526020016b139010101f1e17b932b1ba1f60a11b8152506113a2565b6040518060400160405280602081526020017f27202066696c7465723d2775726c28236e6f6973652927203e3c2f726563743e8152505b836040516020016113b5939291906135e6565b6040516020818303038152906040529250505092915050565b610c6a83838360405180602001604052806000815250611ba5565b60006113f460085490565b82106114575760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610723565b6008828154811061147857634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b601060205260009081526040902080546114a390613cce565b80601f01602080910402602001604051908101604052809291908181526020018280546114cf90613cce565b801561151c5780601f106114f15761010080835404028352916020019161151c565b820191906000526020600020905b8154815290600101906020018083116114ff57829003601f168201915b505050505081565b6000818152600260205260408120546001600160a01b0316806106f95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610723565b60006001600160a01b0382166116065760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610723565b506001600160a01b031660009081526003602052604090205490565b60008061162f8585613c8b565b6040805160208101869052016040516020818303038152906040528051906020012060001c61165e9190613d24565b905061166a8582613c1b565b95945050505050565b600c5460ff16806116935750600c5461010090046001600160a01b031633145b6116af5760405162461bcd60e51b815260040161072390613afa565b60058211156116ef5760405162461bcd60e51b815260206004820152600c60248201526b0858dbdd5b9d081b1a5b5a5d60a21b6044820152606401610723565b81600d546116fd9190613c6c565b341015806117375750600c5461010090046001600160a01b0316331480156117285750600c5460ff16155b801561173757506005600b5411155b61176c5760405162461bcd60e51b81526020600482015260066024820152652176616c756560d01b6044820152606401610723565b612711600b5411156117905760405162461bcd60e51b815260040161072390613b1a565b60005b82811015610c6a5760008282815181106117bd57634e487b7160e01b600052603260045260246000fd5b60200260200101516040516020016117d591906130d4565b60408051601f1981840301815291815281516020928301206000818152601190935291205490915060ff161561181d5760405162461bcd60e51b815260040161072390613a4f565b6000818152601160205260408120805460ff19166001179055600b54611849906032906101a490611622565b9050600061185e6101f4610398600b54611622565b9050600061187160016019600b54611622565b905060006118858161092d6001600a613c8b565b9050604051806101000160405280438152602001336001600160a01b031681526020018888815181106118c857634e487b7160e01b600052603260045260246000fd5b602090810291909101810151825281810187905260408083018790526060830185905260006080840181905260a0909301869052600b548352600f82529182902083518155838201516001820180546001600160a01b0319166001600160a01b03909216919091179055918301518051611948926002850192019061295a565b50606082015160038201556080820151600482015560a0820151600582015560c082015160068201805460ff191691151591909117905560e090910151600790910155600b54611999903390611f61565b600b546119a7906001613c1b565b600b819055611af41415611a2a5760405133906000908290678ac7230489e80000908381818185875af1925050503d8060008114611a01576040519150601f19603f3d011682016040523d82523d6000602084013e611a06565b606091505b5050905080611a275760405162461bcd60e51b815260040161072390613acc565b50505b600b546127101415611aac57604051339060009082906802b5e3af16b1880000908381818185875af1925050503d8060008114611a83576040519150601f19603f3d011682016040523d82523d6000602084013e611a88565b606091505b5050905080611aa95760405162461bcd60e51b815260040161072390613acc565b50505b50505050508080611abc90613d09565b915050611793565b606060018054610a4190613cce565b6001600160a01b038216331415611b2c5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610723565b3360008181526005602090815260408083206001600160a01b0387168085529252909120805460ff1916841515179055906001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611b99911515815260200190565b60405180910390a35050565b611baf338361211d565b611bcb5760405162461bcd60e51b815260040161072390613b40565b611bd784848484612505565b50505050565b6000818152600f602090815260408083208151610100810183528154815260018201546001600160a01b031693810193909352600281018054606095949384019190611c2890613cce565b80601f0160208091040260200160405190810160405280929190818152602001828054611c5490613cce565b8015611ca15780601f10611c7657610100808354040283529160200191611ca1565b820191906000526020600020905b815481529060010190602001808311611c8457829003601f168201915b5050509183525050600382015460208201526004820154604082015260058201546060820152600682015460ff161515608082015260079091015460a09091015290506000611cf08483611246565b90506000611d018360e001516123bf565b60138460a00151600a8110611d2657634e487b7160e01b600052603260045260246000fd5b0160048560600151611d389190613d24565b15611d5f57604051806040016040528060048152602001634e474d4960e01b815250611d7c565b60405180604001604052806003815260200162474d4960e81b8152505b611da56101a587608001518860600151611d969190613c1b565b611da09190613d24565b6123bf565b8651611db0906123bf565b604051602001611dc4959493929190613262565b60408051601f1981840301815282825290850151909250611deb918490849060200161311f565b60408051601f1981840301815290829052611e0891602001613458565b6040516020818303038152906040529350505050919050565b33611e2b84611524565b6001600160a01b031614611e715760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b6044820152606401610723565b6000838152601060205260409020611bd79083836129de565b6060611e95866123bf565b611e9e866123bf565b611ea7866123bf565b611eb0866123bf565b611ec1611da0600061016d89611622565b611ecc60038a613d24565b15611ef057604051806040016040528060018152602001603160f81b815250611f0d565b60405180604001604052806003815260200162302e3760e81b8152505b604051602001611f229695949392919061349d565b604051602081830303815290604052905095945050505050565b60006001600160e01b0319821663780e9d6360e01b14806106f957506106f982612538565b6001600160a01b038216611fb75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610723565b6000818152600260205260409020546001600160a01b03161561201c5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610723565b61202860008383612588565b6001600160a01b0382166000908152600360205260408120805460019290612051908490613c1b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906120e482611524565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600260205260408120546001600160a01b03166121965760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610723565b60006121a183611524565b9050806001600160a01b0316846001600160a01b031614806121dc5750836001600160a01b03166121d184610ac4565b6001600160a01b0316145b8061220c57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661222782611524565b6001600160a01b03161461228f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610723565b6001600160a01b0382166122f15760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610723565b6122fc838383612588565b6123076000826120af565b6001600160a01b0383166000908152600360205260408120805460019290612330908490613c8b565b90915550506001600160a01b038216600090815260036020526040812080546001929061235e908490613c1b565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6060816123e457506040805180820190915260018152600360fc1b60208201526106fc565b8160005b811561240e57806123f881613d09565b91506124079050600a83613c58565b91506123e8565b60008167ffffffffffffffff81111561243757634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612461576020820181803683370190505b509050815b85156124fc57612477600182613c8b565b90506000612486600a88613c58565b61249190600a613c6c565b61249b9088613c8b565b6124a6906030613c33565b905060008160f81b9050808484815181106124d157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506124f3600a89613c58565b97505050612466565b50949350505050565b612510848484612214565b61251c848484846125d6565b611bd75760405162461bcd60e51b815260040161072390613a7a565b60006001600160e01b031982166380ac58cd60e01b148061256957506001600160e01b03198216635b5e139f60e01b145b806106f957506301ffc9a760e01b6001600160e01b03198316146106f9565b6000818152600f602052604090206006015460ff1615806125b057506001600160a01b038316155b806125c257506001600160a01b038216155b6125cb57600080fd5b610c6a8383836126e3565b60006001600160a01b0384163b156126d857604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061261a9033908990889088906004016139ff565b602060405180830381600087803b15801561263457600080fd5b505af1925050508015612664575060408051601f3d908101601f1916820190925261266191810190612cc0565b60015b6126be573d808015612692576040519150601f19603f3d011682016040523d82523d6000602084013e612697565b606091505b5080516126b65760405162461bcd60e51b815260040161072390613a7a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061220c565b506001949350505050565b6001600160a01b03831661273e5761273981600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612761565b816001600160a01b0316836001600160a01b0316146127615761276183826127a0565b6001600160a01b03821661277d576127788161283d565b610c6a565b826001600160a01b0316826001600160a01b031614610c6a57610c6a8282612916565b600060016127ad8461159b565b6127b79190613c8b565b60008381526007602052604090205490915080821461280a576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061284f90600190613c8b565b6000838152600960205260408120546008805493945090928490811061288557634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905080600883815481106128b457634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806128fa57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006129218361159b565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461296690613cce565b90600052602060002090601f01602090048101928261298857600085556129ce565b82601f106129a157805160ff19168380011785556129ce565b828001600101855582156129ce579182015b828111156129ce5782518255916020019190600101906129b3565b506129da929150612a52565b5090565b8280546129ea90613cce565b90600052602060002090601f016020900481019282612a0c57600085556129ce565b82601f10612a255782800160ff198235161785556129ce565b828001600101855582156129ce579182015b828111156129ce578235825591602001919060010190612a37565b5b808211156129da5760008155600101612a53565b600067ffffffffffffffff831115612a8157612a81613d64565b612a94601f8401601f1916602001613bea565b9050828152838383011115612aa857600080fd5b828260208301376000602084830101529392505050565b80356106fc81613d7a565b803580151581146106fc57600080fd5b600082601f830112612aea578081fd5b612af983833560208501612a67565b9392505050565b600060208284031215612b11578081fd5b8135612af981613d7a565b600060208284031215612b2d578081fd5b8151612af981613d7a565b60008060408385031215612b4a578081fd5b8235612b5581613d7a565b91506020830135612b6581613d7a565b809150509250929050565b600080600060608486031215612b84578081fd5b8335612b8f81613d7a565b92506020840135612b9f81613d7a565b929592945050506040919091013590565b60008060008060808587031215612bc5578081fd5b8435612bd081613d7a565b93506020850135612be081613d7a565b925060408501359150606085013567ffffffffffffffff811115612c02578182fd5b8501601f81018713612c12578182fd5b612c2187823560208401612a67565b91505092959194509250565b60008060408385031215612c3f578182fd5b8235612c4a81613d7a565b9150612c5860208401612aca565b90509250929050565b60008060408385031215612c73578182fd5b8235612c7e81613d7a565b946020939093013593505050565b600060208284031215612c9d578081fd5b5035919050565b600060208284031215612cb5578081fd5b8135612af981613d92565b600060208284031215612cd1578081fd5b8151612af981613d92565b600060208284031215612ced578081fd5b813567ffffffffffffffff811115612d03578182fd5b61220c84828501612ada565b60008060408385031215612d21578182fd5b823567ffffffffffffffff811115612d37578283fd5b612d4385828601612ada565b95602094909401359450505050565b60008060408385031215612d64578182fd5b8235915060208084013567ffffffffffffffff80821115612d83578384fd5b818601915086601f830112612d96578384fd5b813581811115612da857612da8613d64565b612db58485830201613bea565b8181528481019250838501865b83811015612deb57612dd98b888435890101612ada565b85529386019390860190600101612dc2565b5096999098509650505050505050565b600080600060408486031215612e0f578081fd5b83359250602084013567ffffffffffffffff80821115612e2d578283fd5b818601915086601f830112612e40578283fd5b813581811115612e4e578384fd5b876020828501011115612e5f578384fd5b6020830194508093505050509250925092565b60008060408385031215612e84578182fd5b82359150602083013567ffffffffffffffff80821115612ea2578283fd5b8185019150610100808388031215612eb8578384fd5b612ec181613bea565b905082358152612ed360208401612abf565b6020820152604083013582811115612ee9578485fd5b612ef588828601612ada565b604083015250606083013560608201526080830135608082015260a083013560a0820152612f2560c08401612aca565b60c082015260e083013560e08201528093505050509250929050565b600080600060608486031215612f55578081fd5b8335925060208401359150604084013567ffffffffffffffff811115612f79578182fd5b612f8586828701612ada565b9150509250925092565b600080600060608486031215612fa3578081fd5b505081359360208301359350604090920135919050565b600080600080600060a08688031215612fd1578283fd5b505083359560208501359550604085013594606081013594506080013592509050565b6000815180845261300c816020860160208601613ca2565b601f01601f19169290920160200192915050565b60008151613032818560208601613ca2565b9290920192915050565b80546000906002810460018083168061305657607f831692505b602080841082141561307657634e487b7160e01b86526022600452602486fd5b81801561308a576001811461309b576130c8565b60ff198616895284890196506130c8565b60008881526020902060005b868110156130c05781548b8201529085019083016130a7565b505084890196505b50505050505092915050565b600082516130e6818460208701613ca2565b9190910192915050565b60008351613102818460208801613ca2565b835190830190613116818360208801613ca2565b01949350505050565b683d913730b6b2911d1160b91b81528351600090613144816009850160208901613ca2565b6a011161134b6b0b3b2911d160ad1b600991840191820152601160f91b60148201527f646174613a696d6167652f7376672b786d6c3b757466382c00000000000000006015820152845161319f81602d840160208901613ca2565b84519101906131b581602d840160208801613ca2565b01602d0195945050505050565b6000683c7465787420783d2760b81b825284516131e6816009850160208901613ca2565b642720793d2760d81b600991840191820152845161320b81600e840160208901613ca2565b7413903337b73a16b9b4bd329e93989918383c13901f60591b600e92909101918201528351613241816023840160208801613ca2565b661e17ba32bc3a1f60c91b60239290910191820152602a0195945050505050565b60007f222c202261747472696275746573223a5b7b2022646973706c61795f7479706582527f223a20226e756d626572222c2274726169745f74797065223a20224c656166736020830152691116113b30b63ab2911d60b11b604083015286516132d381604a850160208b01613ca2565b7f7d2c207b202274726169745f74797065223a20224261736520436f6c6f72222c604a9184019182015268113b30b63ab2911d1160b91b606a82015261331c607382018861303c565b90507f227d2c7b202274726169745f74797065223a2022446976696e65222c2276616c8152643ab2911d1160d91b60208201528551613362816025840160208a01613ca2565b7f227d2c207b2022646973706c61795f74797065223a20226e756d626572222c20602592909101918201527f2274726169745f74797065223a20224c696768746e657373222c2276616c7565604582015261111d60f11b606582015261344c61343d6134376133d46067850189613020565b7f7d2c207b2022646973706c61795f74797065223a20226e756d626572222c202281527f74726169745f74797065223a2022426c6f636b204e756d626572206d696e746560208201526a321116113b30b63ab2911d60a91b6040820152604b0190565b86613020565b627d5d7d60e81b815260030190565b98975050505050505050565b60007f646174613a6170706c69636174696f6e2f6a736f6e3b757466382c00000000008252825161349081601b850160208701613ca2565b91909101601b0192915050565b60006a01e3830ba3410321e93a6960ad1b825287516134c381600b850160208c01613ca2565b8083019050600160fd1b80600b83015288516134e681600c850160208d01613ca2565b7001020901a9c99101c1b1a1018101810189607d1b600c9390910192830152875161351881601d850160208c01613ca2565b601d920191820152855161353381601e840160208a01613ca2565b6b04e40ccd2d8d87a4ed0e6d8560a31b601e9290910191820152845161356081602a840160208901613ca2565b6135d86135af6135a161359b602a858701017f6465672c203931252c2035352529272066696c6c2d6f7061636974793d2700008152601e0190565b88613020565b61013960f51b815260020190565b7f2066696c7465723d2775726c282364726f70736861646f7729272f3e000000008152601c0190565b9a9950505050505050505050565b7f3c73766720786d6c6e733d27687474703a2f2f7777772e77332e6f72672f323081527f30302f737667272076657273696f6e3d27312e312720786d6c6e733a786c696e60208201527f6b3d27687474703a2f2f7777772e77332e6f72672f313939392f786c696e6b2760408201527f2077696474683d273130303027206865696768743d273130303027207669657760608201527f426f783d2730203020313030302031303030273e20203c66696c74657220696460808201527f3d276e6f697365273e203c666554757262756c656e636520626173654672657160a08201527f75656e63793d27302e3630272078726573756c743d27636f6c6f724e6f69736560c08201527f27202f3e203c6665436f6c6f724d617472697820696e3d27636f6c6f724e6f6960e08201527f73652720747970653d276d6174726978272076616c7565733d272e3333202e336101008201527f33202e333320302030202e3333202e3333202e333320302030202e3333202e336101208201527f33202e33332030203020302030203020312030272f3e20203c6665436f6d706f6101408201527f73697465206f70657261746f723d27696e2720696e323d27536f7572636547726101608201527f61706869632720726573756c743d276d6f6e6f4e6f697365272f3e3c6665426c6101808201527f656e6420696e3d27536f75726365477261706869632720696e323d276d6f6e6f6101a08201527f4e6f69736527206d6f64653d276d756c7469706c7927202f3e3c2f66696c74656101c08201527f723e203c66696c7465722069643d2764726f70736861646f77272068656967686101e08201527f743d2731333025273e3c6665476175737369616e426c757220696e3d27536f756102008201527f726365416c7068612720737464446576696174696f6e3d2733272f3e3c66654f6102208201527f66667365742064783d2732272064793d27322720726573756c743d276f6666736102408201527f6574626c7572272f3e3c6665436f6d706f6e656e745472616e736665723e3c666102608201527f6546756e634120747970653d276c696e6561722720736c6f70653d27302e35276102808201527f2f3e3c2f6665436f6d706f6e656e745472616e736665723e3c66654d657267656102a08201527f3e3c66654d657267654e6f64652f3e3c66654d657267654e6f646520696e3d276102c08201527f536f7572636547726170686963272f3e3c2f66654d657267653e3c2f66696c746102e08201526232b91f60e91b6103008201527f3c726563742077696474683d273130303027206865696768743d273130303027610303820152662066696c6c3d2760c81b610323820152600061166a6139ed6139e76139e161032a86018961303c565b87613020565b85613020565b651e17b9bb339f60d11b815260060190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613a3290830184612ff4565b9695505050505050565b600060208252612af96020830184612ff4565b60208082526011908201527013985b5948185b1c9958591e481d5cd959607a1b604082015260600190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601490820152732330b4b632b2103a379039b2b7321022ba3432b960611b604082015260600190565b602080825260069082015265085cdd185c9d60d21b604082015260600190565b6020808252600c908201526b085b585e081c995858da195960a21b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b8881526001600160a01b038816602082015261010060408201819052600090613bbc8382018a612ff4565b60608401989098525050608081019490945260a0840192909252151560c083015260e0909101529392505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715613c1357613c13613d64565b604052919050565b60008219821115613c2e57613c2e613d38565b500190565b600060ff821660ff84168060ff03821115613c5057613c50613d38565b019392505050565b600082613c6757613c67613d4e565b500490565b6000816000190483118215151615613c8657613c86613d38565b500290565b600082821015613c9d57613c9d613d38565b500390565b60005b83811015613cbd578181015183820152602001613ca5565b83811115611bd75750506000910152565b600281046001821680613ce257607f821691505b60208210811415613d0357634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415613d1d57613d1d613d38565b5060010190565b600082613d3357613d33613d4e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114613d8f57600080fd5b50565b6001600160e01b031981168114613d8f57600080fdfea2646970667358221220130fa17c4b66a4c54600ea04c7aa58ee1a4283f0c7b5a9d07ac6aa6f58f6741d64736f6c63430008020033
Verified Source Code Full Match
Compiler: v0.8.2+commit.661d1103
EVM: istanbul
Optimization: Yes (200 runs)
DrawAbstract.sol 421 lines
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
//import "hardhat/console.sol";
/*
,,aadd8888888ba,
.o8P""' `""Y8o.
.88"' _____ `"88.
.dP' /~ / ~\ `Yb.
.8P j f ~/' "8.
.8" |\ d 7' "8.
.8| | H /| |8
o8 | \`H / | 8b
88 | H / | 8)
88 | \ N | 8)
88 |\ `H / | .8P
Y8 \ H' / o8'
`8| \H/ a8'
`8o H a8'
Yb. H .od'
"8o V .dP'
"V8o,,. ,,od8"
``""YY8888888PP""'
*/
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contract Feather is ERC721, ERC721Enumerable {
IERC721 public vnft;
struct Character {
uint256 blocknumber;
address creator;
string name;
uint256 x;
uint256 y;
uint256 background;
bool isFree;
uint256 leafs;
}
uint256 public supply;
bool public isOpen;
address public artist;
uint256 public price;
uint256 public lastFreeMint;
mapping(uint256 => Character) public infos;
mapping(uint256 => string) public pages;
mapping(bytes32 => bool) public usedNames;
mapping(uint256 => bool) public vnftClaimed;
string[10] backgroungColors = [
"LightGoldenRodYellow",
"PapayaWhip",
"LightCyan",
"Cornsilk",
"Beige",
"OldLace",
"LavenderBlush",
"FloralWhite",
"Moccasin",
"Thistle"
];
constructor(
string memory name_,
string memory symbol_,
address _vnft
) ERC721(name_, symbol_) {
isOpen = false;
artist = msg.sender;
price = 100000000000000000;
vnft = IERC721(_vnft);
}
// The content sent here should be LZMA compressed
function store(uint256 id, string calldata data) public {
require(ownerOf(id) == msg.sender, "Not the owner");
pages[id] = data;
}
// this one leaf
function makePath(
uint256 x1,
uint256 y1,
uint256 x2,
uint256 y2,
uint256 _seed
) public view returns (string memory) {
return
string(
abi.encodePacked(
"<path d='M ",
uint2str(x1),
" ",
uint2str(y1),
" A 592 864 0 0 1 ",
uint2str(x2),
" ",
uint2str(y2),
"' fill='hsl(",
uint2str(random(0, 365, _seed)),
"deg, 91%, 55%)' fill-opacity='",
x2 % 3 == 0 ? "0.7" : "1",
"' ",
" filter='url(#dropshadow)'/>"
)
);
}
function makeText(
uint256 x,
uint256 y,
string memory text
) public view returns (string memory) {
return
string(
abi.encodePacked(
"<text x='",
uint2str(x),
"' y='",
uint2str(y),
"' font-size='120px' >", // stroke='white' stroke-width='1px' >",
text,
"</text>"
)
);
}
function random(
uint256 min,
uint256 max,
uint256 seed
) public pure returns (uint256) {
uint256 randomnumber = uint256(keccak256(abi.encodePacked(seed))) %
(max - min);
return randomnumber + min;
}
function uint2str(uint256 _i)
internal
pure
returns (string memory _uintAsString)
{
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len;
while (_i != 0) {
k = k - 1;
uint8 temp = (48 + uint8(_i - (_i / 10) * 10));
bytes1 b1 = bytes1(temp);
bstr[k] = b1;
_i /= 10;
}
return string(bstr);
}
function generateSVGImage(uint256 _seed, Character memory c)
public
view
returns (string memory)
{
string memory paths;
uint256 rounds = c.leafs;
for (uint256 index; index < rounds; index++) {
// we add as many leaf as decided
paths = string(
abi.encodePacked(
paths,
makePath(
c.x,
c.y,
random(550, 940, _seed + index),
random(80, 600, _seed + index),
_seed + index
)
)
);
}
// add text
paths = string(abi.encodePacked(paths, makeText(20, 950, c.name)));
return
string(
abi.encodePacked(
"<svg xmlns='http://www.w3.org/2000/svg' version='1.1' xmlns:xlink='http://www.w3.org/1999/xlink' width='1000' height='1000' viewBox='0 0 1000 1000'> <filter id='noise'> <feTurbulence baseFrequency='0.60' xresult='colorNoise' /> <feColorMatrix in='colorNoise' type='matrix' values='.33 .33 .33 0 0 .33 .33 .33 0 0 .33 .33 .33 0 0 0 0 0 1 0'/> <feComposite operator='in' in2='SourceGraphic' result='monoNoise'/><feBlend in='SourceGraphic' in2='monoNoise' mode='multiply' /></filter> <filter id='dropshadow' height='130%'><feGaussianBlur in='SourceAlpha' stdDeviation='3'/><feOffset dx='2' dy='2' result='offsetblur'/><feComponentTransfer><feFuncA type='linear' slope='0.5'/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in='SourceGraphic'/></feMerge></filter>",
"<rect width='1000' height='1000' fill='",
backgroungColors[c.background],
c.x % 4 == 0
? "' filter='url(#noise)' ></rect>"
: "' ></rect>",
paths,
"</svg>"
)
);
}
//this is a gift to holders of our previous projects
function vnftClaim(string memory name, uint256 _id) external {
require(isOpen, "!start");
require(supply <= 10001, "!max reached");
// require(block.timestamp > lastFreeMint + 10 minutes, "wait"); removed to easy test
require(vnft.ownerOf(_id) == msg.sender, "!owner");
require(!vnftClaimed[_id], "claimed");
vnftClaimed[_id] = true;
// set name
bytes32 byteName = keccak256(abi.encodePacked(name));
require(usedNames[byteName] == false, "Name already used");
usedNames[byteName] = true;
// MINT
uint256 x = random(50, 420, supply); //starting x/y position
uint256 y = random(500, 920, supply);
uint256 leafs = random(1, 25, supply);
uint256 background = random(0, backgroungColors.length - 1, supply);
infos[supply] = Character(
block.number,
msg.sender,
name,
x,
y,
background,
false,
leafs
);
_mint(msg.sender, supply);
supply = supply + 1;
}
// buy an nft for free (one can be minted by everyone every 10 minutes) and can't be transfered or sold
function freeMint(string memory name) external {
require(isOpen, "!start");
require(supply <= 10001, "!max reached");
require(block.timestamp > lastFreeMint + 10 minutes, "wait");
lastFreeMint = block.timestamp;
// set name
bytes32 byteName = keccak256(abi.encodePacked(name));
require(usedNames[byteName] == false, "Name already used");
usedNames[byteName] = true;
// MINT
uint256 x = random(70, 490, supply); //starting x/y position
uint256 y = random(400, 880, supply);
uint256 leafs = random(1, 25, supply);
uint256 background = random(0, backgroungColors.length - 1, supply);
infos[supply] = Character(
block.number,
msg.sender,
name,
x,
y,
background,
true,
leafs
);
_mint(msg.sender, supply);
supply = supply + 1;
}
// Buy an NFT for 0.1 or x for 0.1 eth by x limitted to 5
function mint(uint256 qty, string[] memory names) public payable {
require(isOpen || msg.sender == artist, "!start");
require(qty <= 5, "!count limit");
require(
msg.value >= price * qty ||
(msg.sender == artist && !isOpen && supply <= 5),
"!value"
); // allow artist to mint 4 pieces before sale
require(supply <= 10001, "!max reached");
for (uint256 i = 0; i < qty; i++) {
// set name
bytes32 byteName = keccak256(abi.encodePacked(names[i]));
require(usedNames[byteName] == false, "Name already used");
usedNames[byteName] = true;
// MINT
uint256 x = random(50, 420, supply); //starting x/y position
uint256 y = random(500, 920, supply);
uint256 leafs = random(1, 25, supply);
uint256 background = random(0, backgroungColors.length - 1, supply);
infos[supply] = Character(
block.number,
msg.sender,
names[i],
x,
y,
background,
false,
leafs
);
_mint(msg.sender, supply);
supply = supply + 1;
if (supply == 6900) {
// special lottery gift /!\
address payable _to = payable(msg.sender); // minter
(bool sent, ) = _to.call{value: 10 ether}("");
require(sent, "Failed to send Ether");
}
if (supply == 10000) {
// special lottery gift /!\
address payable _to = payable(msg.sender); // minter
(bool sent, ) = _to.call{value: 50 ether}("");
require(sent, "Failed to send Ether");
}
}
}
function openSale() public {
require(msg.sender == artist, "!forbidden");
isOpen = true;
}
function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
Character memory c = infos[_tokenId];
string memory image = ((generateSVGImage(_tokenId, c)));
string memory attributes = string(
abi.encodePacked(
'", "attributes":[{ "display_type": "number","trait_type": "Leafs","value":',
uint2str(c.leafs),
'}, { "trait_type": "Base Color","value":"',
backgroungColors[c.background],
'"},{ "trait_type": "Divine","value":"',
c.x % 4 == 0 ? "GMI" : "NGMI",
'"}, { "display_type": "number", "trait_type": "Lightness","value":',
uint2str((c.x + c.y) % 421),
'}, { "display_type": "number", "trait_type": "Block Number minted","value":',
uint2str(c.blocknumber),
"}]}"
)
);
return
string(
abi.encodePacked(
"data:application/json;utf8,",
(
(
abi.encodePacked(
'{"name":"',
c.name,
'","image": ',
'"',
"data:image/svg+xml;utf8,",
image,
attributes
)
)
)
)
);
}
receive() external payable {}
function withdrawEth(address to) public {
require(msg.sender == artist, "!forbidden");
address payable muse = payable(
0x6fBa46974b2b1bEfefA034e236A32e1f10C5A148
); //multisig)
(bool sentMuse, ) = muse.call{value: (address(this).balance / 10)}("");
require(sentMuse, "Failed to send Ether");
address payable _to = payable(to); //multisig
(bool sent, ) = _to.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");
}
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Enumerable, ERC721)
returns (bool)
{
return ERC721Enumerable.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721, ERC721Enumerable) {
require(
infos[tokenId].isFree == false ||
from == address(0x0) ||
to == address(0x0)
);
super._beforeTokenTransfer(from, to, tokenId);
}
}
Address.sol 216 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 66 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
ERC721.sol 411 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
IERC721.sol 142 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
ERC165.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
ERC721Enumerable.sol 162 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
IERC721Enumerable.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
Read Contract
artist 0x43bc1612 → address
balanceOf 0x70a08231 → uint256
generateSVGImage 0x7fb32bcb → string
getApproved 0x081812fc → address
infos 0x28de3c9b → uint256, address, string, uint256, uint256, uint256, bool, uint256
isApprovedForAll 0xe985e9c5 → bool
isOpen 0x47535d7b → bool
lastFreeMint 0xae7b741c → uint256
makePath 0xe70d7998 → string
makeText 0x2fea3088 → string
name 0x06fdde03 → string
ownerOf 0x6352211e → address
pages 0x5c3e9cc2 → string
price 0xa035b1fe → uint256
random 0x7299054c → uint256
supply 0x047fc9aa → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
usedNames 0x750af3ab → bool
vnft 0x168557a5 → address
vnftClaimed 0xa464c98b → bool
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
freeMint 0x1d64b7c1
string name
mint 0x8a1bbf86
uint256 qty
string[] names
openSale 0x167ff46f
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
store 0xe1ff178a
uint256 id
string data
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
vnftClaim 0x06d97bea
string name
uint256 _id
withdrawEth 0x25e16063
address to
Recent Transactions
No transactions found for this address