pragma solidity ^0.4.24; contract Test { uint FEE = 0.01 ether; uint LIST_SIZE = 5; mapping(address => address[]) participants; constructor () public { for(uint i = 0; i < LIST_SIZE; i++) participants[msg.sender].push(msg.sender); } function getList(address addr) public view returns(address[]) { return participants[addr]; } function acceptInvite(address inviteFrom) public payable { require(participants[inviteFrom].length > 0); require(msg.value >= FEE * LIST_SIZE); //pay to users in list for(uint i = 0; i < participants[msg.sender].length; i++) { if (participants[msg.sender][i] != address(0)) { participants[msg.sender][i].transfer(FEE); } } // create new user list participants[msg.sender] = participants[inviteFrom]; for(i = LIST_SIZE - 1; i > 0; i--) { participants[msg.sender][i] = participants[msg.sender][i-1]; } participants[msg.sender][0] = msg.sender; } function getBalance(address addr) public view returns(uint) { return addr.balance; } }
0.4.24