Address Contract Partially Verified
Address
0xeb2B79190E10A9CCE69f203B3db6aFC33A4237d0
Balance
0 ETH
Nonce
1
Code Size
11610 bytes
Creator
0xC58EDAba...f13d at tx 0xeb35fdff...621201
Indexed Transactions
0
Contract Bytecode
11610 bytes
0x608060405260043610610236575f3560e01c80638da5cb5b11610129578063b6337a75116100a8578063d21cacdf1161006d578063d21cacdf14610778578063d5a91ffd146107ac578063db2e21bc146107bf578063f2fde38b146107d3578063f7ff5f8e146107f2575f80fd5b8063b6337a75146106d3578063b657b77d146106e8578063c00c635914610707578063c621f94c1461073a578063c9df37c214610759575f80fd5b8063a8602fea116100ee578063a8602fea14610610578063aa2c74f61461062f578063ad4149611461064e578063b3df39211461066d578063b4ce1b9d1461068c575f80fd5b80638da5cb5b1461057c57806394b9cbb21461059e578063977fa6a0146105bd5780639aadeb91146105dc578063a57ffde2146105f1575f80fd5b806353c7cf9a116101b557806370f6a3031161017a57806370f6a303146104b4578063715018a6146104c95780637479954d146104dd5780638456cb591461051a578063845ddcb21461052e575f80fd5b806353c7cf9a1461043357806358faaccc146104485780635bf5d54c146104675780635c975abb1461047c5780636fcc26291461049f575f80fd5b806335cb2a50116101fb57806335cb2a501461038b57806338c67b73146103aa5780633f4ba83a146103c95780634626402b146103dd578063485f16ee14610414575f80fd5b8063039af9eb1461029e5780630cee1725146102df578063186ba7f1146102fe5780631afbba4a146103495780633308f59014610368575f80fd5b3661029a57610243610811565b6003546005541061026f5760405162461bcd60e51b815260040161026690612a2d565b60405180910390fd5b5f341161028e5760405162461bcd60e51b815260040161026690612a54565b610298335f610859565b005b5f80fd5b3480156102a9575f80fd5b506102bd6102b8366004612a7c565b6110c3565b6040805193845260208401929092521515908201526060015b60405180910390f35b3480156102ea575f80fd5b506102986102f9366004612a7c565b6110f7565b348015610309575f80fd5b506103126111a8565b604080519788526020880196909652948601939093526060850191909152608084015260a0830152151560c082015260e0016102d6565b348015610354575f80fd5b50610298610363366004612a93565b611236565b348015610373575f80fd5b5061037d600b5481565b6040519081526020016102d6565b348015610396575f80fd5b506102986103a5366004612a93565b6112ed565b3480156103b5575f80fd5b506102986103c4366004612a7c565b6113b7565b3480156103d4575f80fd5b5061029861141c565b3480156103e8575f80fd5b506002546103fc906001600160a01b031681565b6040516001600160a01b0390911681526020016102d6565b34801561041f575f80fd5b5061029861042e366004612a7c565b61142c565b34801561043e575f80fd5b5061037d600d5481565b348015610453575f80fd5b50610298610462366004612a93565b6114de565b348015610472575f80fd5b5061037d60055481565b348015610487575f80fd5b5060015460ff165b60405190151581526020016102d6565b3480156104aa575f80fd5b5061037d600c5481565b3480156104bf575f80fd5b5061037d60085481565b3480156104d4575f80fd5b506102986115b3565b3480156104e8575f80fd5b506102bd6104f7366004612ac7565b60096020525f908152604090208054600182015460029092015490919060ff1683565b348015610525575f80fd5b506102986115c4565b348015610539575f80fd5b5061054d610548366004612a7c565b6115d4565b6040805196875260208701959095529385019290925260608401526080830152151560a082015260c0016102d6565b348015610587575f80fd5b5060015461010090046001600160a01b03166103fc565b3480156105a9575f80fd5b506102986105b8366004612a7c565b61161b565b3480156105c8575f80fd5b506102986105d7366004612a7c565b611817565b3480156105e7575f80fd5b5061037d60075481565b3480156105fc575f80fd5b5061029861060b366004612a93565b6118a3565b34801561061b575f80fd5b5061029861062a366004612ac7565b61196c565b34801561063a575f80fd5b50610298610649366004612a93565b611a05565b348015610659575f80fd5b50610298610668366004612a7c565b611ab0565b348015610678575f80fd5b50610298610687366004612aef565b611b3c565b348015610697575f80fd5b506102bd6106a6366004612ac7565b6001600160a01b03165f90815260096020526040902080546001820154600290920154909260ff90911690565b3480156106de575f80fd5b5061037d60065481565b3480156106f3575f80fd5b5061048f610702366004612b4a565b611d66565b348015610712575f80fd5b506103fc7f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b281565b348015610745575f80fd5b50610298610754366004612b74565b611d96565b348015610764575f80fd5b50610298610773366004612a7c565b611f40565b348015610783575f80fd5b506103fc610792366004612ac7565b600a6020525f90815260409020546001600160a01b031681565b6102986107ba366004612ac7565b611ffb565b3480156107ca575f80fd5b50610298612044565b3480156107de575f80fd5b506102986107ed366004612ac7565b612280565b3480156107fd575f80fd5b5061029861080c366004612bb2565b6122ba565b60015460ff16156108575760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610266565b565b5f34116108785760405162461bcd60e51b815260040161026690612a54565b5f60036005548154811061088e5761088e612be8565b905f5260205f20906006020190505f8160010154116108e55760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420737461676520707269636560681b6044820152606401610266565b60018101545f906109089061090234670de0b6b3a76400006124da565b906124ec565b825460048401549192509061091d90836124f7565b11156109625760405162461bcd60e51b8152602060048201526014602482015273115e18d959591cc81cdd1859d9481d185c99d95d60621b6044820152606401610266565b6001600160a01b0383161580159061098c5750836001600160a01b0316836001600160a01b031614155b15610ddc57825b6001600160a01b03811615610a2257846001600160a01b0316816001600160a01b031603610a035760405162461bcd60e51b815260206004820152601a60248201527f43697263756c617220726566657272616c2064657465637465640000000000006044820152606401610266565b6001600160a01b039081165f908152600a602052604090205416610993565b6001600160a01b038581165f908152600a6020908152604080832080546001600160a01b031916948916948517905592825260099052208054610a6590846124f7565b815560038401545f90610a80906064906109029034906124da565b90505f610a9f60646109028860020154886124da90919063ffffffff16565b90508115610b58575f876001600160a01b0316836040515f6040518083038185875af1925050503d805f8114610af0576040519150601f19603f3d011682016040523d82523d5f602084013e610af5565b606091505b5050905080610b465760405162461bcd60e51b815260206004820152601c60248201527f45544820726566657272616c207472616e73666572206661696c6564000000006044820152606401610266565b600854610b5390846124f7565b600855505b8015610d8a57807f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b031663dd62ed3e610ba66001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152306024820152604401602060405180830381865afa158015610bee573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c129190612bfc565b1015610c705760405162461bcd60e51b815260206004820152602760248201527f496e73756666696369656e742045434d20616c6c6f77616e636520666f7220726044820152661959995c9c985b60ca1b6064820152608401610266565b7f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b03166323b872dd610cb76001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b039182166004820152908a166024820152604481018490526064016020604051808303815f875af1158015610d09573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d2d9190612c13565b610d795760405162461bcd60e51b815260206004820152601c60248201527f45434d20726566657272616c207472616e73666572206661696c6564000000006044820152606401610266565b600754610d8690826124f7565b6007555b60408051828152602081018490526001600160a01b038916917f223bc761924b82019859b3c71e1c78f40793a5e7c75da256804af926bd086c8d910160405180910390a2610dd787612502565b505050505b807f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b031663dd62ed3e610e246001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152306024820152604401602060405180830381865afa158015610e6c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e909190612bfc565b1015610eee5760405162461bcd60e51b815260206004820152602760248201527f496e73756666696369656e742045434d20616c6c6f77616e636520666f7220706044820152667572636861736560c81b6064820152608401610266565b7f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b03166323b872dd610f356001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b0391821660048201529087166024820152604481018490526064016020604051808303815f875af1158015610f87573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fab9190612c13565b610fed5760405162461bcd60e51b81526020600482015260136024820152721150d3481d1c985b9cd9995c8819985a5b1959606a1b6044820152606401610266565b6004820154610ffc90826124f7565b600483015560065461100e90826124f7565b6006556005546040516001600160a01b038616917ffaa658fc95efb378bd46bbc87236a1a3432fb3a400f7cd686c8ced2d615d69c49161105691858252602082015260400190565b60405180910390a281546004830154106110bd576005808301805460ff19166001179055546040517fff2322ca5cc0de99e86dcca47216acc9431131b0653f58418006395c7d33fc3e916110ad9190815260200190565b60405180910390a16110bd612666565b50505050565b600481815481106110d2575f80fd5b5f91825260209091206003909102018054600182015460029092015490925060ff1683565b6110ff6126c2565b5f8111801561110e5750478111155b61112a5760405162461bcd60e51b815260040161026690612a54565b6002546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015611161573d5f803e3d5ffd5b506002546040518281526001600160a01b03909116907feaff4b37086828766ad3268786972c0cd24259d4c87a80f9d3963a3c3d999b0d906020015b60405180910390a250565b5f805f805f805f600380549050600554106111d55760405162461bcd60e51b815260040161026690612a2d565b5f6003600554815481106111eb576111eb612be8565b5f9182526020909120600580546006909302909101805460018201546002830154600384015460048501549490950154959e929d50909b509950919750955060ff9091169350915050565b61123e6126c2565b600354821061125f5760405162461bcd60e51b815260040161026690612c2e565b60648111156112805760405162461bcd60e51b815260040161026690612c5b565b806003838154811061129457611294612be8565b905f5260205f209060060201600301819055507f43937716422242d4891fa151318cde122c74796ca913fbe09be62ad34919f6d882826040516112e1929190918252602082015260400190565b60405180910390a15050565b6112f56126c2565b60035482106113165760405162461bcd60e51b815260040161026690612c2e565b5f6003838154811061132a5761132a612be8565b905f5260205f20906006020190505f82116113775760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610266565b600181018290556040518381527f34cf54504fd39ab670a54acbb37f686c5bd25e6eedfa39889cba899d360bc7d9906020015b60405180910390a1505050565b6113bf6126c2565b60035481106113e05760405162461bcd60e51b815260040161026690612c2e565b60058190556040518181527fbd102993c090f400138a05c1b5b0c9eadb8d94399c432f6522fab9cf26bd180b906020015b60405180910390a150565b6114246126c2565b6108576126f5565b6114346126c2565b5f81118015611444575060648111155b6114a95760405162461bcd60e51b815260206004820152603060248201527f54696572207265776172642070657263656e74616765206d757374206265206260448201526f065747765656e203120616e64203130360841b6064820152608401610266565b600b8190556040518181527fad520d6b522936202edf235d806a6d1f4d488454ec05537332c0f2f3c278f63d90602001611411565b6114e66126c2565b60035482106115075760405162461bcd60e51b815260040161026690612c2e565b5f6003838154811061151b5761151b612be8565b905f5260205f2090600602019050805f015482111561157c5760405162461bcd60e51b815260206004820181905260248201527f536f6c6420616d6f756e742065786365656473207374616765207461726765746044820152606401610266565b600481018290556040518381527f34cf54504fd39ab670a54acbb37f686c5bd25e6eedfa39889cba899d360bc7d9906020016113aa565b6115bb6126c2565b6108575f612747565b6115cc6126c2565b6108576127a0565b600381815481106115e3575f80fd5b5f9182526020909120600690910201805460018201546002830154600384015460048501546005909501549395509193909260ff1686565b6116236126c2565b5f811180156116b757506040516370a0823160e01b81523060048201527f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b0316906370a0823190602401602060405180830381865afa15801561168f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116b39190612bfc565b8111155b6116d35760405162461bcd60e51b815260040161026690612a54565b7f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b031663a9059cbb61171a6001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303815f875af1158015611764573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117889190612c13565b6117cc5760405162461bcd60e51b8152602060048201526015602482015274151bdad95b881d1c985b9cd9995c8819985a5b1959605a1b6044820152606401610266565b60015461010090046001600160a01b03166001600160a01b03167f6352c5382c4a4578e712449ca65e83cdb392d045dfcf1cad9615189db2da244b8260405161119d91815260200190565b61181f6126c2565b5f811161186e5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206d696e2073616c657320766f6c756d6500000000000000006044820152606401610266565b600d8190556040518181527fdf7068877f04c0671f6f054f399ff20ea54f09b1567f1066c814c6e924f5480a90602001611411565b6118ab6126c2565b60035482106118cc5760405162461bcd60e51b815260040161026690612c2e565b5f600383815481106118e0576118e0612be8565b905f5260205f2090600602019050806004015482116119395760405162461bcd60e51b8152602060048201526015602482015274125b9d985b1a59081d185c99d95d08185b5bdd5b9d605a1b6044820152606401610266565b8181556040518381527f34cf54504fd39ab670a54acbb37f686c5bd25e6eedfa39889cba899d360bc7d9906020016113aa565b6119746126c2565b6001600160a01b0381166119bc5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b6044820152606401610266565b600280546001600160a01b0319166001600160a01b0383169081179091556040517f97c79b3848e51f57983ac89e4403452655c8d83ceba8199011de63a74f60d1a7905f90a250565b611a0d6126c2565b6003548210611a2e5760405162461bcd60e51b815260040161026690612c2e565b6064811115611a4f5760405162461bcd60e51b815260040161026690612c5b565b8060038381548110611a6357611a63612be8565b905f5260205f209060060201600201819055507fb1bcc603bd35fecfd5626aab646279995fcbccdf1e2402ff8bf79bdd59ab909582826040516112e1929190918252602082015260400190565b611ab86126c2565b5f8111611b075760405162461bcd60e51b815260206004820152601a60248201527f496e76616c6964206d696e20686f6c64696e6720616d6f756e740000000000006044820152606401610266565b600c8190556040518181527f1b33453265eac30bc116ff626a920d582882586cd6d733055c22e77e4913b29490602001611411565b611b446126c2565b6001600160a01b038516611b915760405162461bcd60e51b8152602060048201526014602482015273496e76616c69642075736572206164647265737360601b6044820152606401610266565b5f8311611bf55760405162461bcd60e51b815260206004820152602c60248201527f546f74616c2073616c657320766f6c756d65206d75737420626520677265617460448201526b6572207468616e207a65726f60a01b6064820152608401610266565b6001600160a01b0385165f9081526009602052604090206002015460ff1615611c605760405162461bcd60e51b815260206004820152601960248201527f416666696c6961746f7220616c726561647920657869737473000000000000006044820152606401610266565b6001600160a01b03841615611d2f57835b6001600160a01b03811615611d0057856001600160a01b0316816001600160a01b031603611ce15760405162461bcd60e51b815260206004820152601a60248201527f43697263756c617220726566657272616c2064657465637465640000000000006044820152606401610266565b6001600160a01b039081165f908152600a602052604090205416611c71565b506001600160a01b038581165f908152600a6020526040902080546001600160a01b0319169186169190911790555b6001600160a01b03949094165f9081526009602052604090209182556001820155600201805460ff19169215159290921790915550565b6001600160a01b0382165f90815260096020908152604080832084845260030190915290205460ff165b92915050565b611d9e6126c2565b6004548410611dde5760405162461bcd60e51b815260206004820152600c60248201526b24b73b30b634b2103a34b2b960a11b6044820152606401610266565b5f8311611e2d5760405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420726571756972656420616666696c6961746f7273000000006044820152606401610266565b5f8211611e765760405162461bcd60e51b8152602060048201526017602482015276496e76616c6964206e657720616666696c6961746f727360481b6044820152606401610266565b8260048581548110611e8a57611e8a612be8565b905f5260205f2090600302015f01819055508160048581548110611eb057611eb0612be8565b905f5260205f209060030201600101819055508060048581548110611ed757611ed7612be8565b5f91825260209182902060039190910201600201805460ff1916921515929092179091556040805186815291820185905281018390527f2702951ec468d8fb7c1501e01af87b4bd50cda65a20463fc38ee59b954a777b09060600160405180910390a150505050565b611f486126c2565b6003548110611f695760405162461bcd60e51b815260040161026690612c2e565b5f60038281548110611f7d57611f7d612be8565b5f91825260209182902060069091020160058101805460ff81161560ff199091161790556040518481529092507fff2322ca5cc0de99e86dcca47216acc9431131b0653f58418006395c7d33fc3e910160405180910390a1600581015460ff168015611fea575060055482145b15611ff757611ff7612666565b5050565b612003610811565b61200b6127db565b6003546005541061202e5760405162461bcd60e51b815260040161026690612a2d565b6120383382610859565b61204160015f55565b50565b61204c6126c2565b60015460ff1661209e5760405162461bcd60e51b815260206004820152601760248201527f436f6e7472616374206d757374206265207061757365640000000000000000006044820152606401610266565b6002546001600160a01b03166120f65760405162461bcd60e51b815260206004820152601760248201527f54726561737572792077616c6c6574206e6f74207365740000000000000000006044820152606401610266565b478015612136576002546040516001600160a01b039091169082156108fc029083905f818181858888f19350505050158015612134573d5f803e3d5ffd5b505b6040516370a0823160e01b81523060048201525f907f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b0316906370a0823190602401602060405180830381865afa15801561219a573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121be9190612bfc565b90508015611ff7577f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b26001600160a01b031663a9059cbb61220d6001546001600160a01b036101009091041690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303815f875af1158015612257573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061227b9190612c13565b505050565b6122886126c2565b6001600160a01b0381166122b157604051631e4fbdf760e01b81525f6004820152602401610266565b61204181612747565b6122c26126c2565b5f83116123115760405162461bcd60e51b815260206004820152601c60248201527f496e76616c696420726571756972656420616666696c6961746f7273000000006044820152606401610266565b5f821161235a5760405162461bcd60e51b8152602060048201526017602482015276496e76616c6964206e657720616666696c6961746f727360481b6044820152606401610266565b600454156123df576004805461237290600190612cb0565b8154811061238257612382612be8565b905f5260205f2090600302015f015483116123df5760405162461bcd60e51b815260206004820152601d60248201527f4d75737420626520686967686572207468616e206c61737420746965720000006044820152606401610266565b604080516060810182528481526020810184815283151592820192835260048054600180820183555f83905293517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b60039092029182015591517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c83015592517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d909101805460ff191691151591909117905590547f2702951ec468d8fb7c1501e01af87b4bd50cda65a20463fc38ee59b954a777b0916124bf91612cb0565b604080519182526020820186905281018490526060016113aa565b5f6124e58284612cc3565b9392505050565b5f6124e58284612cda565b5f6124e58284612cf9565b6001600160a01b0381165f908152600960205260409020600281015460ff161580156125315750600d54815410155b80156125c65750600c546040516370a0823160e01b81526001600160a01b0384811660048301527f0000000000000000000000006f9c25edc02f21e9df8050a3e67947c99b88f0b216906370a0823190602401602060405180830381865afa15801561259f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125c39190612bfc565b10155b15611ff75760028101805460ff191660011790556001600160a01b038083165f908152600a602052604090205416801561262e576001600160a01b0381165f90815260096020526040812060010180549161262083612d0c565b919050555061262e81612832565b6040516001600160a01b038416907febc403d20d792ad9895aa2f13e051113300890094cbb9010c495e25f3ba7dfb5905f90a2505050565b5f60055460016126769190612cf9565b90505b6003548110156126b9575f6003828154811061269757612697612be8565b905f5260205f2090600602015f015411156126b157600555565b600101612679565b50600354600555565b6001546001600160a01b036101009091041633146108575760405163118cdaa760e01b8152336004820152602401610266565b6126fd6129e4565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600180546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6127a8610811565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2583361272a565b60025f540361282c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610266565b60025f55565b6001600160a01b0381165f908152600960205260408120905b60045481101561227b575f81815260038301602052604090205460ff168061289957506004818154811061288157612881612be8565b5f91825260209091206002600390920201015460ff16155b6129dc57600481815481106128b0576128b0612be8565b905f5260205f2090600302015f01548260010154106129dc575f612946670de0b6b3a764000061090260646109026003600554815481106128f3576128f3612be8565b905f5260205f20906006020160010154612940600b5461294060048b8154811061291f5761291f612be8565b905f5260205f20906003020160010154600d546124da90919063ffffffff16565b906124da565b5f838152600385016020526040808220805460ff19166001179055519192506001600160a01b0386169183156108fc0291849190818181858888f19350505050158015612995573d5f803e3d5ffd5b5060408051838152602081018390526001600160a01b038616917fe6e098e8b9f9c15186066cc2d484102a04be48cbc8bf1511fb0b8f4c6fff987b910160405180910390a2505b60010161284b565b60015460ff166108575760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610266565b6020808252600d908201526c1250d3c81a185cc8195b991959609a1b604082015260600190565b6020808252600e908201526d125b9d985b1a5908185b5bdd5b9d60921b604082015260600190565b5f60208284031215612a8c575f80fd5b5035919050565b5f8060408385031215612aa4575f80fd5b50508035926020909101359150565b6001600160a01b0381168114612041575f80fd5b5f60208284031215612ad7575f80fd5b81356124e581612ab3565b8015158114612041575f80fd5b5f805f805f60a08688031215612b03575f80fd5b8535612b0e81612ab3565b94506020860135612b1e81612ab3565b935060408601359250606086013591506080860135612b3c81612ae2565b809150509295509295909350565b5f8060408385031215612b5b575f80fd5b8235612b6681612ab3565b946020939093013593505050565b5f805f8060808587031215612b87575f80fd5b8435935060208501359250604085013591506060850135612ba781612ae2565b939692955090935050565b5f805f60608486031215612bc4575f80fd5b83359250602084013591506040840135612bdd81612ae2565b809150509250925092565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215612c0c575f80fd5b5051919050565b5f60208284031215612c23575f80fd5b81516124e581612ae2565b602080825260139082015272092dcecc2d8d2c840e6e8c2ceca40d2dcc8caf606b1b604082015260600190565b60208082526021908201527f426f6e7573206d757374206265206265747765656e20302520616e64203130306040820152602560f81b606082015260800190565b634e487b7160e01b5f52601160045260245ffd5b81810381811115611d9057611d90612c9c565b8082028115828204841417611d9057611d90612c9c565b5f82612cf457634e487b7160e01b5f52601260045260245ffd5b500490565b80820180821115611d9057611d90612c9c565b5f60018201612d1d57612d1d612c9c565b506001019056fea264697066735822122053ff362b469b75b70b2e8f4b5136e10e583c0d410fb3726639d74dc295635eba64736f6c634300081a0033
Verified Source Code Partial Match
Compiler: v0.8.26+commit.8a97fa7a
EVM: cancun
Optimization: Yes (200 runs)
ECMICOV3.sol 1265 lines
// SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
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);
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// 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;
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/security/Pausable.sol
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
/**
* @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);
}
}
// File: @openzeppelin/contracts/utils/math/SafeMath.sol
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// File: contracts/ECM-Coin/ECMICOV3.sol
pragma solidity ^0.8.26;
/**
* @title ECM Token ICO Sale Contract with Affiliate System
* @notice Manages ICO stages and affiliate rewards
* @dev Implements multi-stage ICO with referral and tier-based rewards
*/
contract ECMICOV3 is ReentrancyGuard, Pausable, Ownable(msg.sender) {
using SafeMath for uint256;
/// @notice ECM token contract interface
IERC20 public immutable ecmCoin;
/// @notice Wallet to receive treasury funds
address payable public treasuryWallet;
/// @notice Structure for each ICO stage
struct Stage {
uint256 target; // Total ECM tokens available in this stage
uint256 price; // Price per ECM in ETH
uint256 ecmRefBonus; // Referral bonus in ECM (percentage)
uint256 ethRefBonus; // Referral bonus in ETH (percentage)
uint256 ecmSold; // Amount of ECM sold in this stage
bool isCompleted; // Whether stage is completed
}
/// @notice Structure to track affiliate information
struct AffiliatorInfo {
uint256 totalSalesVolume; // Total ECM sales through referrals
uint256 affiliatorCount; // Number of affiliators in network
bool isAffiliator; // Affiliator status
mapping(uint256 => bool) tiersClaimed; // Track claimed tier rewards
}
/// @notice Structure for affiliate tier information
struct TierInfo {
uint256 requiredAffiliators; // Number of affiliators needed
uint256 newAffiliators; // New affiliators since last tier
bool isActive; // If tier is active
}
Stage[] public stages;
TierInfo[] public tiers;
uint256 public currentStage;
uint256 public totalEcmSold;
uint256 public totalECMReferralDistributed;
uint256 public totalETHReferralDistributed;
mapping(address => AffiliatorInfo) public affiliators;
mapping(address => address) public referrerOf;
uint256 public tierRewardPercentage = 2; // Default 2%
uint256 public minECMHolding = 300 * 1e18; // 300 ECM initial value
uint256 public minSalesVolume = 2500 * 1e18; // 2500 ECM initial value
// Events
event ECMPurchased(address indexed buyer, uint256 amount, uint256 stage);
event ReferralRewardPaid(address indexed referrer, uint256 ecmAmount, uint256 ethAmount);
event TreasuryWalletUpdated(address indexed newWallet);
event TokensWithdrawn(address indexed to, uint256 amount);
event FundsWithdrawn(address indexed to, uint256 amount);
event StageCompleted(uint256 stageIndex);
event StageUpdated(uint256 stageIndex);
event CurrentStageUpdated(uint256 newStage);
event StageRefEcmBonusUpdated(uint256 stageIndex, uint256 newRefBonus);
event StageRefEthBonusUpdated(uint256 stageIndex, uint256 newRefBonus);
event MinECMHoldingUpdated(uint256 newAmount);
event MinSalesVolumeUpdated(uint256 newAmount);
event AffiliatorQualified(address indexed user);
event TierRewardPercentageUpdated(uint256 newPercentage);
event TierRewardClaimed(address indexed affiliator, uint256 tierIndex, uint256 ethAmount);
event TierUpdated(uint256 tierIndex, uint256 requiredAffiliators, uint256 newAffiliators);
/**
* @notice Contract constructor to initialize the ICO stages, tiers, and treasury wallet.
* @param _ecmCoin Address of the ECM token contract.
* Initializes:
* - ICO stages with predefined targets, prices, and referral bonuses.
* - Affiliate tiers with required affiliators and rewards.
* - Treasury wallet as the contract owner.
*/
constructor(address _ecmCoin) {
require(_ecmCoin != address(0), "Invalid token address");
ecmCoin = IERC20(_ecmCoin);
treasuryWallet = payable(owner());
stages.push(Stage(200000 * 1e18, 0.00040 ether, 2, 3, 0, false));
stages.push(Stage(200000 * 1e18, 0.00041 ether, 2, 3, 0, false));
stages.push(Stage(200000 * 1e18, 0.00042 ether, 2, 3, 0, false));
stages.push(Stage(100000 * 1e18, 0.00043 ether, 2, 3, 0, false));
stages.push(Stage(100000 * 1e18, 0.00044 ether, 2, 3, 0, false));
stages.push(Stage(50000 * 1e18, 0.00045 ether, 2, 3, 0, false));
stages.push(Stage(50000 * 1e18, 0.00046 ether, 2, 3, 0, false));
stages.push(Stage(50000 * 1e18, 0.00047 ether, 2, 3, 0, false));
stages.push(Stage(50000 * 1e18, 0.00048 ether, 2, 3, 0, false));
tiers.push(TierInfo(3, 3, true));
tiers.push(TierInfo(7, 4, true));
tiers.push(TierInfo(12, 5, true));
tiers.push(TierInfo(20, 8, true));
tiers.push(TierInfo(30, 10, true));
tiers.push(TierInfo(50, 20, true));
}
/**
* @dev Fallback function to receive ETH and purchase ECM tokens.
* Automatically triggers a purchase for the sender with no referrer.
* Requirements:
* - The contract must not be paused.
* - The ICO must not have ended.
* - The sent ETH amount must be greater than zero.
*/
receive() external payable whenNotPaused {
require(currentStage < stages.length, "ICO has ended");
require(msg.value > 0, "Invalid amount");
_buyECM(msg.sender, address(0));
}
/**
* @dev Purchase ECM tokens with an optional referrer.
*/
function buyECM(address referrer) external payable whenNotPaused nonReentrant {
require(currentStage < stages.length, "ICO has ended");
_buyECM(msg.sender, referrer);
}
/**
* @dev Internal function to handle ECM token purchases with referral logic.
*/
function _buyECM(address buyer, address referrer) internal {
require(msg.value > 0, "Invalid amount");
Stage storage stage = stages[currentStage];
require(stage.price > 0, "Invalid stage price");
// Calculate ECM tokens to buy using SafeMath
uint256 ecmToBuy = msg.value.mul(1e18).div(stage.price);
require(stage.ecmSold.add(ecmToBuy) <= stage.target, "Exceeds stage target");
// Circular referral prevention
if (referrer != address(0) && referrer != buyer) {
address currentReferrer = referrer;
while (currentReferrer != address(0)) {
require(currentReferrer != buyer, "Circular referral detected");
currentReferrer = referrerOf[currentReferrer];
}
// Assign the referrer only after validating circular referral
referrerOf[buyer] = referrer;
// Update referrer's affiliate sales volume
AffiliatorInfo storage refInfo = affiliators[referrer];
refInfo.totalSalesVolume = refInfo.totalSalesVolume.add(ecmToBuy);
// Calculate referral bonuses using SafeMath
uint256 ethReferralAmount = msg.value.mul(stage.ethRefBonus).div(100);
uint256 ecmReferralAmount = ecmToBuy.mul(stage.ecmRefBonus).div(100);
// Distribute ETH referral bonus
if (ethReferralAmount > 0) {
(bool success, ) = payable(referrer).call{value: ethReferralAmount}("");
require(success, "ETH referral transfer failed");
totalETHReferralDistributed = totalETHReferralDistributed.add(ethReferralAmount);
}
// Distribute ECM referral bonus
if (ecmReferralAmount > 0) {
require(ecmCoin.allowance(owner(), address(this)) >= ecmReferralAmount, "Insufficient ECM allowance for referral");
require(ecmCoin.transferFrom(owner(), referrer, ecmReferralAmount), "ECM referral transfer failed");
totalECMReferralDistributed = totalECMReferralDistributed.add(ecmReferralAmount);
}
emit ReferralRewardPaid(referrer, ecmReferralAmount, ethReferralAmount);
_checkAndUpdateAffiliatorStatus(referrer);
}
// Transfer ECM to the buyer
require(ecmCoin.allowance(owner(), address(this)) >= ecmToBuy, "Insufficient ECM allowance for purchase");
require(ecmCoin.transferFrom(owner(), buyer, ecmToBuy), "ECM transfer failed");
// Update stage and total sales using SafeMath
stage.ecmSold = stage.ecmSold.add(ecmToBuy);
totalEcmSold = totalEcmSold.add(ecmToBuy);
emit ECMPurchased(buyer, ecmToBuy, currentStage);
// Check if the stage is completed
if (stage.ecmSold >= stage.target) {
stage.isCompleted = true;
emit StageCompleted(currentStage);
progressToNextStage();
}
}
/**
* @dev Qualifies a user as an affiliator if they meet requirements, updating referrer stats.
* @param user The address to check.
*/
function _checkAndUpdateAffiliatorStatus(address user) internal {
AffiliatorInfo storage info = affiliators[user];
if (!info.isAffiliator &&
info.totalSalesVolume >= minSalesVolume &&
ecmCoin.balanceOf(user) >= minECMHolding) {
info.isAffiliator = true;
// Update referrer's affiliator count if exists
address referrer = referrerOf[user];
if (referrer != address(0)) {
affiliators[referrer].affiliatorCount++;
_checkTierRewards(referrer);
}
emit AffiliatorQualified(user);
}
}
/**
* @dev Checks and distributes unclaimed tier rewards for a qualified affiliator.
* @param affiliator The address of the affiliator to check.
*/
function _checkTierRewards(address affiliator) internal {
AffiliatorInfo storage info = affiliators[affiliator];
for (uint256 i = 0; i < tiers.length; i++) {
if (info.tiersClaimed[i] || !tiers[i].isActive) continue;
if (info.affiliatorCount >= tiers[i].requiredAffiliators){
uint256 ethReward = minSalesVolume
.mul(tiers[i].newAffiliators)
.mul(tierRewardPercentage)
.mul(stages[currentStage].price)
.div(100)
.div(1e18);
info.tiersClaimed[i] = true;
payable(affiliator).transfer(ethReward);
emit TierRewardClaimed(affiliator, i, ethReward);
}
}
}
/**
* @dev Advances to the next stage with a valid (non-zero) target.
* If no valid stage is found, marks the ICO as completed.
*/
function progressToNextStage() internal {
for (uint256 i = currentStage + 1; i < stages.length; i++) {
if (stages[i].target > 0) {
currentStage = i;
return;
}
}
currentStage = stages.length; // Mark ICO as completed
}
/** ======= Start Stage Management ====== */
/**
* @dev Sets the current stage index.
* Can only be called by the owner.
* @param newStage The index of the new current stage.
*/
function setCurrentStage(uint256 newStage) external onlyOwner {
require(newStage < stages.length, "Invalid stage index");
currentStage = newStage;
emit CurrentStageUpdated(newStage);
}
/**
* @dev Returns details of the current stage.
* @return stageIndex The current stage.
* @return target The target tokens for the stage.
* @return price The price per token in ETH.
* @return ecmRefBonus ECM referral bonus (percentage).
* @return ethRefBonus ETH referral bonus (percentage).
* @return ecmSold ECM tokens sold in the stage.
* @return isCompleted Whether the stage is completed.
*/
function currentStageInfo() external view returns (
uint256 stageIndex,
uint256 target,
uint256 price,
uint256 ecmRefBonus,
uint256 ethRefBonus,
uint256 ecmSold,
bool isCompleted
) {
require(currentStage < stages.length, "ICO has ended");
Stage storage stage = stages[currentStage];
return (
currentStage,
stage.target,
stage.price,
stage.ecmRefBonus,
stage.ethRefBonus,
stage.ecmSold,
stage.isCompleted
);
}
/**
* @dev Updates the target tokens for a specific stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to update.
* @param target The new target token amount.
*/
function updateStageTarget(uint256 stageIndex, uint256 target) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
Stage storage stage = stages[stageIndex];
require(target > stage.ecmSold, "Invalid target amount");
stage.target = target;
emit StageUpdated(stageIndex);
}
/**
* @dev Updates the amount of ECM tokens sold in a specific stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to update.
* @param soldAmount The new amount of ECM tokens sold.
* Requirements:
* - The stage index must be valid.
* - The sold amount must not exceed the stage target.
*/
function updateStageSold(uint256 stageIndex, uint256 soldAmount) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
Stage storage stage = stages[stageIndex];
require(soldAmount <= stage.target, "Sold amount exceeds stage target");
stage.ecmSold = soldAmount;
emit StageUpdated(stageIndex);
}
/**
* @dev Updates the token price for a specific stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to update.
* @param price The new price per token in ETH.
*/
function updateStagePrice(uint256 stageIndex, uint256 price) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
Stage storage stage = stages[stageIndex];
require(price > 0, "Invalid price");
stage.price = price;
emit StageUpdated(stageIndex);
}
/**
* @dev Toggles the completion status of a stage.
* If toggling completes the current stage, progresses to the next valid stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to toggle.
*/
function toggleCompleteStage(uint256 stageIndex) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
Stage storage stage = stages[stageIndex];
stage.isCompleted = !stage.isCompleted;
emit StageCompleted(stageIndex);
if (stage.isCompleted && stageIndex == currentStage) {
progressToNextStage();
}
}
/**
* @dev Updates the ECM referral bonus for a specific stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to update.
* @param newRefBonus The new referral bonus in percentage.
*/
function updateStageEcmRefBonus(uint256 stageIndex, uint256 newRefBonus) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
require(newRefBonus >= 0 && newRefBonus <= 100, "Bonus must be between 0% and 100%");
stages[stageIndex].ecmRefBonus = newRefBonus;
emit StageRefEcmBonusUpdated(stageIndex, newRefBonus);
}
/**
* @dev Updates the ETH referral bonus for a specific stage.
* Can only be called by the owner.
* @param stageIndex The index of the stage to update.
* @param newRefBonus The new referral bonus in percentage.
*/
function updateStageEthRefBonus(uint256 stageIndex, uint256 newRefBonus) external onlyOwner {
require(stageIndex < stages.length, "Invalid stage index");
require(newRefBonus >= 0 && newRefBonus <= 100, "Bonus must be between 0% and 100%");
stages[stageIndex].ethRefBonus = newRefBonus;
emit StageRefEthBonusUpdated(stageIndex, newRefBonus);
}
/** ======= End Stage Management ====== */
/** ======= Start Tier Management ====== */
/**
* @dev Adds a new affiliate tier with specified requirements and status.
* @param requiredAffiliators The number of affiliators needed for the tier.
* @param newAffiliators The number of new affiliators since the last tier.
* @param isActive Whether the tier is active.
*/
function addNewTier(
uint256 requiredAffiliators,
uint256 newAffiliators,
bool isActive
) external onlyOwner {
require(requiredAffiliators > 0, "Invalid required affiliators");
require(newAffiliators > 0, "Invalid new affiliators");
if (tiers.length > 0) {
require(
requiredAffiliators > tiers[tiers.length - 1].requiredAffiliators,
"Must be higher than last tier"
);
}
tiers.push(TierInfo(requiredAffiliators, newAffiliators, isActive));
emit TierUpdated(tiers.length - 1, requiredAffiliators, newAffiliators);
}
/**
* @dev Updates an existing affiliate tier's requirements and status.
* @param tierIndex The index of the tier to update.
* @param requiredAffiliators The new number of affiliators needed for the tier.
* @param newAffiliators The new number of affiliators since the last tier.
* @param isActive The new active status of the tier.
*/
function updateTier(
uint256 tierIndex,
uint256 requiredAffiliators,
uint256 newAffiliators,
bool isActive
) external onlyOwner {
require(tierIndex < tiers.length, "Invalid tier");
require(requiredAffiliators > 0, "Invalid required affiliators");
require(newAffiliators > 0, "Invalid new affiliators");
tiers[tierIndex].requiredAffiliators = requiredAffiliators;
tiers[tierIndex].newAffiliators = newAffiliators;
tiers[tierIndex].isActive = isActive;
emit TierUpdated(tierIndex, requiredAffiliators, newAffiliators);
}
/**
* @dev Updates the tier reward percentage for affiliators.
* @param newPercentage The new reward percentage (1 to 100).
*/
function updateTierRewardPercentage(uint256 newPercentage) external onlyOwner {
require(newPercentage > 0 && newPercentage <= 100, "Tier reward percentage must be between 1 and 100");
tierRewardPercentage = newPercentage;
emit TierRewardPercentageUpdated(newPercentage);
}
/**
* @dev Updates the minimum ECM holding required to qualify as an affiliator.
* @param newMinHolding The new minimum ECM token holding.
*/
function updateMinECMHolding(uint256 newMinHolding) external onlyOwner {
require(newMinHolding > 0, "Invalid min holding amount");
minECMHolding = newMinHolding;
emit MinECMHoldingUpdated(newMinHolding);
}
/**
* @dev Updates the minimum sales volume required to qualify as an affiliator.
* @param newMinVolume The new minimum ECM sales volume.
*/
function updateMinSalesVolume(uint256 newMinVolume) external onlyOwner {
require(newMinVolume > 0, "Invalid min sales volume");
minSalesVolume = newMinVolume;
emit MinSalesVolumeUpdated(newMinVolume);
}
/** ======= End Tier Management ====== */
/** ======= Start Affiliadtion Management ====== */
/**
* @dev Returns information about an affiliator.
* @param user The address of the affiliator.
* @return salesVolume Total sales volume through referrals by the user.
* @return affiliatorCount Number of affiliators referred by the user.
* @return isAffiliator Whether the user is an active affiliator.
*/
function getAffiliatorInfo(address user) external view returns (
uint256 salesVolume,
uint256 affiliatorCount,
bool isAffiliator
) {
AffiliatorInfo storage info = affiliators[user];
return (
info.totalSalesVolume,
info.affiliatorCount,
info.isAffiliator
);
}
/**
* @dev Saves affiliator info for migration, ensuring no duplicate or circular referrals.
* @param user The address of the affiliator.
* @param referrer The address of the referrer (if any).
* @param totalSalesVolume Total referral sales volume of the affiliator.
* @param affiliatorCount Number of affiliators referred by the user.
* @param isAffiliator Whether the user qualifies as an affiliator.
*/
function addAffiliatorInfo(
address user,
address referrer,
uint256 totalSalesVolume,
uint256 affiliatorCount,
bool isAffiliator
) external onlyOwner {
require(user != address(0), "Invalid user address");
require(totalSalesVolume > 0, "Total sales volume must be greater than zero");
require(affiliatorCount >= 0, "Affiliator count cannot be negative");
require(!affiliators[user].isAffiliator, "Affiliator already exists");
// Circular referral prevention
if (referrer != address(0)) {
address currentReferrer = referrer;
while (currentReferrer != address(0)) {
require(currentReferrer != user, "Circular referral detected");
currentReferrer = referrerOf[currentReferrer];
}
referrerOf[user] = referrer; // Set the referrer after validation
}
// Save affiliator info
AffiliatorInfo storage info = affiliators[user];
info.totalSalesVolume = totalSalesVolume;
info.affiliatorCount = affiliatorCount;
info.isAffiliator = isAffiliator;
}
/**
* @dev Checks if a specific tier reward has been claimed by a user.
* @param user The address of the affiliator.
* @param tierIndex The ID of the tier to check.
* @return bool True if the tier reward has been claimed, false otherwise.
*/
function isTierClaimed(address user, uint256 tierIndex) external view returns (bool) {
return affiliators[user].tiersClaimed[tierIndex];
}
/** ======= End Affiliadtion Management ====== */
/** ======= Start Withdrawal Management ====== */
/**
* @dev Withdraws a specified amount of ECM tokens to the owner's wallet.
* Can only be called by the owner.
* @param amount The amount of ECM tokens to withdraw.
* Requirements:
* - `amount` must be greater than 0.
* - `amount` must not exceed the contract's ECM token balance.
* Emits a `TokensWithdrawn` event.
*/
function withdrawECM(uint256 amount) external onlyOwner {
require(amount > 0 && amount <= ecmCoin.balanceOf(address(this)), "Invalid amount");
require(ecmCoin.transfer(owner(), amount), "Token transfer failed");
emit TokensWithdrawn(owner(), amount);
}
/**
* @dev Withdraws a specified amount of ETH to the treasury wallet.
* Can only be called by the owner.
* @param amount The amount of ETH to withdraw.
* Requirements:
* - `amount` must be greater than 0.
* - `amount` must not exceed the contract's ETH balance.
* Emits a `FundsWithdrawn` event.
*/
function withdrawFund(uint256 amount) external onlyOwner {
require(amount > 0 && amount <= address(this).balance, "Invalid amount");
treasuryWallet.transfer(amount);
emit FundsWithdrawn(treasuryWallet, amount);
}
/**
* @dev Withdraws all ETH and ECM tokens from the contract in case of an emergency.
* Can only be called by the owner when the contract is paused.
* Transfers ETH to the treasury wallet and ECM tokens to the owner's wallet.
* Requirements:
* - The contract must be paused.
* - The treasury wallet must be set.
*/
function emergencyWithdraw() external onlyOwner {
require(paused(), "Contract must be paused");
require(treasuryWallet != address(0), "Treasury wallet not set");
uint256 balance = address(this).balance;
if (balance > 0) {
treasuryWallet.transfer(balance);
}
uint256 tokenBalance = ecmCoin.balanceOf(address(this));
if (tokenBalance > 0) {
ecmCoin.transfer(owner(), tokenBalance);
}
}
/** ======= End Withdrawal Management ====== */
/** ======= Start Contract Control ====== */
/**
* @dev Sets a new treasury wallet address.
* Can only be called by the owner.
* @param _newWallet The new treasury wallet address.
* Requirements:
* - `_newWallet` must not be the zero address.
* Emits a `TreasuryWalletUpdated` event.
*/
function setTreasuryWallet(address payable _newWallet) external onlyOwner {
require(_newWallet != address(0), "Invalid address");
treasuryWallet = _newWallet;
emit TreasuryWalletUpdated(_newWallet);
}
/**
* @dev Pauses the contract, disabling critical functions.
* Can only be called by the owner.
* Emits a `Paused` event.
*/
function pause() external onlyOwner {
_pause();
}
/**
* @dev Unpauses the contract, re-enabling critical functions.
* Can only be called by the owner.
* Emits an `Unpaused` event.
*/
function unpause() external onlyOwner {
_unpause();
}
/** ======= End Contract Control ====== */
}
Read Contract
affiliators 0x7479954d → uint256, uint256, bool
currentStage 0x5bf5d54c → uint256
currentStageInfo 0x186ba7f1 → uint256, uint256, uint256, uint256, uint256, uint256, bool
ecmCoin 0xc00c6359 → address
getAffiliatorInfo 0xb4ce1b9d → uint256, uint256, bool
isTierClaimed 0xb657b77d → bool
minECMHolding 0x6fcc2629 → uint256
minSalesVolume 0x53c7cf9a → uint256
owner 0x8da5cb5b → address
paused 0x5c975abb → bool
referrerOf 0xd21cacdf → address
stages 0x845ddcb2 → uint256, uint256, uint256, uint256, uint256, bool
tierRewardPercentage 0x3308f590 → uint256
tiers 0x039af9eb → uint256, uint256, bool
totalECMReferralDistributed 0x9aadeb91 → uint256
totalETHReferralDistributed 0x70f6a303 → uint256
totalEcmSold 0xb6337a75 → uint256
treasuryWallet 0x4626402b → address
Write Contract 22 functions
These functions modify contract state and require a wallet transaction to execute.
addAffiliatorInfo 0xb3df3921
address user
address referrer
uint256 totalSalesVolume
uint256 affiliatorCount
bool isAffiliator
addNewTier 0xf7ff5f8e
uint256 requiredAffiliators
uint256 newAffiliators
bool isActive
buyECM 0xd5a91ffd
address referrer
emergencyWithdraw 0xdb2e21bc
No parameters
pause 0x8456cb59
No parameters
renounceOwnership 0x715018a6
No parameters
setCurrentStage 0x38c67b73
uint256 newStage
setTreasuryWallet 0xa8602fea
address _newWallet
toggleCompleteStage 0xc9df37c2
uint256 stageIndex
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
updateMinECMHolding 0xad414961
uint256 newMinHolding
updateMinSalesVolume 0x977fa6a0
uint256 newMinVolume
updateStageEcmRefBonus 0xaa2c74f6
uint256 stageIndex
uint256 newRefBonus
updateStageEthRefBonus 0x1afbba4a
uint256 stageIndex
uint256 newRefBonus
updateStagePrice 0x35cb2a50
uint256 stageIndex
uint256 price
updateStageSold 0x58faaccc
uint256 stageIndex
uint256 soldAmount
updateStageTarget 0xa57ffde2
uint256 stageIndex
uint256 target
updateTier 0xc621f94c
uint256 tierIndex
uint256 requiredAffiliators
uint256 newAffiliators
bool isActive
updateTierRewardPercentage 0x485f16ee
uint256 newPercentage
withdrawECM 0x94b9cbb2
uint256 amount
withdrawFund 0x0cee1725
uint256 amount
Recent Transactions
No transactions found for this address