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
AuditTrailobject on the IOTA network - A capability with
CorrectRecordpermission, such as one issued from aRecordAdminrole - 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
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.
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.
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.
5. Read the Correction Links
Read the original record, the correction record, and the current version resolved from the original sequence number.
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.
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
- Rust
- Typescript (Node.js)
loading...
loading...