Skip to main content
The Agent Registry is a Stylus contract that tracks every ouroborai agent instance on-chain. Each agent is registered with a capabilities bitmask, a revenue share percentage, and a reputation score managed by governance.

Capabilities Bitmask

Agent capabilities are encoded as a u64 bitmask. Each bit position represents a DeFi skill the agent is authorized to perform: Capabilities are combined with bitwise OR. An agent registered with CAP_TRADE | CAP_PERPS | CAP_LEND (value 7) can swap, manage perps, and lend — but cannot bid for express lane access or trade RWA stocks.

Storage Layout

Agent IDs are auto-incrementing uint256 values starting at 0. Each agent maps to an owner address, a capabilities bitmask, a revenue share in basis points, a reputation score, and an active flag.

Public Methods

Register a new agent. The caller becomes the owner.
  • capabilities (u64) — bitmask of enabled skills.
  • revenue_share_bps (u16) — revenue share in basis points (max 10,000 = 100%).
  • Returns the new agent’s uint256 ID.
  • Reverts if revenue_share_bps > 10,000.
  • Emits AgentRegistered(owner, agentId, capabilities).
Update an existing agent’s capabilities and revenue share. Only the owner can call this.
  • Returns true on success, false if the caller is not the owner.
  • Reverts if revenue_share_bps > 10,000.
  • Emits AgentUpdated(agentId, capabilities, revenueShareBps).
Deactivate an agent. Callable by the owner or the governance address.
  • Returns true on success, false if unauthorized.
  • Emits AgentDeactivated(agentId).
Set a new reputation score for an agent. Governance only.
  • Returns true on success, false if the caller is not governance.
  • Emits ReputationUpdated(agentId, newScore).
Read an agent’s full record.Returns (owner, capabilities, revenue_share_bps, reputation, active).
Check whether an agent has a specific capability flag set.
Returns the total number of agents ever registered (including deactivated).
Set the governance address. If governance is currently address(0), any caller can set it (one-time bootstrap). After that, only the current governance address can transfer governance.

Events

Governance Model

The contract has a single governance address with two exclusive powers:
  1. Deactivate any agent — acts as a safety valve if an agent is misbehaving.
  2. Update reputation scores — only governance can write to the reputation mapping.
The governance address is initially address(0). The first call to set_governance bootstraps it. After that, only the current governance address can transfer the role.
Revenue share is bounded to 10,000 basis points (100%). Both register and update enforce this limit on-chain, rejecting values above 10,000 with a revert.

Test Coverage

The contract has 10 tests covering:
  • Agent registration and auto-increment IDs
  • Capability bitmask checking
  • Owner-only update enforcement
  • Non-owner update rejection
  • Deactivation by owner and governance
  • Governance reputation updates (authorized and unauthorized)
  • Revenue share boundary validation (max 10,000, above-max rejection)
  • Multi-agent registration with distinct owners