AgentVault (compMOR draft)
Draft contract
Part of compMOR v0.9 draft spec. Not yet deployed to mainnet. Testnet deployments planned at the start of compMOR v1.0.
Source: registry-contracts/contracts/compmor/AgentVault.sol
Purpose
AgentVault is the identity + balance contract for an autonomous agent in compMOR. Each agent is represented by an ERC-721 NFT whose tokenId is the agent's identifier. The vault tracks per-agent cMOR balance, transferability flags, and operator delegation.
Inheritance
contract AgentVault is IAgentVault, IERC721Implements a strict ERC-721 surface (v0.4):
ownerOf(tokenId)reverts withAgentNotFoundfor non-existent / burned agents (not zero address)balanceOf(address)— count of agents owned by addresstransferFrom/safeTransferFrom— gated by per-agenttransferableflagapprove/setApprovalForAll/getApproved/isApprovedForAlltokenURI(tokenId)— points to off-chain manifestsupportsInterface— ERC-165 declaration for IERC721
Key functions
mintAgent
function mintAgent(
address owner,
bytes32 genesisHash,
bytes32 modelTierPolicy,
address operator,
bool transferable
) external returns (uint256 agentId);topUp
function topUp(uint256 agentId, uint256 amount) external;Pulls amount of cMOR (immutable cMORToken ERC-20) via transferFrom from the caller. Updates per-agent ledger.
withdraw
function withdraw(uint256 agentId, address to, uint256 amount) external;Owner-only. Decrements ledger and transfers cMOR out.
debitConsume
function debitConsume(uint256 agentId, uint256 amount) external onlySettlement;Called by the Settlement contract to debit inference usage. cMOR is forwarded to recycleTreasury (the buyback-and-burn destination).
liquidate
function liquidate(uint256 agentId, address to, uint256 amount) external onlySettlement;Used in keeper-reward + dispute paths.
burn
function burn(uint256 agentId) external;Owner-only. Requires per-agent ledger balance == 0. Permanently removes the agent NFT.
Invariants
vault balance == sum(per-agent ledger)— enforced by ledger arithmetic on every state-changing entry point.- cMOR token immutability —
cMORTokenset in constructor, never changes. - Genesis-locked identity —
genesisHash(companionGenesisLockcontract) is set once and immutable.
Test coverage
61 tests passing (0 failing) in AgentVault.t.sol. Coverage spans F1 (token wiring), F2 (ERC-721 strict surface), and v0.3 (consume-forward-to-treasury).
See also
- Contracts overview — full contract map
- compMOR overview — v0.9 draft spec
ForgeToolRegistry— adjacent registry layer