Integration Guide
updated with @miden-sdk 0.14.5
1. Install
pnpm add @epoch-protocol/epoch-intents-sdk
pnpm add wagmi viem @rainbow-me/rainbowkit @tanstack/react-query
pnpm add @miden-sdk/miden-sdk @miden-sdk/miden-wallet-adapter-base \\\\
@miden-sdk/miden-wallet-adapter-react @miden-sdk/react2. Initialize the SDK
2.1 Cross-chain (Miden → EVM)
import { useEffect, useState } from 'react';
import { useWalletClient } from 'wagmi';
const MIDEN_VIRTUAL_CHAIN_ID = 999999999;
export function useMidenSourceSDK() {
const { data: walletClient } = useWalletClient();
const [sdk, setSdk] = useState<any>(null);
useEffect(() => {
if (!walletClient) {
setSdk(null);
return;
}
let cancelled = false;
import('@epoch-protocol/epoch-intents-sdk').then(({ EpochIntentSDK }) => {
if (cancelled) return;
const midenWalletClient = {
...walletClient,
chain: { ...(walletClient.chain ?? {}), id: MIDEN_VIRTUAL_CHAIN_ID },
};
setSdk(new EpochIntentSDK({
apiBaseUrl: import.meta.env.VITE_ALLOCATOR_URL ?? '<http://localhost:3000>',
walletClient: midenWalletClient,
}));
});
return () => { cancelled = true; };
}, [walletClient]);
return { sdk, isReady: !!sdk };
}2.2 Withdraw (EVM → Miden)
2.3 Why useEffect and not useMemo
useEffect and not useMemoField
Cross-chain
Withdraw
3. Intent lifecycle
Step
Input
Output
Side effects
4. Miden → EVM
4.1 Encode task data
4.2 Quote
4.3 Solve
4.4 Field reference
Field
Value
Meaning
5. EVM → Miden
5.1 Encode task data
5.2 Quote + solve
5.3 Field reference
Field
Value
Meaning
6. createMidenP2IDNote callback
createMidenP2IDNote callback7. Track intent status
8. Identifier normalization
9. Decimals & amounts
Field
Format
Source
Last updated