What is the exact signature of
selfdestruct
? (parameters, return type, ..). I couldn't find it. Where can I find it by my self?Does the address given to
selfdestruct
is used to send the remaining ethers of the deleted contract to?Does solidity authorized anyone (any EOA or any contract) to call
selfdestruct
on any contract (does it mean that I can delete uniswap? I guess not, so what are the rules?).Is there a way to disable future calls to
selfdestruct
on my contract from my self or other parties?What are the best practices of
selfdestruct
?
1 Answer
What is the exact signature of selfdestruct? (parameters, return type, ..). I couldn't find it. Where can I find it by my self?
You can refer to the official solidity doc here : https://docs.soliditylang.org/en/latest/units-and-global-variables.html#contract-related
Does the address given to selfdestruct is used to send the remaining ethers of the deleted contract to?
Exactly
Does solidity authorized anyone (any EOA or any contract) to call selfdestruct on any contract (does it mean that I can delete uniswap? I guess not, so what are the rules?).
selfdestruct is optional, you can have contracts that doesn't include selfdestruct and most of them doesn't. If theory if you create a function that calls selfdestruct on your contracts, if there is no access control ( e.g, onlyOwner) anyone (EOA or not) can call it.
Is there a way to disable future calls to selfdestruct on my contract from my self or other parties?
As mentioned you can either not implement selfdestruct to your contract, or you can protect it to make sure only specific user(s) can call it.
What are the best practices of selfdestruct?
selfdestruct is being deprecated. I don't recommend you to use it. https://eips.ethereum.org/EIPS/eip-4758