Skip to content

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

solidity
contract AgentVault is IAgentVault, IERC721

Implements a strict ERC-721 surface (v0.4):

  • ownerOf(tokenId) reverts with AgentNotFound for non-existent / burned agents (not zero address)
  • balanceOf(address) — count of agents owned by address
  • transferFrom / safeTransferFrom — gated by per-agent transferable flag
  • approve / setApprovalForAll / getApproved / isApprovedForAll
  • tokenURI(tokenId) — points to off-chain manifest
  • supportsInterface — ERC-165 declaration for IERC721

Key functions

mintAgent

solidity
function mintAgent(
    address owner,
    bytes32 genesisHash,
    bytes32 modelTierPolicy,
    address operator,
    bool transferable
) external returns (uint256 agentId);

topUp

solidity
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

solidity
function withdraw(uint256 agentId, address to, uint256 amount) external;

Owner-only. Decrements ledger and transfers cMOR out.

debitConsume

solidity
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

solidity
function liquidate(uint256 agentId, address to, uint256 amount) external onlySettlement;

Used in keeper-reward + dispute paths.

burn

solidity
function burn(uint256 agentId) external;

Owner-only. Requires per-agent ledger balance == 0. Permanently removes the agent NFT.

Invariants

  1. vault balance == sum(per-agent ledger) — enforced by ledger arithmetic on every state-changing entry point.
  2. cMOR token immutabilitycMORToken set in constructor, never changes.
  3. Genesis-locked identitygenesisHash (companion GenesisLock contract) 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

Released under the MIT License.