Created
          August 26, 2020 22:22 
        
      - 
      
- 
        Save AugustoL/fa206b17c6c3766f0ae49c0ee1e431df to your computer and use it in GitHub Desktop. 
    ETHRefunds.sol
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | pragma solidity ^0.7.0; | |
| contract ETHRefund { | |
| uint256[] public values; | |
| address[] public receivers; | |
| uint256 public endTime; | |
| address payable public avatar = 0x519b70055af55A007110B4Ff99b0eA33071c720a; | |
| constructor (address[] memory _receivers, uint256[] memory _values) { | |
| receivers = _receivers; | |
| values = _values; | |
| endTime = block.timestamp + 7890000; // 1 month | |
| } | |
| receive() payable external {} | |
| // Claim function to be called by the receiver | |
| function claim(uint256 index) public { | |
| require(block.timestamp < endTime); | |
| require(msg.sender == receivers[index]); | |
| msg.sender.transfer(values[index]); | |
| values[index] = 0; | |
| } | |
| // Destroy the contract and send back the ETH to the avatar | |
| function kill() public { | |
| require(block.timestamp > endTime); | |
| selfdestruct(avatar); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment