Address Contract Verified
Address
0x53D917d66EcFec3eF379434b0Ad481E4DdEDcF66
Balance
0 ETH
Nonce
1
Code Size
11447 bytes
Creator
0xCF23e502...6554 at tx 0xc37f125c...394c80
Indexed Transactions
0
Contract Bytecode
11447 bytes
0x608060405234801561001057600080fd5b50600436106102115760003560e01c806370a0823111610125578063cb05f4ef116100ad578063dcc34a991161007c578063dcc34a9914610473578063e2ec6ec314610486578063e8a3d48514610499578063e985e9c5146104a1578063f2fde38b146104dd57600080fd5b8063cb05f4ef14610419578063d1af9ee01461042c578063d5abeb011461043f578063d936547e1461044757600080fd5b806395d89b41116100f457806395d89b41146103c5578063a22cb465146103cd578063b88d4fde146103e0578063c175703b146103f3578063c87b56dd1461040657600080fd5b806370a0823114610386578063715018a614610399578063817c8966146103a15780638da5cb5b146103b457600080fd5b8063286dd3f5116101a85780634f6ccce7116101775780634f6ccce71461032d57806355f804b3146103405780635b7460771461035357806362012b85146103665780636352211e1461037357600080fd5b8063286dd3f5146102ec5780632f745c59146102ff57806342842e0e1461031257806342cc13691461032557600080fd5b80631249c58b116101e45780631249c58b1461029357806318160ddd1461029b5780631e7269c5146102ad57806323b872dd146102d957600080fd5b806301ffc9a71461021657806306fdde031461023e578063081812fc14610253578063095ea7b31461027e575b600080fd5b610229610224366004612204565b6104f0565b60405190151581526020015b60405180910390f35b61024661051b565b6040516102359190612280565b610266610261366004612293565b6105ad565b6040516001600160a01b039091168152602001610235565b61029161028c3660046122c3565b610647565b005b61029161075d565b6008545b604051908152602001610235565b6102296102bb3660046122ed565b6001600160a01b03166000908152600c602052604090205460ff1690565b6102916102e7366004612308565b610a3e565b6102916102fa3660046122ed565b610a6f565b61029f61030d3660046122c3565b610aba565b610291610320366004612308565b610b50565b610291610b6b565b61029f61033b366004612293565b610c7c565b61029161034e366004612344565b610d0f565b61029f610361366004612293565b610d45565b6012546102299060ff1681565b610266610381366004612293565b610df6565b61029f6103943660046122ed565b610e6d565b610291610ef4565b61029f6103af3660046122ed565b610f2a565b600a546001600160a01b0316610266565b610246610fbd565b6102916103db3660046123c6565b610fcc565b6102916103ee366004612440565b611091565b600b54610266906001600160a01b031681565b610246610414366004612293565b6110c9565b610291610427366004612587565b6112aa565b61029161043a3660046125cc565b6114c3565b61029f611500565b6102296104553660046122ed565b6001600160a01b03166000908152600d602052604090205460ff1690565b6102916104813660046122ed565b611514565b6102916104943660046125e7565b611560565b6102466115f6565b6102296104af36600461261c565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102916104eb3660046122ed565b611685565b60006001600160e01b0319821663780e9d6360e01b1480610515575061051582611720565b92915050565b60606000805461052a90612646565b80601f016020809104026020016040519081016040528092919081815260200182805461055690612646565b80156105a35780601f10610578576101008083540402835291602001916105a3565b820191906000526020600020905b81548152906001019060200180831161058657829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b031661062b5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061065282610df6565b9050806001600160a01b0316836001600160a01b031614156106c05760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610622565b336001600160a01b03821614806106dc57506106dc81336104af565b61074e5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610622565b6107588383611770565b505050565b63615d8fc04210156107b15760405162461bcd60e51b815260206004820152601860248201527f436c61696d696e67206e6f7420796574207374617274656400000000000000006044820152606401610622565b336000908152600c602052604090205460ff16156108095760405162461bcd60e51b81526020600482015260156024820152745072696f72206d696e74206279206164647265737360581b6044820152606401610622565b600b546040516370a0823160e01b81523360048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561084d57600080fd5b505afa158015610861573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108859190612681565b9050683635c9adc5dea000008110156108d75760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b6044820152606401610622565b60006a0422ca8b0a00a42500000082101580156108f6575060125460ff165b1561095e576015600e54106109475760405162461bcd60e51b815260206004820152601760248201527610dbdb5b585b99195c881b1a5b5a5d081c995858da1959604a1b6044820152606401610622565b50600e546109568160016126b0565b600e55610a16565b6969e10de76676d0800000821015801561097a575060125460ff165b156109b85760dd600f54106109a15760405162461bcd60e51b8152600401610622906126c8565b50600f546109b08160016126b0565b600f55610a16565b6108ad60115410610a035760405162461bcd60e51b815260206004820152601560248201527414dbdb191a595c881b1a5b5a5d081c995858da1959605a1b6044820152606401610622565b50601154610a128160016126b0565b6011555b610a2033826117de565b5050336000908152600c60205260409020805460ff19166001179055565b610a4833826117f8565b610a645760405162461bcd60e51b8152600401610622906126f7565b6107588383836118ef565b600a546001600160a01b03163314610a995760405162461bcd60e51b815260040161062290612748565b6001600160a01b03166000908152600d60205260409020805460ff19169055565b6000610ac583610e6d565b8210610b275760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610622565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b61075883838360405180602001604052806000815250611091565b336000908152600d602052604090205460ff16610bca5760405162461bcd60e51b815260206004820152601760248201527f41646472657373206e6f742057686974656c69737465640000000000000000006044820152606401610622565b336000908152600c602052604090205460ff1615610c225760405162461bcd60e51b81526020600482015260156024820152745072696f72206d696e74206279206164647265737360581b6044820152606401610622565b60dd600f5410610c445760405162461bcd60e51b8152600401610622906126c8565b600f54610c528160016126b0565b600f55610c5f33826117de565b50336000908152600c60205260409020805460ff19166001179055565b6000610c8760085490565b8210610cea5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610622565b60088281548110610cfd57610cfd61277d565b90600052602060002001549050919050565b600a546001600160a01b03163314610d395760405162461bcd60e51b815260040161062290612748565b61075860138383612155565b60008160011415610d5f576001600e546105159190612793565b8160021415610d77576015600f546105159190612793565b8160031415610da9576101a5601154610d909190612793565b60dd601054610d9f9190612793565b61051591906126b0565b60405162461bcd60e51b815260206004820152601b60248201527f63757272656e74537570706c793a20696e76616c69642072616e6b00000000006044820152606401610622565b919050565b6000818152600260205260408120546001600160a01b0316806105155760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610622565b60006001600160a01b038216610ed85760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610622565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610f1e5760405162461bcd60e51b815260040161062290612748565b610f286000611a9a565b565b600080610f3683610e6d565b905080610f465750600092915050565b6000610f53846000610aba565b90506000805b83811015610f8b57610f6b8682610aba565b915082821015610f79578192505b80610f83816127aa565b915050610f59565b5060dd8210610f9f57506003949350505050565b60158210610fb257506002949350505050565b506001949350505050565b60606001805461052a90612646565b6001600160a01b0382163314156110255760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610622565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61109b33836117f8565b6110b75760405162461bcd60e51b8152600401610622906126f7565b6110c384848484611aec565b50505050565b6000818152600260205260409020546060906001600160a01b03166111405760405162461bcd60e51b815260206004820152602760248201527f4552433732313a2055524920717565727920666f72206e6f6e6578697374656e6044820152663a103a37b5b2b760c91b6064820152608401610622565b6060806015841015611190576040518060400160405280600981526020016821b7b6b6b0b73232b960b91b81525091506040518060600160405280603b8152602001612b56603b91399050611219565b60dd8410156111db576040518060400160405280600781526020016611d95b995c985b60ca1b81525091506040518060600160405280603b8152602001612c47603b91399050611219565b6040518060400160405280600781526020016629b7b63234b2b960c91b81525091506040518060600160405280603b8152602001612bd1603b913990505b6040518060400160405280601d81526020017f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152506112818360148560138660405160200161126d95949392919061285f565b604051602081830303815290604052611b1f565b604051602001611292929190612962565b60405160208183030381529060405292505050919050565b600a546001600160a01b031633146112d45760405162461bcd60e51b815260040161062290612748565b6001825110156113155760405162461bcd60e51b815260206004820152600c60248201526b4e6f2061646472657373657360a01b6044820152606401610622565b6000805b83518110156110c357826001141561138f576015600e54106113775760405162461bcd60e51b815260206004820152601760248201527610dbdb5b585b99195c881b1a5b5a5d081c995858da1959604a1b6044820152606401610622565b600e5491506113878260016126b0565b600e5561148e565b82600214156113d25760dd600f54106113ba5760405162461bcd60e51b8152600401610622906126c8565b600f5491506113ca8260016126b0565b600f5561148e565b8260031415611446576101a56010541061142e5760405162461bcd60e51b815260206004820152601960248201527f44657620536f6c64696572206c696d69742072656163686564000000000000006044820152606401610622565b601054915061143e8260016126b0565b60105561148e565b60405162461bcd60e51b815260206004820152601960248201527f6d696e7442794f776e65723a20696e76616c69642072616e6b000000000000006044820152606401610622565b6114b18482815181106114a3576114a361277d565b6020026020010151836117de565b806114bb816127aa565b915050611319565b600a546001600160a01b031633146114ed5760405162461bcd60e51b815260040161062290612748565b6012805460ff1916911515919091179055565b600061150f60016108ad612793565b905090565b600a546001600160a01b0316331461153e5760405162461bcd60e51b815260040161062290612748565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b600a546001600160a01b0316331461158a5760405162461bcd60e51b815260040161062290612748565b60005b81518110156115f2576001600d60008484815181106115ae576115ae61277d565b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806115ea816127aa565b91505061158d565b5050565b60606040518060400160405280601d81526020017f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000815250611660601460136040518060600160405280603b8152602001612c0c603b913960405160200161126d93929190612991565b604051602001611671929190612962565b604051602081830303815290604052905090565b600a546001600160a01b031633146116af5760405162461bcd60e51b815260040161062290612748565b6001600160a01b0381166117145760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610622565b61171d81611a9a565b50565b60006001600160e01b031982166380ac58cd60e01b148061175157506001600160e01b03198216635b5e139f60e01b145b8061051557506301ffc9a760e01b6001600160e01b0319831614610515565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906117a582610df6565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6115f2828260405180602001604052806000815250611c87565b6000818152600260205260408120546001600160a01b03166118715760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610622565b600061187c83610df6565b9050806001600160a01b0316846001600160a01b031614806118b75750836001600160a01b03166118ac846105ad565b6001600160a01b0316145b806118e757506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b031661190282610df6565b6001600160a01b03161461196a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610622565b6001600160a01b0382166119cc5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610622565b6119d7838383611cba565b6119e2600082611770565b6001600160a01b0383166000908152600360205260408120805460019290611a0b908490612793565b90915550506001600160a01b0382166000908152600360205260408120805460019290611a399084906126b0565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611af78484846118ef565b611b0384848484611d72565b6110c35760405162461bcd60e51b815260040161062290612a52565b6060815160001415611b3f57505060408051602081019091526000815290565b6000604051806060016040528060408152602001612b916040913990506000600384516002611b6e91906126b0565b611b789190612aa4565b611b83906004612ac6565b90506000611b928260206126b0565b67ffffffffffffffff811115611baa57611baa6123f9565b6040519080825280601f01601f191660200182016040528015611bd4576020820181803683370190505b509050818152600183018586518101602084015b81831015611c425760039283018051603f601282901c811687015160f890811b8552600c83901c8216880151811b6001860152600683901c8216880151811b60028601529116860151901b93820193909352600401611be8565b600389510660018114611c5c5760028114611c6d57611c79565b613d3d60f01b600119830152611c79565b603d60f81b6000198301525b509398975050505050505050565b611c918383611e77565b611c9e6000848484611d72565b6107585760405162461bcd60e51b815260040161062290612a52565b6001600160a01b038316611d1557611d1081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b611d38565b816001600160a01b0316836001600160a01b031614611d3857611d388382611fc5565b6001600160a01b038216611d4f5761075881612062565b826001600160a01b0316826001600160a01b031614610758576107588282612111565b60006001600160a01b0384163b15610fb257604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611db6903390899088908890600401612ae5565b602060405180830381600087803b158015611dd057600080fd5b505af1925050508015611e00575060408051601f3d908101601f19168201909252611dfd91810190612b22565b60015b611e5a573d808015611e2e576040519150601f19603f3d011682016040523d82523d6000602084013e611e33565b606091505b508051611e525760405162461bcd60e51b815260040161062290612a52565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b6001600160a01b038216611ecd5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610622565b6000818152600260205260409020546001600160a01b031615611f325760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610622565b611f3e60008383611cba565b6001600160a01b0382166000908152600360205260408120805460019290611f679084906126b0565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001611fd284610e6d565b611fdc9190612793565b60008381526007602052604090205490915080821461202f576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061207490600190612793565b6000838152600960205260408120546008805493945090928490811061209c5761209c61277d565b9060005260206000200154905080600883815481106120bd576120bd61277d565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806120f5576120f5612b3f565b6001900381819060005260206000200160009055905550505050565b600061211c83610e6d565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b82805461216190612646565b90600052602060002090601f01602090048101928261218357600085556121c9565b82601f1061219c5782800160ff198235161785556121c9565b828001600101855582156121c9579182015b828111156121c95782358255916020019190600101906121ae565b506121d59291506121d9565b5090565b5b808211156121d557600081556001016121da565b6001600160e01b03198116811461171d57600080fd5b60006020828403121561221657600080fd5b8135612221816121ee565b9392505050565b60005b8381101561224357818101518382015260200161222b565b838111156110c35750506000910152565b6000815180845261226c816020860160208601612228565b601f01601f19169290920160200192915050565b6020815260006122216020830184612254565b6000602082840312156122a557600080fd5b5035919050565b80356001600160a01b0381168114610df157600080fd5b600080604083850312156122d657600080fd5b6122df836122ac565b946020939093013593505050565b6000602082840312156122ff57600080fd5b612221826122ac565b60008060006060848603121561231d57600080fd5b612326846122ac565b9250612334602085016122ac565b9150604084013590509250925092565b6000806020838503121561235757600080fd5b823567ffffffffffffffff8082111561236f57600080fd5b818501915085601f83011261238357600080fd5b81358181111561239257600080fd5b8660208285010111156123a457600080fd5b60209290920196919550909350505050565b80358015158114610df157600080fd5b600080604083850312156123d957600080fd5b6123e2836122ac565b91506123f0602084016123b6565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612438576124386123f9565b604052919050565b6000806000806080858703121561245657600080fd5b61245f856122ac565b9350602061246e8187016122ac565b935060408601359250606086013567ffffffffffffffff8082111561249257600080fd5b818801915088601f8301126124a657600080fd5b8135818111156124b8576124b86123f9565b6124ca601f8201601f1916850161240f565b915080825289848285010111156124e057600080fd5b808484018584013760008482840101525080935050505092959194509250565b600082601f83011261251157600080fd5b8135602067ffffffffffffffff82111561252d5761252d6123f9565b8160051b61253c82820161240f565b928352848101820192828101908785111561255657600080fd5b83870192505b8483101561257c5761256d836122ac565b8252918301919083019061255c565b979650505050505050565b6000806040838503121561259a57600080fd5b823567ffffffffffffffff8111156125b157600080fd5b6125bd85828601612500565b95602094909401359450505050565b6000602082840312156125de57600080fd5b612221826123b6565b6000602082840312156125f957600080fd5b813567ffffffffffffffff81111561261057600080fd5b6118e784828501612500565b6000806040838503121561262f57600080fd5b612638836122ac565b91506123f0602084016122ac565b600181811c9082168061265a57607f821691505b6020821081141561267b57634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561269357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082198211156126c3576126c361269a565b500190565b60208082526015908201527411d95b995c985b081b1a5b5a5d081c995858da1959605a1b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b6000828210156127a5576127a561269a565b500390565b60006000198214156127be576127be61269a565b5060010190565b8054600090600181811c90808316806127df57607f831692505b602080841082141561280157634e487b7160e01b600052602260045260246000fd5b818015612815576001811461282657612853565b60ff19861689528489019650612853565b60008881526020902060005b8681101561284b5781548b820152908501908301612832565b505084890196505b50505050505092915050565b7503d913730b6b2911d112a2427a92bb0b63632ba1016960551b81528551600090612891816016850160208b01612228565b701116113232b9b1b934b83a34b7b7111d1160791b6016918401918201526128bc60278201886127c5565b90507f222c2261747472696275746573223a5b7b2274726169745f74797065223a20228152702930b735911610113b30b63ab2911d101160791b6020820152855161290e816031840160208a01612228565b6d113eae96101134b6b0b3b2911d1160911b60319290910191820152612937603f8201866127c5565b90508351612949818360208801612228565b61227d60f01b9101908152600201979650505050505050565b60008351612974818460208801612228565b835190830190612988818360208801612228565b01949350505050565b7f7b226e616d65223a202254484f5257616c6c65742041726d79222c202264657381526b31b934b83a34b7b7111d101160a11b602082015260006129d8602c8301866127c5565b6c1116101134b6b0b3b2911d101160991b81526129f8600d8201866127c5565b90508351612a0a818360208801612228565b7f222c202265787465726e616c5f6c696e6b223a202268747470733a2f2f74686f91019081526c7277616c6c65742e6f7267227d60981b6020820152602d0195945050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082612ac157634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612ae057612ae061269a565b500290565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612b1890830184612254565b9695505050505050565b600060208284031215612b3457600080fd5b8151612221816121ee565b634e487b7160e01b600052603160045260246000fdfe62616679626569636b37626a36373769336668713575706f633276706c7534676d676d6764706163627461687836663475716b676c3764617474714142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f626166796265696365796e6976647063726e75363333676d637970333678346c773761766568707a6e626a78356936326135326e7168326c6b356962616679626569686e347933626633363469687777326f677a70716176757279686a6165616b76706b3663693772726b6a6a346d6d73716a70616562616679626569647a66656766706e32346c706a6b6632333574646871766b3236623262737237796537736a326767736f64786b34727332356a75a26469706673582212205312e572fa8f6bf92b7c6920e954184083b81a4f4c30083691642f639921822164736f6c63430008080033
Verified Source Code Full Match
Compiler: v0.8.8+commit.dddeac2f
EVM: london
Optimization: Yes (200 runs)
twanft.sol 270 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.8;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/access/Ownable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.3/contracts/token/ERC20/IERC20.sol";
import "https://github.com/Brechtpd/base64/blob/main/base64.sol";
contract TWNFT is ERC721Enumerable, Ownable {
//This token address will be checked if enough tokens are available
address public requireTokenAddress;
//After this date, public minting of soldiers will be possible. Before this date, only the owner and generals can be minted.
uint256 private constant START_TIMESTAMP = 1633521600; //06.10.2021, 12:00 GMT (14:00 CEST)
//the address that minted an NFT cannot mint it again. You would need to send your tokens to another address to mint again
mapping(address => bool) addressMinted;
//for investors, we can whitelist addresses in order they can mint generals
mapping(address => bool) whitelist;
string private constant COMMANDER = "bafybeick7bj677i3fhq5upoc2vplu4gmgmgdpacbtahx6f4uqkgl7dattq"; //rank 1
string private constant GENERAL = "bafybeidzfegfpn24lpjkf235tdhqvk26b2bsr7ye7sj2ggsodxk4rs25ju"; //rank 2
string private constant SOLDIER = "bafybeiceynivdpcrnu633gmcyp36x4lw7avehpznbjx5i62a52nqh2lk5i"; //rank 3
string private constant ARMY = "bafybeihn4y3bf364ihww2ogzpqavuryhjaeakvpk6ci7rrkjj4mmsqjpae"; //image for platform
uint256 private constant COMMANDER_MINT = 5000000 * 1e18; //5,000,000 x 10^18
uint256 private constant GENERAL_MINT = 500000 * 1e18; // 500,000 x 10^18
uint256 private constant SOLDIER_MINT = 1000 * 1e18; // 1,000 x 10^18
uint256 private constant FIRST_COMMANDER_ID = 1;
uint256 private constant FIRST_GENERAL_ID = 21;
uint256 private constant FIRST_DEV_SOLDIER_ID = 221;
uint256 private constant FIRST_PUB_SOLDIER_ID = 421;
uint256 private constant FIRST_INVALID = 2221;
uint256 private nextCommanderId = FIRST_COMMANDER_ID; // 1-20
uint256 private nextGeneralId = FIRST_GENERAL_ID; // 21-220
uint256 private nextDevSoldierId = FIRST_DEV_SOLDIER_ID; //221-420
uint256 private nextPubSoldierId = FIRST_PUB_SOLDIER_ID; //421-2220
bool public releasedTGT;
string private constant datajson = "data:application/json;base64,";
string private baseURI = "ipfs://";
string private description = "THORWallet NFTs consist of 20 Commanders, 200 Generals and 2000 Soldiers that unlock unique premium features in the THORWallet.";
constructor() ERC721("THORWallet Army", "TWA"){}
//This is for external application to know the current supply of the ranks
//1: the number of commanders minted. If one commander is added, nextCommanderId will be set to 2, while FIRST_COMMANDER_ID is 1, hence 1
//2: the number of generals minted. If one general is added nextGeneralId will be set to 22, while FIRST_GENERAL_ID is 21, hence 1
//3: the number of dev and pub soldiers. If one dev soldier will be added nextDevSoldierId, will be 222, FIRST_DEV_SOLDIER_ID is 221, hence 1
//here we need to add the pub soldier: if one pub soldier will be added nextPubSoldierId, will be 422, FIRST_PUB_SOLDIER_ID is 421, hence 1
function currentSupply(uint256 _rank) public view returns (uint256) {
if (_rank == 1) {
return nextCommanderId - FIRST_COMMANDER_ID;
} else if (_rank == 2) {
return nextGeneralId - FIRST_GENERAL_ID;
} else if (_rank == 3) {
return (nextDevSoldierId - FIRST_DEV_SOLDIER_ID) + (nextPubSoldierId - FIRST_PUB_SOLDIER_ID);
} else {
revert("currentSupply: invalid rank");
}
}
//This is for external application to know the max supply
//Not to be confused with totalSupply, which is the number of minted NFTs
function maxSupply() public pure returns (uint256) {
return FIRST_INVALID - 1;
}
function addAddressesToWhitelist(address[] memory addrs) onlyOwner public {
for (uint256 i = 0; i < addrs.length; i++) {
whitelist[addrs[i]] = true;
}
}
function removeAddressFromWhitelist(address addr) onlyOwner public {
whitelist[addr] = false;
}
function whitelisted(address _address) public view returns (bool) {
return whitelist[_address];
}
function minted(address _address) public view returns (bool) {
return addressMinted[_address];
}
function setBaseURI(string calldata _baseURI) onlyOwner public {
baseURI = _baseURI;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721: URI query for nonexistent token");
string memory rank;
string memory rankImage;
if (tokenId < FIRST_GENERAL_ID) {
rank = "Commander";
rankImage = COMMANDER;
} else if (tokenId < FIRST_DEV_SOLDIER_ID) {
rank = "General";
rankImage = GENERAL;
} else {
rank = "Soldier";
rankImage = SOLDIER;
}
return string(
abi.encodePacked(
datajson,
Base64.encode(
bytes(
abi.encodePacked(
'{"name":"THORWallet - ',
rank,
'","description":"',
description,
'","attributes":[{"trait_type": "Rank", "value": "',
rank,
'"}], "image":"',
baseURI,
rankImage,
'"}'
)
)
)
)
);
}
function getLevel(address _address) public view returns (uint256) {
//Levels: 0=None, 1=Commander, 2=General, 3=Soldier
uint256 addressBalance = balanceOf(_address);
if (addressBalance == 0) {
return 0; //No NFT held
}
uint256 lowest = tokenOfOwnerByIndex(_address, 0);
uint256 id;
for (uint256 i=0; i < addressBalance; i++) {
id = tokenOfOwnerByIndex(_address, i);
if(id < lowest) {
lowest = id;
}
}
if (lowest >= FIRST_DEV_SOLDIER_ID) {
return 3; // Soldier TokenId 221-2220 -> 2000 Soldiers
} else if (lowest >= FIRST_GENERAL_ID) {
return 2; // General TokenId 21-220 -> 200 Generals
} else {
return 1; // Commander TokenId 1-20 -> 20 Commanders
}
}
function setRequiredToken(address _tokenAddress) public onlyOwner {
requireTokenAddress = _tokenAddress;
}
function setReleasedTGT(bool _released) public onlyOwner {
releasedTGT = _released;
}
//used for external projects, e.g., https://docs.opensea.io/docs/contract-level-metadata
function contractURI() public view returns (string memory) {
return string(
abi.encodePacked(
datajson, Base64.encode(
bytes(
abi.encodePacked(
'{"name": "THORWallet Army", "description": "',
description,
'", "image": "',
baseURI,
ARMY,
'", "external_link": "https://thorwallet.org"}'
)
)
)
)
);
}
function mintWhitelisted() public {
require(whitelist[msg.sender], "Address not Whitelisted");
require(!addressMinted[msg.sender], "Prior mint by address");
//check if General limt reached, if we are already at the first dev soldier
require(nextGeneralId < FIRST_DEV_SOLDIER_ID, "General limit reached");
uint256 tokenId = nextGeneralId;
nextGeneralId = nextGeneralId + 1;
_safeMint(msg.sender, tokenId);
//add msg.sender to list of minters, who already minted (they cannot mint twice)
addressMinted[msg.sender] = true;
}
//mints multiple NFTs of same rank to provided addresses
function mintByOwner(address[] memory _addresses, uint256 _rank) public onlyOwner {
require(_addresses.length >= 1, "No addresses");
uint256 tokenId;
for (uint256 i=0; i < _addresses.length; i++) {
if (_rank == 1) {
//check if Commander limit reached, if we are already at the first general id
require(nextCommanderId < FIRST_GENERAL_ID, "Commander limit reached");
tokenId = nextCommanderId;
nextCommanderId = nextCommanderId + 1;
} else if (_rank == 2) {
//check if General limit reached, if we are already at the first dev soldier
require(nextGeneralId < FIRST_DEV_SOLDIER_ID, "General limit reached");
tokenId = nextGeneralId;
nextGeneralId = nextGeneralId + 1;
} else if (_rank == 3) {
//check if Dev Soldier limit reached, if we are already at the public soldier
require(nextDevSoldierId < FIRST_PUB_SOLDIER_ID, "Dev Soldier limit reached");
tokenId = nextDevSoldierId;
nextDevSoldierId = nextDevSoldierId + 1;
} else {
revert("mintByOwner: invalid rank");
}
_safeMint(_addresses[i], tokenId);
}
}
function mint() public {
require(block.timestamp >= START_TIMESTAMP, "Claiming not yet started");
//restricts minting address to 1 nft
require(!addressMinted[msg.sender], "Prior mint by address");
//check token quantity
uint256 bal = IERC20(requireTokenAddress).balanceOf(msg.sender);
//check if insufficient balance, if soldier level not reached
require(bal >= SOLDIER_MINT , "Insufficient balance");
uint256 tokenId;
if (bal >= COMMANDER_MINT && releasedTGT) {
//check if Commander limit reached, if we are already at the first general id
require(nextCommanderId < FIRST_GENERAL_ID, "Commander limit reached");
tokenId = nextCommanderId;
nextCommanderId = nextCommanderId + 1;
} else if (bal >= GENERAL_MINT && releasedTGT) {
//check if General limit reached, if we are already at the first dev soldier
require(nextGeneralId < FIRST_DEV_SOLDIER_ID, "General limit reached");
tokenId = nextGeneralId;
nextGeneralId = nextGeneralId + 1;
} else {
//check if Soldier limit reached, if we are already at the first invalid id
require(nextPubSoldierId < FIRST_INVALID, "Soldier limit reached");
tokenId = nextPubSoldierId;
nextPubSoldierId = nextPubSoldierId + 1;
}
_safeMint(msg.sender, tokenId);
//add msg.sender to list of minters, who already minted (they cannot mint twice)
addressMinted[msg.sender] = true;
}
}
base64.sol 62 lines
// SPDX-License-Identifier: MIT /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides a function for encoding some bytes in base64 library Base64 { string internal constant TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { dataPtr := add(dataPtr, 3) // read 3 bytes let input := mload(dataPtr) // write 4 characters mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(18, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr(12, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and(shr( 6, input), 0x3F))))) resultPtr := add(resultPtr, 1) mstore(resultPtr, shl(248, mload(add(tablePtr, and( input, 0x3F))))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } }
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);
}
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(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");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
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
balanceOf 0x70a08231 → uint256
contractURI 0xe8a3d485 → string
currentSupply 0x5b746077 → uint256
getApproved 0x081812fc → address
getLevel 0x817c8966 → uint256
isApprovedForAll 0xe985e9c5 → bool
maxSupply 0xd5abeb01 → uint256
minted 0x1e7269c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
releasedTGT 0x62012b85 → bool
requireTokenAddress 0xc175703b → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
whitelisted 0xd936547e → bool
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
addAddressesToWhitelist 0xe2ec6ec3
address[] addrs
approve 0x095ea7b3
address to
uint256 tokenId
mint 0x1249c58b
No parameters
mintByOwner 0xcb05f4ef
address[] _addresses
uint256 _rank
mintWhitelisted 0x42cc1369
No parameters
removeAddressFromWhitelist 0x286dd3f5
address addr
renounceOwnership 0x715018a6
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
setBaseURI 0x55f804b3
string _baseURI
setReleasedTGT 0xd1af9ee0
bool _released
setRequiredToken 0xdcc34a99
address _tokenAddress
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address