Overview
Theaccount_delete syscall marks an account as deleted by setting the DELETED flag. The account must have zero balance and be writable by the current program.
Syscall Code
Code:0x06 (TN_SYSCALL_CODE_ACCOUNT_DELETE)
C SDK Function
Arguments
Index of the account to delete. Must be writable by the current program and have zero balance.
Return Value
Returns a syscall result code:TN_VM_SYSCALL_SUCCESS(0) - Account marked as deleted successfully
TN_VM_ERR_SYSCALL_INVALID_ACCOUNT_INDEX(-7) - Account index out of boundsTN_VM_ERR_SYSCALL_ACCOUNT_DOES_NOT_EXIST(-8) - Account does not existTN_VM_ERR_SYSCALL_ACCOUNT_NOT_WRITABLE(-26) - Account not writable by current programTN_VM_ERR_SYSCALL_INVALID_ACCOUNT(-26) - Account has non-zero balance
Resource Consumption
Compute Units
- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Additional cost: None
- Total cost: Fixed at 512 units
Memory Pages
- Page usage: No immediate page deallocation (pages freed during garbage collection)
- Metadata impact: May trigger metadata page allocation if not already writable
- Future cleanup: Pages will be reclaimed after transaction completion
Side Effects
- Account state: Sets the DELETED flag on the account
- Metadata: Makes account metadata writable if not already
- Data retention: Account data and metadata remain accessible until garbage collection
Usage Notes
- Account must have exactly zero balance before deletion
- Only the account owner (program) can delete the account
- Deleted accounts can be recreated with
account_create(removes DELETED flag) - Account data remains accessible during the transaction even after deletion
- The account becomes eligible for garbage collection after transaction completion
Deletion vs Compression
| Operation | Purpose | Requirements | Effect |
|---|---|---|---|
| Delete | Remove account | Zero balance, ownership | Sets DELETED flag |
| Compress | Archive account | State proof | Sets COMPRESSED flag |