Skip to main content

Update Metadata

This guide shows how to manage the two-tier metadata system on an AuditTrail object: immutable metadata (set once at creation) and updatable metadata (can be changed or cleared at any time by an authorized role).

Prerequisites

Steps

1. Set Up Multiple Wallets

Create an admin wallet and a metadata-admin wallet that will be delegated metadata-update rights.

Used Utility Functions
examples/audit-trail/03_update_metadata.rs
loading...

2. Create a Trail with Both Metadata Types

Set immutable metadata (name and description) and initial updatable metadata when creating the trail.

examples/audit-trail/03_update_metadata.rs
loading...

3. Delegate Metadata Updates to a Role

Create a MetadataAdmin role and issue a capability for it. This separates metadata management from full administrative control.

examples/audit-trail/03_update_metadata.rs
loading...

4. Update the Mutable Metadata

Change the updatable metadata value. The immutable metadata remains unchanged.

examples/audit-trail/03_update_metadata.rs
loading...

5. Clear the Mutable Metadata

Set the updatable metadata to None / undefined to remove it entirely.

examples/audit-trail/03_update_metadata.rs
loading...

Expected Behavior

  • Immutable metadata (name and description) never changes after trail creation.
  • Updatable metadata can be freely changed or cleared by a holder of a MetadataAdmin capability.
  • Typical use: store a status summary (e.g., "Status: Active") that evolves as the trail progresses.

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/03_update_metadata.rs
loading...