Найти тему

geth+remix

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

import "hardhat/console.sol";

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

/**

* @title Owner

* @dev Set & change owner

*/

contract Owner {

struct User {

string name;

string password;

uint money_cmon;

uint money_eth;

address[] whitelistPrivate;

}

struct Request {//заявки

string name;

address requester;

}

mapping (address => User) Users;

Request[] public requests;

//time

uint Time_start; //время старта

uint public Time_dif; //времянная разница

uint Time_now; //время сейчас

uint Time_system; //время жизни системы

//main

address public mainOwner;

address public privat_prowaider;

address public public_prowaider;

//my

uint podgotovka;

uint privat;

constructor() {

mainOwner = 0xA44363888c43cd0b7fb37452b24f3Bd74a911d32;

privat_prowaider = 0xeb0C25Ed412B4de82fE1B97F76a460AeB9aeb27E;

public_prowaider = 0x5C22E3FFb2C81EacB7f3230518EB48C12A58c5ff;

address investor1 = 0x43490F04A29eBD4243162F38F143b7ffAC365177;

address investor2 = 0x7550b8B07e37Bc5EA2b658f3e9C9EF1BBfe3237B;

address Best_friends = 0x671268d0159238F2EB24df5a0488a0D36d101B5D;

//need

Time_system =

Time_now =

Time_start = block.timestamp;

Time_dif = 0;

//basa

Users[mainOwner].name = "mainOwner";

Users[mainOwner].password = "1111";

Users[mainOwner].money_cmon = 100000000000000000;

Users[mainOwner].money_eth = 0;

Users[privat_prowaider].name = "privat_prowaider";

Users[privat_prowaider].password = "1111";

Users[privat_prowaider].money_cmon = 100000;

Users[privat_prowaider].money_eth = 75 ether / 10000;

Users[public_prowaider].name = "public_prowaider";

Users[public_prowaider].password = "1111";

Users[public_prowaider].money_cmon = 5000;

Users[public_prowaider].money_eth = 1 ether / 1000;

//Users basa

Users[investor1].name = "investor1";

Users[investor1].password = "1111";

Users[investor1].money_cmon = 300000;

Users[investor1].money_eth = 0;

Users[investor2].name = "investor2";

Users[investor2].password = "1111";

Users[investor2].money_cmon = 400000;

Users[investor2].money_eth = 0;

Users[Best_friends].name = "Best_friends";

Users[Best_friends].password = "1111";

Users[Best_friends].money_cmon = 200000;

Users[Best_friends].money_eth = 0;

//my

podgotovka = 5*60;

privat = 15*60;

}

//заявки

function submitRequestInvestor(string memory _name, address _requester) public {

require(block.timestamp - Time_start <= (Time_dif+5)*60, "Now it's to late." );

requests.push(Request(_name, _requester));

}

//принятие заявки

function addUser(uint id, string memory _password) public {

Users[requests[id].requester].name = requests[id].name;

Users[requests[id].requester].password = _password;

Users[requests[id].requester].money_cmon = 0;

Users[requests[id].requester].money_eth = 0;

}

//пополнение

function addMoney(uint _money, address _address) public {

Users[_address].money_eth = Users[_address].money_eth + _money;

}

//покупка

function buy(uint _money, address _address) public {

require(Users[mainOwner].money_cmon < _money, "cmon have't.");

require(block.timestamp - Time_start <= (Time_dif+5)*60, "you can;t buy token.");

if(block.timestamp - Time_start <= (Time_dif+15)*60 && _money <= Users[privat_prowaider].money_cmon && _address != mainOwner){

uint price = _money*Users[privat_prowaider].money_eth;

require(Users[_address].money_eth < price, "money eth have't.");

//++

Users[_address].money_eth = Users[_address].money_eth - price;

Users[_address].money_cmon = _money;

//--

Users[mainOwner].money_eth = Users[mainOwner].money_eth + _money * Users[privat_prowaider].money_eth;

Users[mainOwner].money_cmon = Users[mainOwner].money_cmon - _money;

}else if(_money <= Users[public_prowaider].money_cmon){

uint price = _money * (75 ether / 10000);

require(Users[_address].money_eth < price, "money eth have't.");

//++

Users[_address].money_eth = Users[_address].money_eth - price;

Users[_address].money_cmon = _money;

//--

Users[mainOwner].money_eth = Users[mainOwner].money_eth + _money * (75 ether / 10000);

Users[mainOwner].money_cmon = Users[mainOwner].money_cmon - _money;

}else{

require(true, "money eth have't.");

}

}

//private whitelist add

function addWhitelistPrivate(address _who, address _address) public {

for (uint i = 0; i < Users[_address].whitelistPrivate.length; i++){

require(Users[_address].whitelistPrivate[i] == _who, "have yet.");

}

Users[_address].whitelistPrivate.push(_who);

}

//private whitelist delete

function deleteWhitelistPrivate(address _who, address _address) public {

for (uint i = 0; i < Users[_address].whitelistPrivate.length; i++){

if(Users[_address].whitelistPrivate[i] == _who){

delete Users[_address].whitelistPrivate[i];

}

}

}

//перевод

function sell(uint _money_cmon, address _who, address _address, bool _gift) public {

require(block.timestamp - Time_start <= (Time_dif+15)*60 && _address != mainOwner, "you can't yet.");

require(Users[_who].money_cmon < _money_cmon, "cmon have't.");

require(bytes(Users[_address].name).length != 0, "addresa have't.");

require(block.timestamp - Time_start <= (Time_dif+5)*60, "please wait.");

uint price = 0;

if(block.timestamp - Time_start <= (Time_dif+15)*60){

price = _money_cmon*Users[privat_prowaider].money_cmon;

}else{

price = _money_cmon*Users[public_prowaider].money_cmon;

}

require(Users[_address].money_eth < price, "addresat have't eth.");

//--

Users[_who].money_cmon = Users[_who].money_cmon - _money_cmon;

//++

Users[_address].money_cmon = Users[_address].money_cmon + _money_cmon;

if(!_gift){

//--

Users[_who].money_eth = Users[_who].money_eth - price;

//++

Users[_address].money_eth = Users[_address].money_eth + price;

}

}

//++time

function addOneMinut() public {

Time_dif = Time_dif + 1;

}

//прошло

function getTimeSinceStart() public view returns (uint) {

return block.timestamp - Time_start;

}

//задержка

function getTimeDif() public view returns (uint) {

return Time_dif;

}

}