Skip to main content

Manage Record Tags

This guide demonstrates how to manage the record tag registry after trail creation: delegating tag management to a dedicated role, adding new tags dynamically, and removing unused tags. Tags that are still referenced by roles or records cannot be removed.

Prerequisites

Steps

1. Set Up Multiple Wallets

Create an admin wallet, a tag-admin wallet, and a finance-writer wallet to separate tag management from record writing.

Used Utility Functions
examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

2. Create a Trail with an Initial Tag

Start with a trail that has at least one tag in its registry.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

3. Delegate Tag Management to a TagAdmin Role

Create a TagAdmin role with AddRecordTags and DeleteRecordTags permissions.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

4. Add a New Tag

Add a tag to the registry after trail creation. New tags become immediately available for use in roles and records.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

5. Create a Role Scoped to a Tag and Add a Record

Create a role restricted to a specific tag and use it to add a tagged record.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

6. Verify In-Use Tags Cannot Be Removed

Attempting to remove a tag that is referenced by a role or record fails.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

7. Remove an Unused Tag

Tags that are not referenced by any role or record can be safely removed.

examples/audit-trail/advanced/11_manage_record_tags.rs
loading...

Expected Behavior

  • Tags can be added dynamically after trail creation.
  • Tags that are in use (referenced by roles or records) cannot be removed.
  • Unused tags can be removed from the registry.
  • Tag management can be delegated through a dedicated TagAdmin role.

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/advanced/11_manage_record_tags.rs
loading...