Skip to main content

Correct Records

This guide shows how to correct an existing record without mutating or deleting it. A correction appends a new record, links it to the record it supersedes, and lets readers resolve the current version while preserving the full history.

Prerequisites​

  • An existing AuditTrail object on the IOTA network
  • A capability with CorrectRecord permission, such as one issued from a RecordAdmin role
  • Familiarity with adding and reading records

Steps​

1. Set Up Multiple Wallets​

Create an admin wallet and a record-admin wallet. The admin creates the trail and grants the record-admin wallet permission to correct records.

Used Utility Functions
examples/audit-trail/advanced/12_correct_records.rs
loading...

2. Create a Trail with an Initial Record​

Create a trail that starts with the record you want to correct later. The initial record receives sequence number 0.

examples/audit-trail/advanced/12_correct_records.rs
loading...

3. Grant Record Correction Permission​

Create a RecordAdmin role and issue a capability to the record-admin wallet. The standard record-admin permission set includes CorrectRecord.

examples/audit-trail/advanced/12_correct_records.rs
loading...

4. Append a Correction Record​

Call the correction API with the sequence number of the record being corrected. The original record stays in place, and the correction is appended with a new sequence number.

examples/audit-trail/advanced/12_correct_records.rs
loading...

Read the original record, the correction record, and the current version resolved from the original sequence number.

examples/audit-trail/advanced/12_correct_records.rs
loading...

6. Verify the Original Cannot Be Corrected Twice​

Attempting to correct an already replaced record fails. To continue a correction chain, correct the latest record returned by resolve_current / resolveCurrent.

examples/audit-trail/advanced/12_correct_records.rs
loading...

Expected Behavior​

  • The correction is appended as a new record with its own sequence number.
  • The original record's correction metadata points to the replacement record.
  • The correction record's metadata lists the sequence number it replaces.
  • Resolving the current record from the original sequence number returns the appended correction.
  • Correcting an already replaced record is rejected.

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/12_correct_records.rs
loading...