Created
August 19, 2020 15:06
-
-
Save AugustoL/e7eb934232df6cf0270e1f022c515528 to your computer and use it in GitHub Desktop.
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 + 2630000; // 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