I was exploring on self destruct design pattern for a time bound smart contract. So my contract should not accept any further state change after a certain given time period.

While working on that I have come across selfdestruct design pattern which is quite good for the need but leads to loss of funds if any one tries to send funds to a destroyed contract.

What should be the best approach to avoid loss of funds which are being sent to such contracts


2 Answers 2


You've pinpointed a reason for using a pausable pattern instead.

selfdestruct(recipient) takes care of two concerns that can almost always be addressed without leaving these dangerous voids on the blockchain.

  1. Recover funds, which is easily addressed with a withdraw function.
  2. Reject incoming requests, which is easily addressed with a modifier.

Implementation example: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.12.0/contracts/lifecycle/Pausable.sol

You use that to shut down functions that should not be used after termination as well as functions that can only be used in a shutdown (withdraw?).

You can also remove the unPause() function to make a pause action permanent which would more closely emulate the selfdestruct process.

Hope it helps.

  • Hey @rob Thanks for your valueable inputs .. Let me explore further if this solves the purpose and then mark it answered !
    – CaptPython
    Mar 7, 2019 at 3:10

selfdestruct is a good pattern for time bound contracts. You are good to use if you are sure to remove all dead links after expiry and there is no risk of fund loss. This will save you gas cost during the final fund transfer transaction.

but if there are any such risk then to avoid the risk for loosing funds after contract expiry pausable pattern is better as mentioned in response by @Rob.

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.