Docs Técnicas
Admin Patterns
TREA standardizes a small set of administrative modules so product contracts do not invent a different owner, role, or pause shape every time.
TREA standardizes a small set of administrative modules so product contracts do not invent a different owner, role, or pause shape every time.
These modules are intentionally small. They are usually composed into another contract rather than deployed as a product on their own.
Ownable
std.access.Ownable gives a contract a single owner.
Typical use:
import std.access.Ownable
contract InstitutionToken impl Ownable:
@tx
def mint(to: Address, amount: u128):
self.only_owner()
...Use it when exactly one administrative account controls sensitive actions such as minting, parameter updates, or emergency recovery.
Roles
std.access.Roles names an operational admin rather than an economic owner. This is useful for servicing contracts, loan administration, or workflows where the privileged account is a role in the product rather than the owner of the asset.
The Simple Loan example uses this distinction: the admin acts as servicer, while lender and borrower remain product parties.
See Simple Loan.
Pausable
std.token.Pausable provides a pause switch. Product contracts decide who is allowed to call it by overriding or wrapping pause() and unpause() with their own access checks.
For regulated assets, the common pattern is:
contract PausableInstitutionToken impl BasicToken, Ownable, Pausable:
@tx
def pause():
self.only_owner()
super.pause()See Pausable Institution Token.
Choosing The Pattern
| Need | Pattern | |------|---------| | One admin controls the contract | Ownable | | A named operator/servicer performs lifecycle actions | Roles | | Emergency stop or regulatory halt | Pausable | | Multi-party authorization | MultisigVault or a product-specific approval flow |
Avoid exposing an admin primitive as a user-facing product by itself. The useful product is usually the composed contract: a token, vault, loan, RWA, card, or factory that uses the admin primitive internally.