How to destroy AppAgent

Intro

Destroying an AppAgent means removing it from the blockchain. This is a complex multi-stage process since an AppAgent is responsible for other addresses and assets on chain. The deletion is started by calling initiate_destroy_app_agent which changes the status to ready to be deleted. After this, all of the assets and addresses controlled by the AppAgent must be properly cleaned up before an AppAgent can be completely deleted.

AppAgent Destruction Stages

  1. DestroyInitiated: Indicates that the AppAgent has initiated the destruction process. This event marks the beginning of the destruction phase for the AppAgent.

    • The destruction can be cancelled or reversed at this stage only.

  2. DestroyingOwnAssets: Signifies that the AppAgent is currently in the process of destroying its owned assets.

    • This could include any resources or properties directly associated with the app agent.

  3. DestroyingAddressPool: Denotes that the AppAgent is in the process of destroying its address pool.

    • This typically involves deallocating or releasing addresses or identifiers managed by the AppAgent.

  4. DestroyingAppAgent: Indicates that the AppAgent is currently in the process of destroying its storage or internal data structures.

    • This phase involves clearing out any data or state associated with the AppAgent.

  5. Destroyed: Marks the completion of the destruction process for the AppAgent.

    • At this stage, the AppAgent has been successfully destroyed, and its resources have been deallocated or released.

Prerequisites

  1. Ensure the caller address is the owner of the AppAgent

  2. Ensure the caller address has sufficient tokens to pay the transaction fees.

Destroy an AppAgent

Re-activate the AppAgent after initiating destruction

⚠️ An AppAgent can only be reactivated when in the DestroyInitiated state within the expiry period.

Last updated