Remove application resources before deleting an Aptos object

Deleting an object’s framework core is only one part of retiring it. Resources published by application modules at the same address need their own cleanup paths.

Plan deletion at construction time

For an object intended to be deletable, use a suitable constructor and retain its DeleteRef under controlled custody. A sticky object is deliberately undeletable. The example belongs in the module defining Attachment and assumes a simple droppable revision field.

let addr = object::address_from_delete_ref(&delete_ref);
let Attachment { revision: _ } = move_from<Attachment>(addr);
object::delete(delete_ref);

Inventory all resources at the object address

Remove or migrate application resources through their defining modules, then consume the DeleteRef. Verify the post-transaction state at that address. If another module’s attachment remains, deleting ObjectCore cannot run that module’s destructor or release its assets automatically. Design the lifecycle before allowing external extensions.

Sources