Configure Locking
This guide demonstrates how to use the three independent locking dimensions to control write access, record deletion, and trail deletion. For a conceptual overview, see Locking Configuration.
Prerequisites
- An existing
AuditTrailobject on the IOTA network - Familiarity with creating an
AuditTrailobject - An admin address owning an admin role capability as been shown in Create an Audit Trail
Steps
1. Set Up Multiple Wallets
Create an admin wallet, a locking-admin wallet, and a record-admin wallet to separate locking administration from record writing. The capabilities granting the needed permissions will be issued to the wallet addresses later on.
Used Utility Functions
2. Create LockingAdmin and RecordAdmin Roles
Delegate locking configuration to a LockingAdmin role and record operations to a RecordAdmin role.
Used Utility Functions
3. Freeze Writes with a Write Lock
Set the write lock to Infinite to prevent any new records from being added to the trail.
4. Lift the Write Lock
Remove the write lock by setting it to None, re-enabling record additions.
5. Configure the Delete-Record Window and Delete-Trail Lock
Set a count-based deletion window to protect the newest N records from deletion. Set the delete-trail lock to prevent the entire trail from being removed.
Locking Options Reference
| Lock Type | Options | Description |
|---|---|---|
| Write lock | None, Infinite, UnlockAtMs(timestamp) | Controls whether new records can be added |
| Delete-record window | None, CountBased(n), TimeBased(ms) | Protects recent records from deletion; n must be > 0 (use None for no lock) |
| Delete-trail lock | None, Infinite, UnlockAtMs(timestamp) | Controls whether the trail can be deleted |
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...