Create an Audit Trail
This guide walks you through creating a new AuditTrail object on the IOTA network, inspecting the built-in Admin role, defining a custom role, and issuing a capability for it.
Prerequisites
- A funded IOTA account
- Access to an IOTA network (testnet, devnet, or local)
- Audit Trails client packages installed (Rust or Wasm)
Steps
1. Set Up Multiple Wallets
Create an admin wallet (which creates the trail) and a record-admin wallet that will receive a delegated capability.
Used Utility Functions
2. Create the Trail
Use the builder to create a trail with immutable metadata (name and description), mutable updatable metadata, and an initial seed record. On success, an Admin capability is automatically minted and transferred to your address.
3. Define a Custom Role
Use the Admin capability to create new roles. PermissionSet::record_admin_permissions() grants AddRecord, DeleteRecord, and CorrectRecord permissions.
4. Issue a Capability
Mint an on-chain Capability object for the role and send it to the target address. The holder can then perform the actions permitted by the role.
Expected Behavior
- A new
AuditTrailobject is created on-chain with a unique trail ID. - The creator automatically receives an Admin capability with full permissions to administer the trail.
- Custom roles can be defined and capabilities issued using the Admin capability.
- Each capability is an on-chain object that can be transferred to other addresses.
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...