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
- An existing
AuditTrailobject with records - Familiarity with creating an
AuditTrailobject - An admin address owning an admin role capability as been shown in Create an Audit Trail
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
2. Create a Role with Delete Permissions
Define a role that includes AddRecord, DeleteRecord, and DeleteAllRecords permissions.
3. Delete a Single Record
Remove a specific record by its sequence number.
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.
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
- Rust
- Typescript (Node.js)
loading...
loading...