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 viemRequirements: 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
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)
getTaskDatawithTaskType.GetTokenOutgetIntentQuote— storequoteResultsolveIntentwithquoteResultandonExecutionStatuscallbackSave
data.allocationResponse.noncefor status pollinggetIntentStatus(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
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
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
solveIntentwithout a priorgetIntentQuoteWrong
destinationChainIdtype — pass as string (e.g."84532")Using mainnet
apiBaseUrlon testnet chains (or vice versa)Forgetting viem
walletClientmust have.chainand.accountset
Next steps
SDK Reference — full method documentation
Gasless Deposits — EIP-7702 testnet relay
Transaction Batching & EIP-7702 — EIP-5792 batching, SIO architecture, test scripts
Last updated