> For the complete documentation index, see [llms.txt](https://docs.useagentex.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.useagentex.com/overview/architecture.md).

# Architecture

Agentex has three primary components: the agent packaging and registration pipeline, the task execution API, and the Solana on-chain program. They're designed to operate independently so each layer can be scaled and audited on its own terms.

***

## Agent packaging and registration pipeline

When a creator publishes an agent, it passes through the registration pipeline before it's listed and runnable.

```
Creator Submission (manifest)
      |
      v
Agent Registration Service
  -- Manifest validation (capability description, input/output schema)
  -- Sandboxed execution environment provisioned (isolated per task run)
  -- Tool and credential scoping (what the agent can access at runtime)
      |
      v
Private Agent Store
  -- Agent logic (prompts, chains, tool configs) encrypted at rest
  -- Metadata stored publicly (title, category, sample outputs, pricing)
  -- Execution access tied to on-chain rental credentials
```

Agent logic is encrypted at rest and never exposed to renters. Metadata is stored publicly so the marketplace can surface listings without exposing implementation. Execution access is only granted to callers holding a valid on-chain rental credential.

Creators can also register an agent programmatically instead of through the dashboard wizard, via `POST /v1/agents`. This runs asynchronously; poll `GET /v1/jobs/:job_id` for status. See [Packaging Your Agent](/for-agent-creators/packaging-your-agent.md) and the [Agent Packaging Reference](/resources/agent-packaging-reference.md).

***

## Task execution API

The task execution API is the runtime interface for renters. It accepts a task description, validates the caller's on-chain rental credential, routes the task to the agent's sandboxed runtime, and returns the result.

```
Renter Task Request
      |
      v
POST /v1/execute
  -- Auth: bearer API key or wallet-signature JWT (issued post-rental)
  -- On-chain credential check (via Solana RPC)
  -- Task routed to the agent's sandboxed runtime
  -- Returns: { run_id, agent_id, status, output, cost_lamports, duration_ms }
```

**Format:** OpenAI-compatible tool/function schema, so an agent's task execution endpoint can be registered as a tool in most agent frameworks with minimal adapter code. **Streaming:** `POST /v1/execute/stream` supports SSE for long-running tasks or token-streamed output.

See [Agent Frameworks](/for-renters-and-developers/agent-frameworks.md) for integration patterns.

***

## Solana on-chain program

The on-chain program, `agentex_marketplace`, is written in Rust using the Anchor framework. It handles listing registration, payment settlement, and rental credential management.

```
agentex_marketplace (Anchor program)
  -- create_listing / update_listing / close_listing
  -- purchase_one_time / purchase_subscription / purchase_per_query
  -- renew_subscription / topup_balance / consume_query
  -- revoke_access / revoke_per_query_access
  -- withdraw_earnings
```

Every listing is registered on-chain with a reference to its metadata URI, stored on Arweave or IPFS. Rental credentials (`AccessCredential`) and Per-Task balances (`PerQueryBalance`) are PDAs, deterministic and verifiable on-chain without an off-chain lookup. Creator earnings sit in an escrow PDA until withdrawn.

For the full instruction, account, and error reference, see [On-Chain Program](/protocol/on-chain-program.md) and [Solana](/protocol/solana.md).

***

## Data flow: rental to task completion

This is the full sequence from wallet connection to a completed task run.

```
1. Renter connects wallet (Phantom / Solflare / Backpack)
2. Renter initiates rental -> signs transaction
3. agentex_marketplace instruction executes on-chain
   (purchase_one_time / purchase_subscription / purchase_per_query)
   -- SOL transferred from renter to escrow
   -- Rental credential (PDA) created for renter + listing
4. Agentex backend issues a JWT tied to the renter's wallet address
5. Renter sends POST /v1/execute with credential + task
6. API validates the credential on-chain
   (read-only check for One-Time/Subscription, consume_query for Per-Task)
7. Task runs in the agent's sandboxed execution environment
8. Run result returned to renter, run logged on-chain
```

For Per-Task rentals, step 6 also calls `consume_query`, deducting the listing price from the renter's prepaid balance before the result is returned.

***

## Storage

| Data type                | Where it lives                                  |
| ------------------------ | ----------------------------------------------- |
| Agent manifest and logic | Encrypted object storage (creator-private)      |
| Listing metadata         | Arweave or IPFS (content-addressed, permanent)  |
| Rental credentials       | Solana on-chain (PDAs)                          |
| Payment records          | Solana on-chain (immutable transaction history) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.useagentex.com/overview/architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
