I want to write a smart contract that encodes some real life contract between parties, and I want to blackhole it, but then have the canister self destruct once the contract is executed.
How would I do the self destruction?
I want to write a smart contract that encodes some real life contract between parties, and I want to blackhole it, but then have the canister self destruct once the contract is executed.
How would I do the self destruction?
I think the closest you can get is to have the canister itself as the controller and then call stop_canister
on the management canister as a one-shot notify call. Then, there’s no way to start it again (but also no way to delete the canister). It will just slowly run out of cycles.
Another approach would be to have a blackholed contract manager canister that would be the controller of all contract canisters, and take care of stopping and deleting the contract canisters.
A third way could be to have a blackholed canister with a flag like is_killed
and you check the flag on every invocation and if it is true you trap.
Maybe there’s still a better approach…