@openzeppelin-move/access

Version 2 - mainnet - 0x9e...330115

Published by@openzeppelin-move · 4 packages

Readme

Versions

2

Dependencies

0

Dependents

0

Analytics

On the way

openzeppelin_access

[!WARNING] This package is open-source and not actively maintained.

The UpgradeCap for packages published to the Move Registry under @openzeppelin-move/* has been made immutable, so these packages can no longer be upgraded by OpenZeppelin or anyone else.

Role-based authorization and controlled ownership-transfer primitives for Sui Move protocols.

The openzeppelin_access package helps protocols protect privileged functions, shared state, admin capabilities, treasury capabilities, and governance-controlled operations.

Install

[dependencies]
openzeppelin_access = { r.mvr = "@openzeppelin-move/access" }

Modules

ModuleUse it when
access_controlAuthority is spread across multiple roles or actors, especially for shared protocol state and privileged functions.
two_step_transferA single-owned privileged object can transfer immediately, but the recipient should explicitly accept first.
delayed_transferA single-owned privileged object should not transfer or unwrap until a visible delay has elapsed.

Role-Based Access Control

Use access_control when your package needs operational roles such as admins, treasurers, guardians, pausers, keepers, or governance executors.

The registry is rooted in your module's One-Time Witness (OTW). Roles must be defined in the same module as that OTW, and Auth<Role> values can be minted in PTBs as typed authorization proofs.

Initialize the registry from the module's init function when the package is first published. Sui does not run init for modules added in a later package upgrade, so an already-published package cannot adopt AccessControl by adding a new module that expects its OTW to be delivered. Publish a fresh package with its own initializing module and AccessControl registry instead. Use access_control::new when the publisher should be the default admin, or access_control::new_with_admin when the initial default admin should be an explicit governance or multisig address.

use openzeppelin_access::access_control::{Self, AccessControl, Auth};

Start with the Role Based Access Control guide for a full implementation walkthrough with publishing, upgrades, and PTBs.

Relevant docs:

Controlled Object Transfers

Use the transfer modules for single-owned privileged objects, especially capability objects.

Two-step transfer

two_step_transfer wraps an object and requires the intended recipient to accept before ownership moves.

use openzeppelin_access::two_step_transfer;

Docs:

Delayed transfer

delayed_transfer wraps an object and enforces a minimum delay before transfer or unwrap execution.

use openzeppelin_access::delayed_transfer;

Docs:

Examples

[!Warning] These are unaudited illustrations of how the primitives can be integrated, not production-ready code.

Complete integration examples live in examples/, one per module:

  • access_control - a shared reward treasury governed entirely by roles. The protocol's One-Time Witness is the root role, set_role_admin delegates pauser management to a guardian role, and privileged actions take an unforgeable Auth<Role> witness instead of a hand-rolled admin check. The tests also drive the timelocked root-admin handoff (transfer and renounce).
  • two_step_transfer - safe custody of an irreplaceable operator capability. The cap is wrapped so handing it to a new operator is an explicit initiate -> accept handshake, with cancel-and-reclaim and borrow-while-pending paths; the cap stays usable in place through borrow.
  • delayed_transfer - a treasury whose withdrawal key only changes hands, or is reclaimed, after a mandatory and visible delay: schedule -> wait -> execute for both transfers and unwraps, plus cancel. Day-to-day withdrawals borrow the key and never wait on the timelock.

Security Notes

  • access_control root-role changes use delayed flows. Do not try to grant, revoke, or renounce the root role with ordinary role-management calls.
  • Role grants and root transfers reject @0x0. Use the delayed root-renounce flow when the goal is to intentionally lock a registry.
  • two_step_transfer records ctx.sender() as cancel authority. Avoid using it directly in shared-object executor flows unless signer identity is intentionally the cancel authority.
  • delayed_transfer recipients should be wallet addresses, not object IDs, unless your protocol explicitly supports recovery from transfer-to-object custody.

Learn More

Install

You can install this package in your Move project by calling

mvr add @openzeppelin-move/access
Interoperating Transactions

Description

Transfer policies for safely handing objects to new owners.