Solidity Development – Understanding Selfdestruct

callcodecontract-developmentdelegatecallselfdestructsolidity

I'm just wondering what would happen if I don't put a selfdestrut() method in my smart contract.

As I read from the Solidity documentation (Self-destruct):

Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode.

But… does it mean that anyone could call selfdestruct() to any contract?

Best Answer

No, means that if you use delegate call in your contract and the code at the target address contains a line with selfdestruct(someaddress), this code will be executed in your contract context, effectively destroying your contract.

This means you should be careful when using delegatecall and only use it in contracts that you wrote or that you know well.

Hope this helps

Related Topic