Skip to main content

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​

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
examples/audit-trail/04_configure_locking.rs
loading...

2. Create LockingAdmin and RecordAdmin Roles​

Delegate locking configuration to a LockingAdmin role and record operations to a RecordAdmin role.

Used Utility Functions
examples/audit-trail/04_configure_locking.rs
loading...

3. Freeze Writes with a Write Lock​

Set the write lock to Infinite to prevent any new records from being added to the trail.

examples/audit-trail/04_configure_locking.rs
loading...

4. Lift the Write Lock​

Remove the write lock by setting it to None, re-enabling record additions.

examples/audit-trail/04_configure_locking.rs
loading...

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.

examples/audit-trail/04_configure_locking.rs
loading...

Locking Options Reference​

Lock TypeOptionsDescription
Write lockNone, Infinite, UnlockAtMs(timestamp)Controls whether new records can be added
Delete-record windowNone, CountBased(n), TimeBased(ms)Protects recent records from deletion; n must be > 0 (use None for no lock)
Delete-trail lockNone, 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​

examples/audit-trail/04_configure_locking.rs
loading...