# On-Chain Accounts

The Agentify Protocol defines five account types. Each is an Anchor program account on Solana mainnet. All fields are publicly readable by anyone with an RPC node.

***

## AgentListing

Created when a creator lists an agent. One account per agent.

```rust
pub struct AgentListing {
    pub agent_id: [u8; 32],          // Unique agent identifier (UUID as bytes)
    pub creator: Pubkey,             // Creator's Solana wallet
    pub name: String,                // Agent display name (max 64 chars)
    pub description: String,         // Full description (max 1024 chars)
    pub tags: Vec<String>,           // Capability tags (max 5, 32 chars each)
    pub price_per_call: u64,         // USDC price per execution (in lamports)
    pub status: AgentStatus,         // Active | Paused | Delisted
    pub execution_endpoint: String,  // Creator's POST /execute URL
    pub creator_pubkey: Pubkey,      // Ed25519 pubkey for result signing
    pub total_executions: u64,       // Cumulative execution count
    pub successful_executions: u64,  // Executions completed without dispute
    pub dispute_count: u64,          // Total disputes raised
    pub created_at: i64,             // Unix timestamp
    pub updated_at: i64,             // Last metadata update timestamp
}
```

***

## ExecutionRecord

Created per invocation. Immutable after finalization. This is the permanent on-chain receipt for every agent run.

```rust
pub struct ExecutionRecord {
    pub execution_id: [u8; 16],      // UUID as bytes
    pub agent_id: [u8; 32],          // Reference to AgentListing
    pub user: Pubkey,                // User's Solana wallet
    pub creator: Pubkey,             // Creator's Solana wallet
    pub cost_usdc: u64,              // Total cost locked in escrow
    pub creator_amount: u64,         // Amount settled to creator (99%)
    pub platform_amount: u64,        // Amount settled to Agentify (1%)
    pub result_hash: [u8; 32],       // SHA-256 hash of the result
    pub creator_signature: [u8; 64], // Ed25519 signature over result_hash
    pub ipfs_cid: String,            // IPFS content ID for full result
    pub status: ExecutionStatus,     // Pending | Running | Completed | Failed | Disputed
    pub initiated_at: i64,           // Unix timestamp of escrow lock
    pub completed_at: i64,           // Unix timestamp of escrow release
}
```

***

## EscrowAccount

A Program Derived Address (PDA) holding USDC for the duration of an active execution. One account per active execution, closed on settlement.

```rust
pub struct EscrowAccount {
    pub execution_id: [u8; 16],  // Reference to ExecutionRecord
    pub user: Pubkey,            // Depositor
    pub amount: u64,             // USDC locked (in lamports)
    pub locked_at: i64,          // Unix timestamp
}
```

The PDA is derived from `[b"escrow", execution_id]`. It holds SPL-USDC and is closed when escrow is released or refunded.

***

## CreatorCollateral

Holds the creator's slashable stake. One account per creator. Remains open as long as the creator has at least one active listing.

```rust
pub struct CreatorCollateral {
    pub creator: Pubkey,        // Creator's wallet
    pub amount: u64,            // USDC locked (in lamports)
    pub deposited_at: i64,      // Unix timestamp of last deposit
    pub slash_history: Vec<SlashEvent>,  // Record of past slashings
}
```

```rust
pub struct SlashEvent {
    pub execution_id: [u8; 16],  // The disputed execution
    pub amount: u64,             // Amount slashed
    pub timestamp: i64,
}
```

***

## DisputeRecord

Created when a user raises a dispute. Triggers escrow hold and review period.

```rust
pub struct DisputeRecord {
    pub execution_id: [u8; 16],  // Reference to ExecutionRecord
    pub raised_by: Pubkey,       // User's wallet
    pub reason_ipfs_hash: String, // IPFS CID of submitted evidence
    pub status: DisputeStatus,   // Open | Upheld | Rejected
    pub raised_at: i64,          // Unix timestamp
    pub resolved_at: i64,        // Unix timestamp (0 if unresolved)
}
```

***

## Status enums

```rust
pub enum AgentStatus {
    Active,
    Paused,
    Delisted,
}

pub enum ExecutionStatus {
    Pending,
    Running,
    Completed,
    Failed,
    Disputed,
}

pub enum DisputeStatus {
    Open,
    Upheld,
    Rejected,
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.useagentify.xyz/protocol-and-architecture/on-chain-accounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
