Last active
March 29, 2021 11:07
-
-
Save tsudmi/4fc6aa4e3793db9d6c8637b512b23b36 to your computer and use it in GitHub Desktop.
This file contains 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.5; | |
contract SystemContract { | |
// Address of the recipient extracted from ETH1 withdrawal credentials. | |
address payable public recipient; | |
// Whether the balance was already withdrawn. | |
bool public withdrawn; | |
// A new instance is deployed for every validator with ETH1 withdrawal credentials when it becomes withdrawable. | |
constructor(address payable _recipient) payable { | |
recipient = _recipient; | |
} | |
function withdraw() external { | |
require(!withdrawn, "Already withdrawn"); | |
withdrawn = true; | |
// forwards all available gas | |
(bool success, ) = recipient.call{ value: address(this).balance }(""); | |
require(success, "Withdrawal has failed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment