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
- An existing
AuditTrailobject on the IOTA network - Familiarity with creating an
AuditTrailobject
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
2. Create a Trail with Both Metadata Types
Set immutable metadata (name and description) and initial updatable metadata when creating the trail.
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.
4. Update the Mutable Metadata
Change the updatable metadata value. The immutable metadata remains unchanged.
5. Clear the Mutable Metadata
Set the updatable metadata to None / undefined to remove it entirely.
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
MetadataAdmincapability. - 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
- Rust
- Typescript (Node.js)
loading...
loading...