Created
May 12, 2023 12:28
-
-
Save joaosantos15/1da147b00573e570f09df816477996dd 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.8.17; | |
contract GaslessDestroy { | |
bool isDestroyable; | |
address owner; | |
constructor (address o) { | |
owner = o; | |
} | |
function destroy() external { | |
require(isDestroyable); | |
selfdestruct(payable(msg.sender)); | |
} | |
function permitDestroy(uint8 v, bytes32 r, bytes32 s) external payable { | |
require(!isDestroyable); | |
bytes32 hash = keccak256(abi.encode("permit-destroy", address(this), block.chainid)); | |
address signer = ecrecover(hash, v, r, s); | |
require(signer != address(0x0)); | |
require(signer == owner); | |
isDestroyable = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment