Address Contract Verified
Address
0xA262fF8F8801C377b1B298c38CaFA83ea34872f1
Balance
0 ETH
Nonce
1
Code Size
18860 bytes
Creator
0x6138F106...A276 at tx 0xe54e9e3e...04bcc9
Indexed Transactions
0
Contract Bytecode
18860 bytes
0x60806040526004361061025f575f3560e01c806395d89b4111610143578063c54e44eb116100b5578063f14210a611610079578063f14210a614610959578063f2fde38b14610981578063f44637ba146109a9578063f8dc404e146109d1578063fc5ef3d3146109fb578063ffdb7dfd14610a23576102b4565b8063c54e44eb14610876578063ca1d9d94146108a0578063db2e21bc146108dd578063dd62ed3e146108f3578063e48ab3cd1461092f576102b4565b8063a69e894e11610107578063a69e894e1461076a578063a814001f14610792578063a9059cbb146107bc578063a937fb63146107f8578063b442c24e14610822578063c415b95c1461084c576102b4565b806395d89b41146106895780639cd441da146106b35780639d7de6b3146106db578063a3ff31b514610703578063a42dce8014610742576102b4565b806342966c68116101dc57806370a08231116101a057806370a082311461056a578063715018a6146105a65780637f9efd46146105bc5780638da5cb5b146105f85780638f5949f91461062257806393f754351461064c576102b4565b806342966c681461047a5780634334614a146104a2578063552f555a146104de578063614aa788146105065780636f73be731461052e576102b4565b806318160ddd1161022357806318160ddd1461039657806323b872dd146103c05780632e0f2625146103fc578063313ce5671461042657806341ae0a3714610450576102b4565b8063013880a8146102b857806302846858146102e057806306fdde0314610308578063095ea7b31461033257806314cea7e71461036e576102b4565b366102b4573373ffffffffffffffffffffffffffffffffffffffff167f1e57e3bb474320be3d2c77138f75b7c3941292d647f5f9634e33a8e94e0e069b346040516102aa9190613a64565b60405180910390a2005b5f5ffd5b3480156102c3575f5ffd5b506102de60048036038101906102d99190613aab565b610a4d565b005b3480156102eb575f5ffd5b5061030660048036038101906103019190613b30565b610dd5565b005b348015610313575f5ffd5b5061031c610e77565b6040516103299190613bcb565b60405180910390f35b34801561033d575f5ffd5b5061035860048036038101906103539190613beb565b610f07565b6040516103659190613c43565b60405180910390f35b348015610379575f5ffd5b50610394600480360381019061038f9190613aab565b610f29565b005b3480156103a1575f5ffd5b506103aa611254565b6040516103b79190613a64565b60405180910390f35b3480156103cb575f5ffd5b506103e660048036038101906103e19190613c5c565b61125d565b6040516103f39190613c43565b60405180910390f35b348015610407575f5ffd5b5061041061128b565b60405161041d9190613cc7565b60405180910390f35b348015610431575f5ffd5b5061043a611290565b6040516104479190613cc7565b60405180910390f35b34801561045b575f5ffd5b50610464611298565b6040516104719190613a64565b60405180910390f35b348015610485575f5ffd5b506104a0600480360381019061049b9190613aab565b61129e565b005b3480156104ad575f5ffd5b506104c860048036038101906104c39190613b30565b611462565b6040516104d59190613c43565b60405180910390f35b3480156104e9575f5ffd5b5061050460048036038101906104ff9190613beb565b61147f565b005b348015610511575f5ffd5b5061052c60048036038101906105279190613aab565b611582565b005b348015610539575f5ffd5b50610554600480360381019061054f9190613b30565b611a6b565b6040516105619190613a64565b60405180910390f35b348015610575575f5ffd5b50610590600480360381019061058b9190613b30565b611ab4565b60405161059d9190613a64565b60405180910390f35b3480156105b1575f5ffd5b506105ba611af9565b005b3480156105c7575f5ffd5b506105e260048036038101906105dd9190613beb565b611b0c565b6040516105ef9190613c43565b60405180910390f35b348015610603575f5ffd5b5061060c611b29565b6040516106199190613cef565b60405180910390f35b34801561062d575f5ffd5b50610636611b51565b6040516106439190613c43565b60405180910390f35b348015610657575f5ffd5b50610672600480360381019061066d9190613aab565b611b7a565b604051610680929190613d08565b60405180910390f35b348015610694575f5ffd5b5061069d611bad565b6040516106aa9190613bcb565b60405180910390f35b3480156106be575f5ffd5b506106d960048036038101906106d49190613d2f565b611c3d565b005b3480156106e6575f5ffd5b5061070160048036038101906106fc9190613d2f565b611d89565b005b34801561070e575f5ffd5b5061072960048036038101906107249190613b30565b611f67565b6040516107399493929190613d6d565b60405180910390f35b34801561074d575f5ffd5b5061076860048036038101906107639190613b30565b6120d7565b005b348015610775575f5ffd5b50610790600480360381019061078b9190613beb565b6121c7565b005b34801561079d575f5ffd5b506107a661245e565b6040516107b39190613a64565b60405180910390f35b3480156107c7575f5ffd5b506107e260048036038101906107dd9190613beb565b612482565b6040516107ef9190613c43565b60405180910390f35b348015610803575f5ffd5b5061080c6124a4565b6040516108199190613a64565b60405180910390f35b34801561082d575f5ffd5b506108366124aa565b6040516108439190613a64565b60405180910390f35b348015610857575f5ffd5b506108606124af565b60405161086d9190613cef565b60405180910390f35b348015610881575f5ffd5b5061088a6124d4565b6040516108979190613e0b565b60405180910390f35b3480156108ab575f5ffd5b506108c660048036038101906108c19190613aab565b6124f8565b6040516108d4929190613d08565b60405180910390f35b3480156108e8575f5ffd5b506108f1612528565b005b3480156108fe575f5ffd5b5061091960048036038101906109149190613e24565b612799565b6040516109269190613a64565b60405180910390f35b34801561093a575f5ffd5b5061094361281b565b6040516109509190613a64565b60405180910390f35b348015610964575f5ffd5b5061097f600480360381019061097a9190613aab565b612824565b005b34801561098c575f5ffd5b506109a760048036038101906109a29190613b30565b6128f4565b005b3480156109b4575f5ffd5b506109cf60048036038101906109ca9190613b30565b612978565b005b3480156109dc575f5ffd5b506109e5612a1b565b6040516109f29190613a64565b60405180910390f35b348015610a06575f5ffd5b50610a216004803603810190610a1c9190613b30565b612a20565b005b348015610a2e575f5ffd5b50610a37612b9c565b604051610a449190613a64565b60405180910390f35b610a55612ba3565b7f00000000000000000000000000000000000000000000000000000000691cbd2b4210610ab7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aae90613eac565b60405180910390fd5b5f8111610af9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af090613f14565b60405180910390fd5b5f6064600183610b099190613f5f565b610b139190613fcd565b90505f8183610b229190613ffd565b90507f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166323b872dd3330866040518463ffffffff1660e01b8152600401610b8193929190614030565b6020604051808303815f875af1158015610b9d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bc1919061408f565b610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf790614104565b60405180910390fd5b5f821115610d04577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b8152600401610c84929190614122565b6020604051808303815f875af1158015610ca0573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cc4919061408f565b610d03576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cfa90614193565b60405180910390fd5b5b610d0e3382612bf2565b610d183382612c71565b3373ffffffffffffffffffffffffffffffffffffffff167fec1430255a2b33641f85114238024a5d33f4cec3181f9eb7744717ec6c75a3ec848385604051610d62939291906141b1565b60405180910390a23373ffffffffffffffffffffffffffffffffffffffff167f2b42f4b25222a5d447ca19dfca2afd1b8d32adfed550f7b87bf9569f6da70c00826276a70042610db291906141e6565b604051610dc0929190613d08565b60405180910390a25050610dd2612e70565b50565b610ddd612e7a565b5f600b5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f90eabbc0c667db2a5029ed6bc0f5fe9f356d11684a4ca9fcfaec0e53f12b9c8e60405160405180910390a250565b606060038054610e8690614246565b80601f0160208091040260200160405190810160405280929190818152602001828054610eb290614246565b8015610efd5780601f10610ed457610100808354040283529160200191610efd565b820191905f5260205f20905b815481529060010190602001808311610ee057829003601f168201915b5050505050905090565b5f5f610f11612f01565b9050610f1e818585612f08565b600191505092915050565b610f31612ba3565b5f8111610f73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6a90613f14565b60405180910390fd5b80610f7d33611ab4565b1015610fbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb5906142c0565b60405180910390fd5b5f6064601483610fce9190613f5f565b610fd89190613fcd565b90505f8183610fe79190613ffd565b9050807f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016110439190613cef565b602060405180830381865afa15801561105e573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061108291906142f2565b10156110c3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110ba90614367565b60405180910390fd5b6110cd3384612f1a565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401611128929190614122565b6020604051808303815f875af1158015611144573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611168919061408f565b6111a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161119e90614104565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff167f31ca5c6da3e8324f73c745c7779875f7b72b1c7a43538e82e988e15d657c107e8483856040516111f1939291906141b1565b60405180910390a23373ffffffffffffffffffffffffffffffffffffffff167ffd38818f5291bf0bb3a2a48aadc06ba8757865d1dabd804585338aab3009dcb68460405161123f9190613a64565b60405180910390a25050611251612e70565b50565b5f600254905090565b5f5f611267612f01565b9050611274858285612f99565b61127f85858561302c565b60019150509392505050565b600681565b5f6006905090565b60085481565b5f81116112e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112d790613f14565b60405180910390fd5b600b5f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16611369576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611360906143cf565b60405180910390fd5b8061137330611ab4565b10156113b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ab90614437565b60405180910390fd5b6113be308261311c565b6113fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f49061449f565b60405180910390fd5b6114073082613268565b6114113082612f1a565b3373ffffffffffffffffffffffffffffffffffffffff167ffd38818f5291bf0bb3a2a48aadc06ba8757865d1dabd804585338aab3009dcb6826040516114579190613a64565b60405180910390a250565b600b602052805f5260405f205f915054906101000a900460ff1681565b611487612e7a565b8061149130611ab4565b10156114d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c990614437565b60405180910390fd5b6114dc308261311c565b61151b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161151290614507565b60405180910390fd5b6115253082613268565b61153030838361302c565b8173ffffffffffffffffffffffffffffffffffffffff167f1861b5c21373949da188f9ce29468a3a32676c94e3fb77da69e60c47ab46c786826040516115769190613a64565b60405180910390a25050565b61158a612ba3565b5f81116115cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c390613f14565b60405180910390fd5b806115d633611ab4565b1015611617576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161160e906142c0565b60405180910390fd5b611621338261311c565b611660576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116579061456f565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000691cbd2b42106116c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b990613eac565b60405180910390fd5b5f8190505f60646001836116d69190613f5f565b6116e09190613fcd565b90505f81836116ef9190613ffd565b9050807f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161174b9190613cef565b602060405180830381865afa158015611766573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061178a91906142f2565b10156117cb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117c290614367565b60405180910390fd5b6117d53385612f1a565b6117df3385613268565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b815260040161183a929190614122565b6020604051808303815f875af1158015611856573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061187a919061408f565b6118b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118b090614104565b60405180910390fd5b5f8211156119bd577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846040518363ffffffff1660e01b815260040161193d929190614122565b6020604051808303815f875af1158015611959573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061197d919061408f565b6119bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b390614193565b60405180910390fd5b5b3373ffffffffffffffffffffffffffffffffffffffff167f31ca5c6da3e8324f73c745c7779875f7b72b1c7a43538e82e988e15d657c107e858385604051611a07939291906141b1565b60405180910390a23373ffffffffffffffffffffffffffffffffffffffff167ffd38818f5291bf0bb3a2a48aadc06ba8757865d1dabd804585338aab3009dcb685604051611a559190613a64565b60405180910390a2505050611a68612e70565b50565b5f600a5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490509050919050565b5f5f5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b611b01612e7a565b611b0a5f6133d8565b565b5f5f611b1784611f67565b50925050508281101591505092915050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b5f7f00000000000000000000000000000000000000000000000000000000691cbd2b4210905090565b5f5f8291506064600183611b8e9190613f5f565b611b989190613fcd565b90508082611ba69190613ffd565b9150915091565b606060048054611bbc90614246565b80601f0160208091040260200160405190810160405280929190818152602001828054611be890614246565b8015611c335780601f10611c0a57610100808354040283529160200191611c33565b820191905f5260205f20905b815481529060010190602001808311611c1657829003601f168201915b5050505050905090565b611c45612e7a565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401611ca293929190614030565b6020604051808303815f875af1158015611cbe573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611ce2919061408f565b611d21576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1890614104565b60405180910390fd5b611d2b3082612bf2565b611d353082612c71565b3373ffffffffffffffffffffffffffffffffffffffff167fac1d76749e5447b7b16f5ab61447e1bd502f3bb4807af3b28e620d1700a6ee458383604051611d7d929190613d08565b60405180910390a25050565b611d91612e7a565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33846040518363ffffffff1660e01b8152600401611dec929190614122565b6020604051808303815f875af1158015611e08573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e2c919061408f565b611e6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6290614104565b60405180910390fd5b80611e7530611ab4565b1015611eb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ead906142c0565b60405180910390fd5b611ec0308261311c565b611eff576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef6906145d7565b60405180910390fd5b611f093082612f1a565b611f133082613268565b3373ffffffffffffffffffffffffffffffffffffffff167f96cd817c6329656790ef8fba7675405193677d39619571282f5e21f3a98cd0598383604051611f5b929190613d08565b60405180910390a25050565b5f5f5f5f5f5f90505b600a5f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490508110156120cf575f600a5f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208281548110612008576120076145f5565b5b905f5260205f2090600302016040518060600160405290815f820154815260200160018201548152602001600282015f9054906101000a900460ff1615151515815250509050805f01518661205d91906141e6565b955080604001511561207f57805f01518361207891906141e6565b92506120c1565b6276a700816020015161209291906141e6565b42106120ae57805f0151846120a791906141e6565b93506120c0565b805f0151856120bd91906141e6565b94505b5b508080600101915050611f70565b509193509193565b6120df612e7a565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361214d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121449061466c565b60405180910390fd5b8060095f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fe5693914d19c789bdee50a362998c0bc8d035a835f9871da5d51152f0582c34f816040516121bc9190613cef565b60405180910390a150565b6121cf612e7a565b7f00000000000000000000000000000000000000000000000000000000691cbd2b4210612231576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161222890613eac565b60405180910390fd5b5f8111612273576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226a90613f14565b60405180910390fd5b807f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a082316122b8611b29565b6040518263ffffffff1660e01b81526004016122d49190613cef565b602060405180830381865afa1580156122ef573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061231391906142f2565b1015612354576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161234b906146d4565b60405180910390fd5b6201518060085461236591906141e6565b421115612374575f6007819055505b64174876e8008160075461238891906141e6565b11156123c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123c09061473c565b60405180910390fd5b6123d38282612bf2565b6123dd8282612c71565b8060075f8282546123ee91906141e6565b92505081905550426008819055508173ffffffffffffffffffffffffffffffffffffffff167f2b42f4b25222a5d447ca19dfca2afd1b8d32adfed550f7b87bf9569f6da70c00826276a7004261244491906141e6565b604051612452929190613d08565b60405180910390a25050565b7f00000000000000000000000000000000000000000000000000000000691cbd2b81565b5f5f61248c612f01565b905061249981858561302c565b600191505092915050565b60075481565b600181565b60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec781565b5f5f60646001846125099190613f5f565b6125139190613fcd565b905080836125219190613ffd565b9150915091565b612530612e7a565b7f00000000000000000000000000000000000000000000000000000000691cbd2b421015612593576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161258a906147a4565b60405180910390fd5b5f4790505f811115612622576125a7611b29565b73ffffffffffffffffffffffffffffffffffffffff166108fc8290811502906040515f60405180830381858888f193505050501580156125e9573d5f5f3e3d5ffd5b507f04590a28d5a843588aa29cd0037e47b18e8e1223898c124a04ab7165d68d826f816040516126199190613a64565b60405180910390a15b5f7f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161267c9190613cef565b602060405180830381865afa158015612697573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906126bb91906142f2565b90505f811115612769577f000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec773ffffffffffffffffffffffffffffffffffffffff1663a9059cbb612709611b29565b836040518363ffffffff1660e01b8152600401612727929190614122565b6020604051808303815f875af1158015612743573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612767919061408f565b505b7f0790d4e391e2a751b9fba814c7b89c653e149c135384a22a6de8abdf1014878160405160405180910390a15050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b64174876e80081565b61282c612e7a565b8047101561286f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016128669061480c565b60405180910390fd5b612877611b29565b73ffffffffffffffffffffffffffffffffffffffff166108fc8290811502906040515f60405180830381858888f193505050501580156128b9573d5f5f3e3d5ffd5b507f04590a28d5a843588aa29cd0037e47b18e8e1223898c124a04ab7165d68d826f816040516128e99190613a64565b60405180910390a150565b6128fc612e7a565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361296c575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016129639190613cef565b60405180910390fd5b612975816133d8565b50565b612980612e7a565b6001600b5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508073ffffffffffffffffffffffffffffffffffffffff167f86e57fd2b90329052917118de7c3f521f400d439b9650deaa906a25b08b9456060405160405180910390a250565b601481565b5f5f90505f5f90505b600a5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080549050811015612b40575f600a5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208281548110612ac157612ac06145f5565b5b905f5260205f2090600302019050806002015f9054906101000a900460ff16158015612aff57506276a7008160010154612afb91906141e6565b4210155b15612b3257805f015483612b1391906141e6565b92506001816002015f6101000a81548160ff0219169083151502179055505b508080600101915050612a29565b505f811115612b98578173ffffffffffffffffffffffffffffffffffffffff167ff9b34e5f901ae9ddd7d4b6c9a2a7f672a926db39101c1d94460a2f0c947150ba82604051612b8f9190613a64565b60405180910390a25b5050565b6276a70081565b600260065403612be8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612bdf90614874565b60405180910390fd5b6002600681905550565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612c62575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401612c599190613cef565b60405180910390fd5b612c6d5f838361349b565b5050565b5f600a5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805490501115612db8575f600a5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f206001600a5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080549050612d449190613ffd565b81548110612d5557612d546145f5565b5b905f5260205f2090600302019050806002015f9054906101000a900460ff16158015612d925750426276a7008260010154612d9091906141e6565b115b15612db65781815f015f828254612da991906141e6565b9250508190555050612e6c565b505b600a5f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2060405180606001604052808381526020014281526020015f1515815250908060018154018082558091505060019003905f5260205f2090600302015f909190919091505f820151815f0155602082015181600101556040820151816002015f6101000a81548160ff02191690831515021790555050505b5050565b6001600681905550565b612e82612f01565b73ffffffffffffffffffffffffffffffffffffffff16612ea0611b29565b73ffffffffffffffffffffffffffffffffffffffff1614612eff57612ec3612f01565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401612ef69190613cef565b60405180910390fd5b565b5f33905090565b612f158383836001613664565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603612f8a575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401612f819190613cef565b60405180910390fd5b612f95825f8361349b565b5050565b5f612fa48484612799565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156130265781811015613017578281836040517ffb8f41b200000000000000000000000000000000000000000000000000000000815260040161300e93929190614892565b60405180910390fd5b61302584848484035f613664565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361309c575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016130939190613cef565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361310c575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016131039190613cef565b60405180910390fd5b61311783838361349b565b505050565b5f5f5f5f90505b600a5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208054905081101561325c575f600a5f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2082815481106131bb576131ba6145f5565b5b905f5260205f2090600302016040518060600160405290815f820154815260200160018201548152602001600282015f9054906101000a900460ff1615151515815250509050806040015115801561322457506276a700816020015161322191906141e6565b42105b1561324e57805f01518361323891906141e6565b925084831061324d5760019350505050613262565b5b508080600101915050613123565b505f9150505b92915050565b5f8190505f5f90505b600a5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080549050811080156132bf57505f82115b156133d2575f600a5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208281548110613314576133136145f5565b5b905f5260205f2090600302019050806002015f9054906101000a900460ff1615801561335157506276a700816001015461334e91906141e6565b42105b156133be575f815f01548411613367578361336c565b815f01545b905080825f015f8282546133809190613ffd565b9250508190555080846133939190613ffd565b93505f825f0154036133bc576001826002015f6101000a81548160ff0219169083151502179055505b505b5080806133ca906148c7565b915050613271565b50505050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614613522576134d8838261311c565b613517576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161350e90614958565b60405180910390fd5b6135218382613268565b5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415801561355d57505f81115b156136545761356c8282612c71565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f1b89874203ff7f0bba87c969ada3f32fda22ed38a6706d35199d21280c7811b1836040516135c99190613a64565b60405180910390a33073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613653578273ffffffffffffffffffffffffffffffffffffffff167fa8592083fa7e499312ad37c0f717a24e3f37244f0fa56bf7e0371812533a8e468260405161364a9190613a64565b60405180910390a25b5b61365f838383613833565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16036136d4575f6040517fe602df050000000000000000000000000000000000000000000000000000000081526004016136cb9190613cef565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603613744575f6040517f94280d6200000000000000000000000000000000000000000000000000000000815260040161373b9190613cef565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550801561382d578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516138249190613a64565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603613883578060025f82825461387791906141e6565b92505081905550613951565b5f5f5f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490508181101561390c578381836040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161390393929190614892565b60405180910390fd5b8181035f5f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603613998578060025f82825403925050819055506139e2565b805f5f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051613a3f9190613a64565b60405180910390a3505050565b5f819050919050565b613a5e81613a4c565b82525050565b5f602082019050613a775f830184613a55565b92915050565b5f5ffd5b613a8a81613a4c565b8114613a94575f5ffd5b50565b5f81359050613aa581613a81565b92915050565b5f60208284031215613ac057613abf613a7d565b5b5f613acd84828501613a97565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f613aff82613ad6565b9050919050565b613b0f81613af5565b8114613b19575f5ffd5b50565b5f81359050613b2a81613b06565b92915050565b5f60208284031215613b4557613b44613a7d565b5b5f613b5284828501613b1c565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f613b9d82613b5b565b613ba78185613b65565b9350613bb7818560208601613b75565b613bc081613b83565b840191505092915050565b5f6020820190508181035f830152613be38184613b93565b905092915050565b5f5f60408385031215613c0157613c00613a7d565b5b5f613c0e85828601613b1c565b9250506020613c1f85828601613a97565b9150509250929050565b5f8115159050919050565b613c3d81613c29565b82525050565b5f602082019050613c565f830184613c34565b92915050565b5f5f5f60608486031215613c7357613c72613a7d565b5b5f613c8086828701613b1c565b9350506020613c9186828701613b1c565b9250506040613ca286828701613a97565b9150509250925092565b5f60ff82169050919050565b613cc181613cac565b82525050565b5f602082019050613cda5f830184613cb8565b92915050565b613ce981613af5565b82525050565b5f602082019050613d025f830184613ce0565b92915050565b5f604082019050613d1b5f830185613a55565b613d286020830184613a55565b9392505050565b5f5f60408385031215613d4557613d44613a7d565b5b5f613d5285828601613a97565b9250506020613d6385828601613a97565b9150509250929050565b5f608082019050613d805f830187613a55565b613d8d6020830186613a55565b613d9a6040830185613a55565b613da76060830184613a55565b95945050505050565b5f819050919050565b5f613dd3613dce613dc984613ad6565b613db0565b613ad6565b9050919050565b5f613de482613db9565b9050919050565b5f613df582613dda565b9050919050565b613e0581613deb565b82525050565b5f602082019050613e1e5f830184613dfc565b92915050565b5f5f60408385031215613e3a57613e39613a7d565b5b5f613e4785828601613b1c565b9250506020613e5885828601613b1c565b9150509250929050565b7f436f6e74726163742065787069726564000000000000000000000000000000005f82015250565b5f613e96601083613b65565b9150613ea182613e62565b602082019050919050565b5f6020820190508181035f830152613ec381613e8a565b9050919050565b7f416d6f756e74206d75737420626520706f7369746976650000000000000000005f82015250565b5f613efe601783613b65565b9150613f0982613eca565b602082019050919050565b5f6020820190508181035f830152613f2b81613ef2565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f613f6982613a4c565b9150613f7483613a4c565b9250828202613f8281613a4c565b91508282048414831517613f9957613f98613f32565b5b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f613fd782613a4c565b9150613fe283613a4c565b925082613ff257613ff1613fa0565b5b828204905092915050565b5f61400782613a4c565b915061401283613a4c565b925082820390508181111561402a57614029613f32565b5b92915050565b5f6060820190506140435f830186613ce0565b6140506020830185613ce0565b61405d6040830184613a55565b949350505050565b61406e81613c29565b8114614078575f5ffd5b50565b5f8151905061408981614065565b92915050565b5f602082840312156140a4576140a3613a7d565b5b5f6140b18482850161407b565b91505092915050565b7f55534454207472616e73666572206661696c65640000000000000000000000005f82015250565b5f6140ee601483613b65565b91506140f9826140ba565b602082019050919050565b5f6020820190508181035f83015261411b816140e2565b9050919050565b5f6040820190506141355f830185613ce0565b6141426020830184613a55565b9392505050565b7f466565207472616e73666572206661696c6564000000000000000000000000005f82015250565b5f61417d601383613b65565b915061418882614149565b602082019050919050565b5f6020820190508181035f8301526141aa81614171565b9050919050565b5f6060820190506141c45f830186613a55565b6141d16020830185613a55565b6141de6040830184613a55565b949350505050565b5f6141f082613a4c565b91506141fb83613a4c565b925082820190508082111561421357614212613f32565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061425d57607f821691505b6020821081036142705761426f614219565b5b50919050565b7f496e73756666696369656e74204e5443732062616c616e6365000000000000005f82015250565b5f6142aa601983613b65565b91506142b582614276565b602082019050919050565b5f6020820190508181035f8301526142d78161429e565b9050919050565b5f815190506142ec81613a81565b92915050565b5f6020828403121561430757614306613a7d565b5b5f614314848285016142de565b91505092915050565b7f496e73756666696369656e742055534454206c697175696469747900000000005f82015250565b5f614351601b83613b65565b915061435c8261431d565b602082019050919050565b5f6020820190508181035f83015261437e81614345565b9050919050565b7f43616c6c6572206973206e6f7420617574686f72697a6564206275726e6572005f82015250565b5f6143b9601f83613b65565b91506143c482614385565b602082019050919050565b5f6020820190508181035f8301526143e6816143ad565b9050919050565b7f496e73756666696369656e7420636f6e74726163742062616c616e63650000005f82015250565b5f614421601d83613b65565b915061442c826143ed565b602082019050919050565b5f6020820190508181035f83015261444e81614415565b9050919050565b7f43616e6e6f74206275726e206578706972656420746f6b656e730000000000005f82015250565b5f614489601a83613b65565b915061449482614455565b602082019050919050565b5f6020820190508181035f8301526144b68161447d565b9050919050565b7f43616e6e6f74207472616e73666572206578706972656420746f6b656e7300005f82015250565b5f6144f1601e83613b65565b91506144fc826144bd565b602082019050919050565b5f6020820190508181035f83015261451e816144e5565b9050919050565b7f43616e6e6f742073776170206578706972656420746f6b656e730000000000005f82015250565b5f614559601a83613b65565b915061456482614525565b602082019050919050565b5f6020820190508181035f8301526145868161454d565b9050919050565b7f43616e6e6f742072656d6f7665206578706972656420746f6b656e73000000005f82015250565b5f6145c1601c83613b65565b91506145cc8261458d565b602082019050919050565b5f6020820190508181035f8301526145ee816145b5565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f496e76616c6964206164647265737300000000000000000000000000000000005f82015250565b5f614656600f83613b65565b915061466182614622565b602082019050919050565b5f6020820190508181035f8301526146838161464a565b9050919050565b7f496e73756666696369656e742055534454206261636b696e67000000000000005f82015250565b5f6146be601983613b65565b91506146c98261468a565b602082019050919050565b5f6020820190508181035f8301526146eb816146b2565b9050919050565b7f45786365656473206461696c79206c696d6974000000000000000000000000005f82015250565b5f614726601383613b65565b9150614731826146f2565b602082019050919050565b5f6020820190508181035f8301526147538161471a565b9050919050565b7f436f6e7472616374207374696c6c2061637469766500000000000000000000005f82015250565b5f61478e601583613b65565b91506147998261475a565b602082019050919050565b5f6020820190508181035f8301526147bb81614782565b9050919050565b7f496e73756666696369656e74204554482062616c616e636500000000000000005f82015250565b5f6147f6601883613b65565b9150614801826147c2565b602082019050919050565b5f6020820190508181035f830152614823816147ea565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c005f82015250565b5f61485e601f83613b65565b91506148698261482a565b602082019050919050565b5f6020820190508181035f83015261488b81614852565b9050919050565b5f6060820190506148a55f830186613ce0565b6148b26020830185613a55565b6148bf6040830184613a55565b949350505050565b5f6148d182613a4c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff820361490357614902613f32565b5b600182019050919050565b7f496e73756666696369656e742076616c696420746f6b656e73000000000000005f82015250565b5f614942601983613b65565b915061494d8261490e565b602082019050919050565b5f6020820190508181035f83015261496f81614936565b905091905056fea264697066735822122071de4db89f8f8cb016f10293551014d0537ba4e904f9f9a80e1b80ef41009de864736f6c634300081e0033
Verified Source Code Full Match
Compiler: v0.8.30+commit.73712a01
EVM: prague
Optimization: No
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
draft-IERC6093.sol 161 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC6093.sol)
pragma solidity >=0.8.4;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
ERC20.sol 305 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @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);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
swapabletoken.sol 367 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract Safestablecoins is ERC20, Ownable, ReentrancyGuard {
// Token configuration
uint8 public constant DECIMALS = 6;
uint256 public constant TOKEN_LIFETIME = 90 days;
uint256 public constant MAX_DAILY_CREATION = 100_000 * 10**6;
uint256 public constant SWAP_FEE_PERCENT = 1; // 1% swap fee
uint256 public constant EXPIRED_PENALTY = 20; // 20% penalty for expired tokens
// Contract state
IERC20 public immutable USDT;
uint256 public immutable contractExpiration;
uint256 public dailyCreated;
uint256 public lastCreationDate;
address public feeCollector;
// Token tracking
struct TokenBatch {
uint256 amount;
uint256 createTime;
bool spent;
}
mapping(address => TokenBatch[]) private _userTokenBatches;
// Burner system
mapping(address => bool) public isBurner;
// Events
event TokensCreated(address indexed recipient, uint256 amount, uint256 expiryDate);
event TokensTransferred(address indexed from, address indexed to, uint256 amount);
event TokensBurned(address indexed burner, uint256 amount);
event ContractExpired();
event EtherWithdrawn(uint256 amount);
event BurnerAdded(address indexed burner);
event BurnerRemoved(address indexed burner);
event ExpiredTokensCleaned(address indexed user, uint256 amount);
event EtherReceived(address indexed sender, uint256 amount);
event ContractTokensReceived(address indexed from, uint256 amount);
event ContractTokensTransferred(address indexed to, uint256 amount);
event SwappedUSDTtoNTCs(address indexed user, uint256 usdtAmount, uint256 ntcsAmount, uint256 fee);
event SwappedNTCstoUSDT(address indexed user, uint256 ntcsAmount, uint256 usdtAmount, uint256 fee);
event LiquidityAdded(address indexed provider, uint256 usdtAmount, uint256 ntcsAmount);
event LiquidityRemoved(address indexed provider, uint256 usdtAmount, uint256 ntcsAmount);
event FeeCollectorUpdated(address newCollector);
constructor(address usdtAddress, address initialOwner, address _feeCollector)
ERC20("Safe Stable Coin", "SST")
Ownable(initialOwner)
{
require(usdtAddress != address(0), "Invalid USDT address");
require(_feeCollector != address(0), "Invalid fee collector address");
USDT = IERC20(usdtAddress);
contractExpiration = block.timestamp + TOKEN_LIFETIME;
isBurner[initialOwner] = true;
feeCollector = _feeCollector;
}
// ========== ETH HANDLING ========== //
receive() external payable {
emit EtherReceived(msg.sender, msg.value);
}
function withdrawETH(uint256 amount) external onlyOwner {
require(address(this).balance >= amount, "Insufficient ETH balance");
payable(owner()).transfer(amount);
emit EtherWithdrawn(amount);
}
// ========== CONTRACT TOKEN TRANSFERS ========== //
function transferContractTokens(address recipient, uint256 amount) external onlyOwner {
require(balanceOf(address(this)) >= amount, "Insufficient contract balance");
require(_hasValidTokens(address(this), amount), "Cannot transfer expired tokens");
_markTokensSpent(address(this), amount);
_transfer(address(this), recipient, amount);
emit ContractTokensTransferred(recipient, amount);
}
// ========== CORE TOKEN LOGIC ========== //
function decimals() public pure override returns (uint8) {
return DECIMALS;
}
function _update(address from, address to, uint256 amount) internal override {
if (from != address(0)) {
require(_hasValidTokens(from, amount), "Insufficient valid tokens");
_markTokensSpent(from, amount);
}
if (to != address(0) && amount > 0) {
_addTokenBatch(to, amount);
emit TokensTransferred(from, to, amount);
if (to == address(this)) {
emit ContractTokensReceived(from, amount);
}
}
super._update(from, to, amount);
}
function _addTokenBatch(address user, uint256 amount) private {
if (_userTokenBatches[user].length > 0) {
TokenBatch storage lastBatch = _userTokenBatches[user][_userTokenBatches[user].length - 1];
if (!lastBatch.spent && lastBatch.createTime + TOKEN_LIFETIME > block.timestamp) {
lastBatch.amount += amount;
return;
}
}
_userTokenBatches[user].push(TokenBatch(amount, block.timestamp, false));
}
function _hasValidTokens(address user, uint256 needed) private view returns (bool) {
uint256 valid;
for (uint i = 0; i < _userTokenBatches[user].length; i++) {
TokenBatch memory batch = _userTokenBatches[user][i];
if (!batch.spent && block.timestamp < batch.createTime + TOKEN_LIFETIME) {
valid += batch.amount;
if (valid >= needed) return true;
}
}
return false;
}
function _markTokensSpent(address user, uint256 amount) private {
uint256 remaining = amount;
for (uint i = 0; i < _userTokenBatches[user].length && remaining > 0; i++) {
TokenBatch storage batch = _userTokenBatches[user][i];
if (!batch.spent && block.timestamp < batch.createTime + TOKEN_LIFETIME) {
uint256 use = remaining > batch.amount ? batch.amount : remaining;
batch.amount -= use;
remaining -= use;
if (batch.amount == 0) {
batch.spent = true;
}
}
}
}
// ========== TOKEN CREATION ========== //
function createTokens(address recipient, uint256 amount) external onlyOwner {
require(block.timestamp < contractExpiration, "Contract expired");
require(amount > 0, "Amount must be positive");
// require(USDT.transferFrom(owner(), address(this), amount), "USDT transfer failed");
require(USDT.balanceOf(owner()) >= amount, "Insufficient USDT backing");
if (block.timestamp > lastCreationDate + 1 days) {
dailyCreated = 0;
}
require(dailyCreated + amount <= MAX_DAILY_CREATION, "Exceeds daily limit");
_mint(recipient, amount);
_addTokenBatch(recipient, amount);
dailyCreated += amount;
lastCreationDate = block.timestamp;
emit TokensCreated(recipient, amount, block.timestamp + TOKEN_LIFETIME);
}
// ========== SWAP FUNCTIONALITY ========== //
function swapUSDTtoNTCs(uint256 usdtAmount) external nonReentrant {
require(block.timestamp < contractExpiration, "Contract expired");
require(usdtAmount > 0, "Amount must be positive");
// Calculate swap amount with fee
uint256 fee = (usdtAmount * SWAP_FEE_PERCENT) / 100;
uint256 swapAmount = usdtAmount - fee;
// Transfer USDT from user
require(USDT.transferFrom(msg.sender, address(this), usdtAmount), "USDT transfer failed");
// Transfer fee to collector
if (fee > 0) {
require(USDT.transfer(feeCollector, fee), "Fee transfer failed");
}
// Mint NTCs to user
_mint(msg.sender, swapAmount);
_addTokenBatch(msg.sender, swapAmount);
emit SwappedUSDTtoNTCs(msg.sender, usdtAmount, swapAmount, fee);
emit TokensCreated(msg.sender, swapAmount, block.timestamp + TOKEN_LIFETIME);
}
function swapNTCstoUSDT(uint256 ntcsAmount) external nonReentrant {
require(ntcsAmount > 0, "Amount must be positive");
require(balanceOf(msg.sender) >= ntcsAmount, "Insufficient NTCs balance");
require(_hasValidTokens(msg.sender, ntcsAmount), "Cannot swap expired tokens");
require(block.timestamp < contractExpiration, "Contract expired");
// Calculate swap amount with fee
uint256 usdtValue = ntcsAmount; // 1:1 ratio (adjust if different)
uint256 fee = (usdtValue * SWAP_FEE_PERCENT) / 100;
uint256 swapAmount = usdtValue - fee;
require(USDT.balanceOf(address(this)) >= swapAmount, "Insufficient USDT liquidity");
// Burn NTCs
_burn(msg.sender, ntcsAmount);
_markTokensSpent(msg.sender, ntcsAmount);
// Transfer USDT to user
require(USDT.transfer(msg.sender, swapAmount), "USDT transfer failed");
// Transfer fee to collector
if (fee > 0) {
require(USDT.transfer(feeCollector, fee), "Fee transfer failed");
}
emit SwappedNTCstoUSDT(msg.sender, ntcsAmount, swapAmount, fee);
emit TokensBurned(msg.sender, ntcsAmount);
}
function swapExpiredNTCs(uint256 ntcsAmount) external nonReentrant {
require(ntcsAmount > 0, "Amount must be positive");
require(balanceOf(msg.sender) >= ntcsAmount, "Insufficient NTCs balance");
// Calculate penalty amount
uint256 penalty = (ntcsAmount * EXPIRED_PENALTY) / 100;
uint256 swapAmount = ntcsAmount - penalty;
require(USDT.balanceOf(address(this)) >= swapAmount, "Insufficient USDT liquidity");
// Burn NTCs
_burn(msg.sender, ntcsAmount);
// Transfer USDT to user (with penalty)
require(USDT.transfer(msg.sender, swapAmount), "USDT transfer failed");
// Penalty stays in contract as additional liquidity
emit SwappedNTCstoUSDT(msg.sender, ntcsAmount, swapAmount, penalty);
emit TokensBurned(msg.sender, ntcsAmount);
}
// ========== LIQUIDITY MANAGEMENT ========== //
function addLiquidity(uint256 usdtAmount, uint256 ntcsAmount) external onlyOwner {
require(USDT.transferFrom(msg.sender, address(this), usdtAmount), "USDT transfer failed");
_mint(address(this), ntcsAmount);
_addTokenBatch(address(this), ntcsAmount);
emit LiquidityAdded(msg.sender, usdtAmount, ntcsAmount);
}
function removeLiquidity(uint256 usdtAmount, uint256 ntcsAmount) external onlyOwner {
require(USDT.transfer(msg.sender, usdtAmount), "USDT transfer failed");
require(balanceOf(address(this)) >= ntcsAmount, "Insufficient NTCs balance");
require(_hasValidTokens(address(this), ntcsAmount), "Cannot remove expired tokens");
_burn(address(this), ntcsAmount);
_markTokensSpent(address(this), ntcsAmount);
emit LiquidityRemoved(msg.sender, usdtAmount, ntcsAmount);
}
// ========== BURNING SYSTEM ========== //
function burn(uint256 amount) external {
require(amount > 0, "Amount must be positive");
require(isBurner[msg.sender], "Caller is not authorized burner");
require(balanceOf(address(this)) >= amount, "Insufficient contract balance");
require(_hasValidTokens(address(this), amount), "Cannot burn expired tokens");
_markTokensSpent(address(this), amount);
_burn(address(this), amount);
emit TokensBurned(msg.sender, amount);
}
// ========== TOKEN MANAGEMENT ========== //
function cleanExpiredTokens(address user) external {
uint256 cleaned = 0;
for (uint i = 0; i < _userTokenBatches[user].length; i++) {
TokenBatch storage batch = _userTokenBatches[user][i];
if (!batch.spent && block.timestamp >= batch.createTime + TOKEN_LIFETIME) {
cleaned += batch.amount;
batch.spent = true;
}
}
if (cleaned > 0) {
emit ExpiredTokensCleaned(user, cleaned);
}
}
// ========== ADMIN FUNCTIONS ========== //
function addBurner(address account) external onlyOwner {
isBurner[account] = true;
emit BurnerAdded(account);
}
function removeBurner(address account) external onlyOwner {
isBurner[account] = false;
emit BurnerRemoved(account);
}
function setFeeCollector(address newCollector) external onlyOwner {
require(newCollector != address(0), "Invalid address");
feeCollector = newCollector;
emit FeeCollectorUpdated(newCollector);
}
function emergencyWithdraw() external onlyOwner {
require(block.timestamp >= contractExpiration, "Contract still active");
uint256 balance = address(this).balance;
if (balance > 0) {
payable(owner()).transfer(balance);
emit EtherWithdrawn(balance);
}
uint256 usdtBalance = USDT.balanceOf(address(this));
if (usdtBalance > 0) {
USDT.transfer(owner(), usdtBalance);
}
emit ContractExpired();
}
// ========== VIEW FUNCTIONS ========== //
function getTokenStatus(address user) public view returns (
uint256 total,
uint256 valid,
uint256 expired,
uint256 spent
) {
for (uint i = 0; i < _userTokenBatches[user].length; i++) {
TokenBatch memory batch = _userTokenBatches[user][i];
total += batch.amount;
if (batch.spent) {
spent += batch.amount;
} else if (block.timestamp >= batch.createTime + TOKEN_LIFETIME) {
expired += batch.amount;
} else {
valid += batch.amount;
}
}
}
function isContractActive() public view returns (bool) {
return block.timestamp < contractExpiration;
}
function areTokensValid(address user, uint256 amount) public view returns (bool) {
(,,uint256 valid,) = getTokenStatus(user);
return valid >= amount;
}
function getTokenBatchCount(address user) public view returns (uint256) {
return _userTokenBatches[user].length;
}
function getSwapQuoteUSDTtoNTCs(uint256 usdtAmount) public pure returns (uint256 ntcsAmount, uint256 fee) {
fee = (usdtAmount * SWAP_FEE_PERCENT) / 100;
ntcsAmount = usdtAmount - fee; // 1:1 ratio (adjust if different)
}
function getSwapQuoteNTCstoUSDT(uint256 ntcsAmount) public pure returns (uint256 usdtAmount, uint256 fee) {
usdtAmount = ntcsAmount; // 1:1 ratio (adjust if different)
fee = (usdtAmount * SWAP_FEE_PERCENT) / 100;
usdtAmount -= fee;
}
}
Read Contract
DECIMALS 0x2e0f2625 → uint8
EXPIRED_PENALTY 0xf8dc404e → uint256
MAX_DAILY_CREATION 0xe48ab3cd → uint256
SWAP_FEE_PERCENT 0xb442c24e → uint256
TOKEN_LIFETIME 0xffdb7dfd → uint256
USDT 0xc54e44eb → address
allowance 0xdd62ed3e → uint256
areTokensValid 0x7f9efd46 → bool
balanceOf 0x70a08231 → uint256
contractExpiration 0xa814001f → uint256
dailyCreated 0xa937fb63 → uint256
decimals 0x313ce567 → uint8
feeCollector 0xc415b95c → address
getSwapQuoteNTCstoUSDT 0x93f75435 → uint256, uint256
getSwapQuoteUSDTtoNTCs 0xca1d9d94 → uint256, uint256
getTokenBatchCount 0x6f73be73 → uint256
getTokenStatus 0xa3ff31b5 → uint256, uint256, uint256, uint256
isBurner 0x4334614a → bool
isContractActive 0x8f5949f9 → bool
lastCreationDate 0x41ae0a37 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 19 functions
These functions modify contract state and require a wallet transaction to execute.
addBurner 0xf44637ba
address account
addLiquidity 0x9cd441da
uint256 usdtAmount
uint256 ntcsAmount
approve 0x095ea7b3
address spender
uint256 value
returns: bool
burn 0x42966c68
uint256 amount
cleanExpiredTokens 0xfc5ef3d3
address user
createTokens 0xa69e894e
address recipient
uint256 amount
emergencyWithdraw 0xdb2e21bc
No parameters
removeBurner 0x02846858
address account
removeLiquidity 0x9d7de6b3
uint256 usdtAmount
uint256 ntcsAmount
renounceOwnership 0x715018a6
No parameters
setFeeCollector 0xa42dce80
address newCollector
swapExpiredNTCs 0x14cea7e7
uint256 ntcsAmount
swapNTCstoUSDT 0x614aa788
uint256 ntcsAmount
swapUSDTtoNTCs 0x013880a8
uint256 usdtAmount
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferContractTokens 0x552f555a
address recipient
uint256 amount
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
withdrawETH 0xf14210a6
uint256 amount
Recent Transactions
No transactions found for this address