For the complete documentation index, see llms.txt. This page is also available as Markdown.

SDK Integration Guide

Add Epoch cross-chain intent flows to any JavaScript/TypeScript project using @epoch-protocol/epoch-intents-sdk. Reference implementation: compact-demo-epoch.

This guide is adapted from skills.md.


Integration Checklist

- [ ] Install @epoch-protocol/epoch-intents-sdk, viem (peer dep)
- [ ] Set apiBaseUrl env var (testnet: https://testnet-dev.epochprotocol.xyz)
- [ ] Configure wallet client (viem or wagmi) on a supported chain
- [ ] Fetch allocator address via sdk.getHealthCheck() (do not hard-code)
- [ ] Implement: getTaskData → getIntentQuote → solveIntent → getIntentStatus
- [ ] Use testnetGraph/mainnetGraph for token/chain discovery
- [ ] (Optional, testnet) Gasless Compact deposits: `convertToSmartAccount` → `solveIntent({ gasless: true, allowGaslessSmartAccount: true })` — see [Gasless Deposits](gasless-deposits.md)

Install

npm install @epoch-protocol/epoch-intents-sdk viem

Requirements: Node.js 18+, TypeScript 5+, viem 2.x


Environment

Always read the allocator address at runtime via sdk.getHealthCheck() — do not rely on stale SDK constants.


APIs Quick Reference

Item
Value

SDK apiBaseUrl (testnet)

https://testnet-dev.epochprotocol.xyz

SDK apiBaseUrl (mainnet)

https://api.epochprotocol.xyz

Full chain and token tables: Supported Chains & Tokens.


Core Intent Flow

The SDK handles ERC-20 approval and Compact deposits automatically inside solveIntent.


Vanilla TypeScript (Node / any JS)

See epoch-integration-demo for a runnable Node.js script.

Routing & liquidity options (optional)

Use routingAndLiquidityOptions when you want to control how the swap is filled — single-transaction filler liquidity (one user signature, seamless end-to-end execution including protocol interactions) vs multi-transaction external routing vs best-of-all.

Presets: any (default), filler-single-transaction (one transaction, seamless end-to-end execution for the user — protocol interactions handled by the filler), external-multi-transactions, custom (with solvers: [\0x…`]`). See SDK Reference.


React + wagmi Pattern (from compact-demo-epoch)

1. Wagmi chains

Configure viem testnet/mainnet chains in wagmi config (compact-demo-epoch/src/config/wagmi.ts):

2. Token/chain discovery from SDK graphs

3. Instantiate SDK per action

4. Swap submit (compact-demo-epoch/src/pages/BalancePage.tsx)

  1. getTaskData with TaskType.GetTokenOut

  2. getIntentQuote — store quoteResult

  3. solveIntent with quoteResult and onExecutionStatus callback

  4. Save data.allocationResponse.nonce for status polling

  5. getIntentStatus(address, nonce)

5. Compact balances & withdrawals

6. Health / allocator address

7. Gasless mode (testnet, optional)

Local private-key wallets: users sign only — the allocator relays Compact deposits via epoch-sio (gasless). Injected wallets: gasless relay is not available; the SDK may batch calls via wallet_sendCalls when the wallet is already a smart account, but the user pays gas:

Injected wallets: SDK does not prompt smart-wallet upgrade. Gasless relay is for local signers; browser wallets use wallet-paid execution with optional batching when already a smart wallet.

Probe before showing UI:

Local integration test: cd smallocator/sdk && pnpm example:local-wallet — see Gasless Deposits.

Full guide: Gasless Deposits. Architecture, batching, and SIO relay: Transaction Batching & EIP-7702.


Task Types

Task
Enum
Use case

Swap / bridge

TaskType.GetTokenOut

Cross-chain token output

Protocol action

TaskType.ProtocolInteraction

NFT buy, raffle, lending, etc.

Deposit only

TaskType.Deposit

Lock funds without a swap intent


Key SDK Exports


compact-demo-epoch File Map

File
Purpose

src/config/wagmi.ts

Supported chains + RainbowKit

src/config/web3.ts

Token/chain discovery from graphs

src/config/api.ts

VITE_API_BASE_URL helper

src/hooks/useAllocatorAPI.ts

Health check, allocator address

src/hooks/useEffectiveWallet.ts

Browser wallet + local signer

src/hooks/useGaslessWallet.ts

Gasless probe + smart-account setup

src/components/GaslessEnableButton.tsx

Gasless toggle UI

src/components/WalletConnect.tsx

RainbowKit + local signer form

src/pages/BalancePage.tsx

Quote → solve (gasless) → status

src/components/UserBalancesList.tsx

getDepositedBalances

src/components/WalletWithdrawDialog.tsx

Forced withdrawal flow


Common Mistakes

  • Hard-coding allocator address instead of calling getHealthCheck()

  • Submitting solveIntent without a prior getIntentQuote

  • Wrong destinationChainId type — pass as string (e.g. "84532")

  • Using mainnet apiBaseUrl on testnet chains (or vice versa)

  • Forgetting viem walletClient must have .chain and .account set


Next steps

Last updated