Skip to main content

Agents and roles

The mvp-token contract implements the agent-role-v1 interface. The interface defines the core capabilities and function signatures for adding and managing agents that have permission to perform protected contract operations. The mvp-token contract extends the agent-role-v1 interface by defining additional capabilities and functions to complement the core capabilities and function signatures.

Capabilities

The mvp-token contract defines the following capabilities:

CapabilityImplementation requiredDescription
AGENT-ADDEDagent-role-v1Event emitted when you add a new agent.
AGENT-REMOVEDagent-role-v1Event emitted when you use remove an agent.
AGENT‑ROLES‑UPDATEDNot required.Event emitted when you update the roles assigned to an agent.
ONLY-AGENTagent-role-v1Managed capability to restrict access to specific functions based on the agent role.
ONLY-OWNERagent-role-v1Managed capability to restrict access to specific functions tha can only executed by the contract owner (not used in the mvp-token contract).
OWNERSHIP‑TRANSFERREDagent-role-v1Event emitted when you transfer ownership of the contract to a new guard.

Functions

The mvp-token contract defines the following functions:

FunctionImplementation requiredDescription
add-agentagent-role-v1Adds a new agent to the contract.
enforce-agentNot required.Enforces that an address is an agent.
get-agent-rolesNot required.Retrieves the roles assigned to an agent.
get-owner-guardNot required.Retrieves the guard for the owner.
is-agentagent-role-v1Returns a boolean if an address is an agent.
only-agentagent-role-v1Ensures access is limited to agents.
only-owneragent-role-v1Ensures access is limited to agents (not used in the mvp-token contract).
only-owner-or-agent-adminNot required.Ensures access is limited to owners or agents with the admin role.
remove-agentagent-role-v1Removes an agent from the contract.
transfer-ownershipagent-role-v1Transfers ownership of the contract.
update-agent-rolesNot required.Updates the roles for an agent.
verify-agent-rolesNot required.Verifies the roles assigned to an agent.

Agent role interface

The agent-role interface describes the core capabilities and function signatures for managing agents and roles. At a minimum, the mvp-token contract must implement all of the capabilities and functions included in the interface.

Event capabilities

  • AGENT-ADDED: Event for the successful execution of an add-agent transaction.
  • AGENT-REMOVED: Event for the successful execution of a remove-agent transaction.
  • OWNERSHIP-TRANSFERRED: Event for the successful execution of a transfer-ownership transaction.

Managed capabilities

  • ONLY-OWNER: Validates whether an address has the owner role before allowing the address to be used to execute a transaction.
  • ONLY-AGENT: Validates whether an address has the agent role before allowing the address to be used to execute a transaction.

State-changing functions

  • add-agent: Adds a new agent and guard to the contract.
  • remove-agent: Removes an agent from the contract.
  • transfer-ownership: Transfers ownership of the contract to a new guard.

Utility functions

  • is-agent: Checks whether an address is an agent and returns a boolean indicating the result of he check.
  • only-agent: Checks whether an address has acquired the ONLY-AGENT capability to grant access to functions that can only be executed by valid agents.
  • only-owner: Checks whether an address has acquired the ONLY-OWNER capability to grant access to functions that can only be executed by the operational owner.