as mentioned in documentation "Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode." so my question is how does it possible , my purpose is to release Eth which stuck in a contract due to code mistake, and there is no way to withdraw now

1 Answer 1


If your contract has a function to run delegatecall with some way to provide the function to call, you can in make it run a function in another contract, which calls selfdestruct. Since functions ran by delegatecall will execute in the context of the first contract, this will self destruct the first contract. For example:

contract A {
  function kill (address payable to) public {

contract B {
  function run (address target, string calldata func, address to) public {
    target.delegatecall(abi.encodeWithSignature(func, to));

Calling run with the address of contract A, kill(address) as func and any address as to, will cause contract B to self destruct and send the Ether to address to.

This run function is not very secure, as you can see. If your contract does not have such a function built-in, you're out of luck, and your ETH is unfortunately stuck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.