Skip to content

Instantly share code, notes, and snippets.

@tsudmi
Last active March 29, 2021 11:07
Show Gist options
  • Save tsudmi/4fc6aa4e3793db9d6c8637b512b23b36 to your computer and use it in GitHub Desktop.
Save tsudmi/4fc6aa4e3793db9d6c8637b512b23b36 to your computer and use it in GitHub Desktop.
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