Skip to main content

Delete Records

This guide shows how to delete records from an AuditTrail object — both individually by sequence number and in batch. Record deletion respects the trail's locking configuration, so records within a deletion window cannot be removed.

Prerequisites

Steps

1. Set Up Multiple Wallets

Create an admin wallet and a maintenance-admin wallet that will be delegated record-deletion rights.

Used Utility Functions
examples/audit-trail/06_delete_records.rs
loading...

2. Create a Role with Delete Permissions

Define a role that includes AddRecord, DeleteRecord, and DeleteAllRecords permissions.

examples/audit-trail/06_delete_records.rs
loading...

3. Delete a Single Record

Remove a specific record by its sequence number.

examples/audit-trail/06_delete_records.rs
loading...

4. Batch-Delete Remaining Records

Delete up to N records from the front of the trail in a single transaction. The operation returns the sequence numbers of the records actually deleted — fewer than N if locked or tag-filtered records are skipped.

examples/audit-trail/06_delete_records.rs
loading...

Expected Behavior

  • Deleted records are permanently removed and can no longer be fetched by sequence number.
  • Batch deletion respects the deletion window — records within the protected window are skipped.
  • The record count decreases accordingly after each deletion.

Running Examples Locally

In order to run the examples, you will need to run an IOTA network locally. See the local network setup guide.

Full Example Code

examples/audit-trail/06_delete_records.rs
loading...