# Architecture

```
  Your App
  +-------------------------------------------------+
  |                                                 |
  |   EVM Wallet (Wagmi)       Miden Wallet         |
  |        |                        |               |
  |        v                        v               |
  |   +--------------------------------------+      |
  |   |        Epoch Intent SDK              |      |
  |   |   Builds intents, manages collateral |      |
  |   +--------------------------------------+      |
  +---------|--------------------|------------------+
            |                    |
            v                    v
  +----------------+    +----------------+
  | The Compact    |    |   Allocator    |
  | (EVM contract) |    |                |----> SIO (Solver Network)
  +----------------+    +----------------+            |
                                                      v
                                              Solvers execute
                                              cross-chain txns
```

Your app integrates the **Epoch Intent SDK**. The SDK takes two inputs — an EVM wallet client and intent parameters — and handles everything else: collateral management, allocator communication, and solver coordination.

For Miden-sourced intents, the SDK calls back into your app to lock tokens on Miden (via a [P2IDE note](https://docs.miden.xyz/builder/smart-contracts/notes/note-types#p2ide-pay-to-id-with-expiration)). Your app provides this callback; the SDK tells you when to call it, how much to lock, and who to send it to.

## Components

### Epoch Intent SDK

The primary integration point. You initialize it with an allocator URL and an EVM wallet client, then call two methods:

* **`getTaskData()`** — encodes your intent parameters (source token, destination token, amount, recipient, chain)
* **`solveIntent()`** — executes the full flow: locks collateral, submits to the allocator, triggers solver execution

For Miden-to-EVM, `solveIntent` accepts a `createMidenP2IDNote` callback that the SDK calls when it needs your app to lock Miden tokens as collateral.

### Allocator

Backend service the SDK communicates with. Receives signed intents, submits them to the solver network, and exposes status endpoints. Also holds a Miden account that receives P2IDE notes from users during bridging.

| Endpoint                                 | Purpose                              |
| ---------------------------------------- | ------------------------------------ |
| `POST /compact`                          | Submit a signed intent               |
| `POST /checkIfDepositNeeded`             | Check if collateral lock is required |
| `GET /intentStatus/:address/:nonce`      | Poll execution status                |
| `GET /miden-recipient`                   | Get allocator's Miden account ID     |
| `GET /suggested-nonce/:chainId/:address` | Get next nonce                       |

### The Compact

EVM smart contract (`0x00000000000000171ede64904551eeDF3C6C9788`) that holds token deposits as collateral. Used in EVM-to-Miden flow, the SDK deposits tokens here automatically when you call `solveIntent` with `collateralType: 'evm'`.

### SIO (Solver Network)

Matches intents with solvers who execute them across chains. Your app never talks to SIO directly; the allocator handles this.


---

# 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.epochprotocol.xyz/epoch-miden-integration/architecture.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.
