Skip to main content

Enforce Capability Constraints

This guide demonstrates how to issue address-bound capabilities and verify that unauthorized wallets cannot use them. It also shows that capability revocation takes effect immediately.

Prerequisites

Steps

1. Set Up Multiple Wallets

Create an admin wallet, an intended writer, and a wrong writer to demonstrate address binding.

Used Utility Functions
examples/audit-trail/advanced/10_capability_constraints.rs
loading...

2. Issue an Address-Bound Capability

Create a role and issue a capability bound to the intended writer's address using the issued_to parameter.

Used Utility Functions
examples/audit-trail/advanced/10_capability_constraints.rs
loading...

3. Verify Unauthorized Access Is Denied

A different wallet attempts to add a record — this fails because the capability is bound to a different address.

examples/audit-trail/advanced/10_capability_constraints.rs
loading...

4. Verify Authorized Access Succeeds

The intended wallet uses the capability successfully.

examples/audit-trail/advanced/10_capability_constraints.rs
loading...

5. Revoke the Capability and Verify Immediate Effect

After revocation, even the previously authorized wallet can no longer use the capability.

examples/audit-trail/advanced/10_capability_constraints.rs
loading...

Expected Behavior

  • Address-bound capabilities can only be used by the specified wallet address.
  • Any other wallet attempting to use the trail is rejected, even if they hold a different capability.
  • Revocation is instant — the revoked capability is immediately unusable.

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/10_capability_constraints.rs
loading...