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
Solidity – How to Call Selfdestruct Without Writing It in Contract
ethereumjselfdestructsolidity
Best Answer
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 callsselfdestruct
. Since functions ran bydelegatecall
will execute in the context of the first contract, this will self destruct the first contract. For example:Calling
run
with the address of contract A,kill(address)
asfunc
and any address asto
, will cause contract B to self destruct and send the Ether to addressto
.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.