Documentation Index
Fetch the complete documentation index at: https://docs.daimo.com/llms.txt
Use this file to discover all available pages before exploring further.
This guide gets a working deposit flow running with the Daimo modal SDK. You’ll create a session on your server and render a pre-built deposit UI on the client.
Install
Step 1: Create a session (server-side)
Create a session with your API key on the server - never expose it to the client. The response includes a clientSecret you provide to your frontend.
For details on credential handling, see Daimo’s Credential Model.
// In your API route handler:
const response = await fetch("https://api.daimo.com/v1/sessions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DAIMO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
destination: {
type: "evm",
address: "0xYourAddress",
chainId: 8453, // Base
tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
amountUnits: "10.00", // $10 USDC
},
display: {
title: "Deposit to Acme",
verb: "Deposit",
},
}),
});
const { session } = await response.json();
// Return session.clientSecret and session.sessionId to the frontend
Step 2: Render the modal (client-side)
Pass the clientSecret to your React frontend and render <DaimoModal>.
import { DaimoSDKProvider, DaimoModal } from "@daimo/sdk/web";
import "@daimo/sdk/web/theme.css";
function App() {
return (
<DaimoSDKProvider>
<DepositPage />
</DaimoSDKProvider>
);
}
function DepositPage() {
// Fetch sessionId and clientSecret from your backend
const [sessionId, setSessionId] = useState<string | null>(null);
const [clientSecret, setClientSecret] = useState<string | null>(null);
useEffect(() => {
fetch("/api/create-session", { method: "POST" })
.then((res) => res.json())
.then((data) => {
setSessionId(data.session.sessionId);
setClientSecret(data.session.clientSecret);
});
}, []);
if (!sessionId || !clientSecret) return null;
return (
<DaimoModal
sessionId={sessionId}
clientSecret={clientSecret}
onPaymentCompleted={() => console.log("deposit succeeded")}
/>
);
}
Step 3: Handle completion
When the deposit completes, poll for status using GET /v1/sessions/{id}. See Check Session.
The session’s destination.delivery.txHash contains the on-chain transaction which delivers the funds to the destination address.
Next steps