> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blend.money/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Overview

> Blend's TypeScript SDKs for quoting, Safe management, cross-chain execution, and gas sponsorship.

Blend's SDK handles quoting, Safe management, cross-chain execution, and gas sponsorship. Pick the package that matches where your code runs.

These docs target SDK version `3.0.1`.

## Packages

| Package             | Name     | Purpose                                                                        |
| ------------------- | -------- | ------------------------------------------------------------------------------ |
| `@blend-money/core` | Core     | Shared logic, types, and utilities. Installed automatically as a dependency.   |
| `@blend-money/fe`   | Frontend | Browser SDK. SIWE wallet auth, deposit/withdrawal quoting, on-chain execution. |
| `@blend-money/node` | Server   | Node.js SDK. API key auth, account management, session lifecycle.              |

You install either `@blend-money/fe` or `@blend-money/node`. Both pull in `@blend-money/core` for you.

## Frontend vs Server

| Concern                | Frontend (`@blend-money/fe`)                       | Server (`@blend-money/node`)                                                                             |
| ---------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| **Runs in**            | Browser                                            | Node.js                                                                                                  |
| **Auth**               | Publishable key + SIWE wallet signature            | API key (`sk_live_`)                                                                                     |
| **Account scoping**    | Automatic after `signIn()`                         | Manual via `forAccount(accountId)`                                                                       |
| **Quoting**            | `sdk.quoteDeposit({ tokenAddress })`               | `client.sessions.quoteDeposit(intentId, { inputAssetAddress })`                                          |
| **Execution**          | `sdk.execute(quote, { deriveSigner })`             | `client.sessions.execute(intentId, { submitActionPlan })` calls your backend signer                      |
| **Session management** | Automatic. `quoteDeposit` creates/reuses sessions. | Create and quote explicitly, then prefer `sessions.execute()` to coordinate lock, execution, and submit. |
| **Best for**           | Apps where users connect wallets in a browser      | Backends with embedded wallets (Privy, Turnkey)                                                          |

## Core concepts

### Safes

Every user gets their own [Gnosis Safe](https://safe.global) - a smart contract wallet on-chain. Funds are never pooled. Each Safe is independent, with its own balances and positions. The user is always the owner.

### Sessions

Every deposit and withdrawal is a session (also called an intent). A session tracks the operation from quote to settlement. One active session per account at a time. Re-quote on the same session to update prices without creating a new one.

### Action plans

When you execute a quote, the SDK converts it into action plans - the actual on-chain transactions routed through the user's Safe. Deposits produce one action plan. Withdrawals can produce several, one per source chain.

### Paymaster

Frontend Safe transactions are ERC-4337 UserOperations. Configure the required `paymaster` registry with Pimlico or Alchemy endpoints for each execution chain.

The server SDK does not take paymaster settings. Your `submitActionPlan` callback owns backend signing and gas.

SDK 3.0.1 gets gas prices from each configured bundler. It does not call a Blend gas-price method or endpoint.

## Session lifecycle

Sessions move through a state machine. Terminal states are `SETTLED`, `FAILED`, and `CANCELLED`.

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
stateDiagram-v2
    [*] --> OPEN: createSession
    OPEN --> OPEN: quoteDeposit / quoteWithdraw (re-quote)
    OPEN --> LOCKED: lock(signerAddress)
    LOCKED --> SETTLED: submit(txHashes)
    SETTLED --> SETTLED: replay matching hashes
    OPEN --> CANCELLED: cancel or auto-expire (~15min)
    LOCKED --> CANCELLED: cancel or auto-expire (~1hr)
```

Submitting hashes records the submission and settles the session. It does not verify transaction receipts. Use balances and positions as the source of truth for indexed on-chain activity.

The `SessionStatus` type retains `SUBMITTED` and `FAILED` for legacy sessions. New submissions settle directly.

One active session is allowed per account. Re-quote an OPEN session to change its amount, token, or chain. The high-level frontend SDK requires `forceReset: true` to switch between a deposit and withdrawal because that discards the opposite-type active session.

<CardGroup cols={2}>
  <Card title="Frontend SDK" icon="browser" href="/build/sdk/frontend">
    Set up browser-based deposits with wallet auth.
  </Card>

  <Card title="Server SDK" icon="server" href="/build/sdk/server">
    Set up server-side account management and sessions.
  </Card>

  <Card title="Deposits & Withdrawals" icon="arrow-right-arrow-left" href="/build/sdk/transactions">
    Quote and execute deposits, withdrawals, and cross-chain flows.
  </Card>

  <Card title="SDK Reference" icon="book" href="/build/sdk/reference">
    Auth, accounts, balances, error codes, and type definitions.
  </Card>
</CardGroup>
