In theory we could use this command:

cargo contract remove --execute --code-hash '******' --url 'wss://rococo-contracts-rpc.polkadot.io' --suri 'seeds'

But in order to do that we have first to terminate the smart contract that was uploaded and instantiated.

How to do this in a "graceful way" ?

Note:For instance in Ethereum there is a horrendous thing called "selfdestruct".

1 Answer 1


One of possible solutions would be to have per default as "best practices" in every smart-contract created a function called "destructor" together with a "beneficiary account".

    #[ink(message, payable)]
    pub fn destructor(&self)  -> Result<(), Error> {
        let caller = self.env().caller();
        if caller == self.beneficiary_account_id {
        } else {
            return Err(Error::InvalidCaller);

Would be nice to hear other points of view of this approach.


  • By the way there is a good example here
    – Evil Kyle
    Commented Jul 27, 2023 at 18:42

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.