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

# Integration Examples

Working reference implementations for Epoch Protocol integrations. All examples use the **`@epoch-protocol/epoch-intents-sdk`** — the recommended integration path.

***

## epoch-integration-demo

**Type:** Node.js CLI script\
**Repo:** [github.com/epochprotocol/epoch-integration-demo](https://github.com/epochprotocol/epoch-integration-demo)

Minimal headless integration showing the full swap-and-bridge flow without a UI:

```
getHealthCheck()
  → getTaskData({ taskType: GetTokenOut, intentData })
  → getIntentQuote({ sponsorAddress, taskTypeString, intentData })
  → solveIntent({ ..., quoteResult })
  → getIntentStatus(address, nonce)
```

**Default testnet route:** USDC on Ethereum Sepolia → PENGU on Base Sepolia.

| Command                   | Description                    |
| ------------------------- | ------------------------------ |
| `npm run quote`           | Quote only (no transactions)   |
| `npm run swap-and-bridge` | Full swap-and-bridge execution |

Best for: backend scripts, CI smoke tests, understanding the SDK flow before building a UI.

***

## compact-demo-epoch

**Type:** React + Vite + wagmi\
**Repo:** [github.com/Man-Jain/compact-demo-epoch](https://github.com/Man-Jain/compact-demo-epoch)\
**Branch:** `feat/gasless-7702` — [PR #10](https://github.com/Man-Jain/compact-demo-epoch/pull/10)

Full-featured web UI demonstrating swap, bridge, Compact deposits, balance queries, withdrawals, **gasless EIP-7702 deposits**, and a **local private-key signer** for testnet relay testing.

| File                                      | Purpose                                                         |
| ----------------------------------------- | --------------------------------------------------------------- |
| `src/config/wagmi.ts`                     | Supported chains + RainbowKit                                   |
| `src/config/web3.ts`                      | Token/chain discovery from SDK graphs                           |
| `src/config/api.ts`                       | `VITE_API_BASE_URL` helper                                      |
| `src/hooks/useAllocatorAPI.ts`            | Health check, allocator address                                 |
| `src/hooks/useEffectiveWallet.ts`         | Unified browser wallet + local signer                           |
| `src/hooks/useGaslessWallet.ts`           | 7702 probe + `setupSmartAccount`                                |
| `src/context/LocalSignerContext.tsx`      | Private-key wallet client (in-memory)                           |
| `src/components/GaslessEnableButton.tsx`  | Gasless opt-in / smart-account setup UI                         |
| `src/components/WalletConnect.tsx`        | Browser wallet + local signer tabs                              |
| `src/pages/BalancePage.tsx`               | Quote → solve (`gasless: true`, routing preset picker) → status |
| `src/components/UserBalancesList.tsx`     | `getDepositedBalances`                                          |
| `src/components/WalletWithdrawDialog.tsx` | Forced withdrawal flow                                          |

**Gasless test flow (demo UI):** connect via **Local signer** tab → switch to Epoch smart account → enable gasless → get quote → deposit + submit intent.

**Headless integration test (local signer, gasless relay):** `cd smallocator/sdk && pnpm example:local-wallet` — see `test/local-wallet-gasless.ts` and [Gasless Deposits](/integration-guides/gasless-deposits.md#local-wallet--gasless-relay).

**Injected wallet batch probe:** [`scripts/injected-wallet-batch-probe.ts`](https://github.com/epochprotocol/docs-new/tree/main/scripts/injected-wallet-batch-probe.ts) — copy into a wagmi app; user-paid batching only (not gasless relay).

Best for: React apps with wallet connection, swap/bridge UI patterns, Compact balance management, and gasless testnet demos.

See [Gasless Deposits](/integration-guides/gasless-deposits.md).

***

## Kismet (chance-chain)

**Type:** Production dApp — React + Vite + wagmi\
**App:** [app.kismet.today](https://app.kismet.today)\
**Repo:** [github.com/Abhimanyu121/chance-chain](https://github.com/Abhimanyu121/chance-chain)

Live on-chain raffles built on Base. Users fund and buy tickets from Polygon, Optimism, or Arbitrum using Epoch cross-chain intents.

**Integration pattern:**

* Raffles deployed on **Base** (mainnet) or **Base Sepolia** (testnet)
* Users connect on a **source chain** (Polygon, Optimism, Arbitrum)
* Fixed-price ticket purchases use **reverse quotes** (`tokenInAmount: "0"`, fixed `minTokenOut`)
* Quote-then-confirm flow before `solveIntent`

Best for: protocol interaction integrations, fixed-output purchases, production UX patterns.

See [Protocol Interaction Guide](/integration-guides/protocol-interaction.md) for details.

***

## miden-integration-example

**Type:** React + Vite — EVM ⇄ Miden bridge\
**Repo:** [github.com/epochprotocol/miden-integration-example](https://github.com/epochprotocol/miden-integration-example)

Reference dapp for moving value between EVM (Sepolia) and Miden testnet via Epoch intents.

**Flows:**

| Flow        | Direction   | Description                                 |
| ----------- | ----------- | ------------------------------------------- |
| Cross-chain | EVM → Miden | Pay USDC on Sepolia, receive asset on Miden |
| Withdraw    | Miden → EVM | Burn Miden note, receive asset on Sepolia   |

| File                             | Purpose                                          |
| -------------------------------- | ------------------------------------------------ |
| `src/services/epoch-bridge.ts`   | Epoch SDK wrapper (intent build / submit / poll) |
| `src/hooks/useEpochIntent.ts`    | EVM→Miden intent submission                      |
| `src/hooks/useWithdrawIntent.ts` | Miden→EVM withdraw flow                          |
| `src/constants/chains.ts`        | Sepolia + Miden virtual chain id (`999999999`)   |

**Note:** `MIDEN_DESTINATION_CHAIN_ID = 999999999` is the virtual chain id for Miden as intent output — do not use a real EVM chain id.

Best for: non-EVM destination chains, Miden-specific integration patterns.

See also [Miden → EVM Lending Integration](/integration-guides/miden-lending.md).

***

## SDK source

The SDK lives in [github.com/epochprotocol/smallocator](https://github.com/epochprotocol/smallocator/tree/dev/sdk). See [SDK Integration Guide](/integration-guides/sdk-integration-guide.md) for the full integration checklist and code patterns.

***

## Next steps

* [Quickstart](/integration-guides/quickstart.md) — get your first integration running
* [SDK Reference](/integration-guides/sdk-reference.md) — method documentation
* [Supported Chains & Tokens](/supported-chains-and-tokens.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.epochprotocol.xyz/integration-examples.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
