Skip to content

Instantly share code, notes, and snippets.

@joaosantos15
Created May 12, 2023 12:28
Show Gist options
  • Save joaosantos15/1da147b00573e570f09df816477996dd to your computer and use it in GitHub Desktop.
Save joaosantos15/1da147b00573e570f09df816477996dd to your computer and use it in GitHub Desktop.
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