Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.24;
- /*
- Реализация смарт контракта по типу 6 кошельков
- */
- contract SixWallets {
- //Адресс владельца
- address public ownerAddress = 0xAd230476dAF40056f90C8B21d8574C665d144411;
- //Количество участников
- uint hexagons = 0;
- bool cfw = false;
- uint256 min = .03 ether;
- mapping(address => bytes32[]) public Addresses; //Адресс => уникальными ссылки
- mapping(bytes32 => address[6]) public Hexagons; //Уникальная ссылка (keccak256) => 6 кошельков
- //Проверяет что сумма перевода достаточна
- modifier enoughMoney() {
- require (msg.value >= min, "Insufficient funds");
- _;
- }
- //Проверяет что тот кто перевел владелец кошелька
- modifier onlyOwner {
- require (msg.sender == ownerAddress, "Olny owner");
- _;
- }
- modifier allreadyCreate {
- require (cfw == false);
- _;
- }
- //Функция для оплаты
- function pay(bytes32 ref) public payable {
- //Перевожу деньги
- for(uint8 i = 0; i < 6; i++)
- Hexagons[ref][i].transfer(msg.value/6);
- createHexagons(ref); //Передаю текущую ref, добавляю новые 6 кошельков
- }
- //Передаю переданную рефку и добавляю новый гексагон
- function createHexagons(bytes32 ref) internal {
- bytes32 new_ref = createRef(hexagons + 1);
- //Прохожу по переданной рефке и создаю кошельки
- for(uint8 i = 0; i < 6; i++)
- Hexagons[new_ref][i] = Hexagons[ref][i + 1];
- Hexagons[new_ref][5] = msg.sender;
- Addresses[msg.sender].push(new_ref); //Добавляю статистику
- hexagons++; //Увеличиваю счетчик
- }
- //Создаю самый первый гексагон для трех типов кошельков
- function createFirstWallets() public onlyOwner allreadyCreate {
- Hexagons[createRef(1)] = [ownerAddress, ownerAddress, ownerAddress, ownerAddress, ownerAddress, ownerAddress];
- Addresses[ownerAddress].push(createRef(1));
- hexagons++;
- cfw = true;
- }
- function createRef(uint hx) internal returns (bytes32 ref) {
- uint256 _unixTimestamp;
- uint256 _timeExpired;
- ref = keccak256(abi.encodePacked(hx, _unixTimestamp, _timeExpired));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement