Capabilities Bitmask
Agent capabilities are encoded as au64 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
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
deactivate(agent_id) -> bool
deactivate(agent_id) -> bool
Deactivate an agent. Callable by the owner or the governance address.
- Returns
trueon success,falseif unauthorized. - Emits
AgentDeactivated(agentId).
update_reputation(agent_id, new_score) -> bool
update_reputation(agent_id, new_score) -> bool
Set a new reputation score for an agent. Governance only.
- Returns
trueon success,falseif the caller is not governance. - Emits
ReputationUpdated(agentId, newScore).
get_agent(agent_id) -> (Address, U256, U256, U256, bool)
get_agent(agent_id) -> (Address, U256, U256, U256, bool)
Read an agent’s full record.Returns
(owner, capabilities, revenue_share_bps, reputation, active).has_capability(agent_id, cap_flag) -> bool
has_capability(agent_id, cap_flag) -> bool
Check whether an agent has a specific capability flag set.
total_agents() -> U256
total_agents() -> U256
Returns the total number of agents ever registered (including deactivated).
set_governance(new_governance) -> bool
set_governance(new_governance) -> bool
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 singlegovernance address with two exclusive powers:
- Deactivate any agent — acts as a safety valve if an agent is misbehaving.
- Update reputation scores — only governance can write to the
reputationmapping.
address(0). The first call to
set_governance bootstraps it. After that, only the current governance address
can transfer the role.
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