Skip to main content
The frontend SDK (@blend-money/fe) handles wallet authentication, deposit/withdrawal quoting, and on-chain execution in the browser.

Quick-start flow

  1. Install @blend-money/fe and viem
  2. Create a BlendSdk instance with your publishable key and paymaster
  3. Sign in with sdk.signIn()
  4. Quote with sdk.quoteDeposit() or sdk.quoteWithdraw()
  5. Execute with sdk.execute(quote, { deriveSigner })

Install

Configuration

Use an Alchemy Gas Manager policy for Alchemy-backed chains:
Later entries replace earlier ones for the same chain. Execution throws VALIDATION_ERROR if the registry has no entry for a required chain. SDK 3.0.1 gets gas prices from the configured bundler. It does not call a Blend gas-price method.

Authentication

signIn

Signs the user in with SIWE. The first sign-in creates the account record and deterministic Safe address. It does not deploy the Safe on-chain.
chainId defaults to 1. It sets the SIWE message chain and does not deploy the Safe. Returns an AuthSession: Check chainsDeployed to see where the Safe is live. If you need the Safe on a chain that isn’t listed, request deployment:
See Safe deployment for the full pattern.

signOut

Revokes the JWT server-side and clears local state.

isSignedIn

Read-only boolean. true if a session is active.

session

Returns the current AuthSession. Throws SdkError with code AUTH_NOT_SIGNED_IN if not authenticated.

exportSession / restoreSession

Persist and restore sessions across page reloads.
Use sessionStorage, not localStorage. Clear the session when the wallet disconnects or the address changes.

Quoting

quoteDeposit

Quotes a deposit. Creates a session automatically if one doesn’t exist.
Returns a DepositQuote:

quoteWithdraw

Quotes a withdrawal. Blend picks which chains to pull funds from.
For a full exit, set isMaxWithdraw: true and amount: "0":
A full withdrawal redeems every source-chain position. For any withdrawal, partial or full, where a source chain differs from destinationChainId, Vault embeds Relay bridge calldata inside the atomic withdrawal transaction. The returned step list may not contain a separate bridge step, but the execution still routes those funds to the requested destination. Returns a WithdrawQuote:

Execution

execute

Locks the quote, submits transactions through the user’s Safe, and records their hashes. New sessions settle as soon as the API accepts the hashes. Legacy SUBMITTED sessions can still require polling.
deriveSigner is called once per action plan. For deposits, that means once. For withdrawals, once per source chain. Return clients configured for the requested chain. The wallet client must have an attached account whose address matches signerAddress. DeriveSignerResult: ExecuteResult:

Discovery

These methods are available on sdk.discover after sign-in. Every frontend route outside challenge and verify requires the SIWE bearer session.
See SDK Reference for response shapes.

Account data

These methods are available on sdk.account after sign-in.
See SDK Reference for response shapes.

Cancel in-flight requests

Every async HTTP method accepts RequestOptions as its last argument. Pass an AbortSignal when a user changes an input during live quoting.

Error handling

Every SDK method can throw SdkError. Catch it to get structured error info.
See SDK Reference for the full error codes table.

What to watch out for

Don’t create a new session to change the amount, token, or chain. Call the same quote method again while the session is OPEN. To switch between a deposit and withdrawal in the high-level frontend SDK, pass forceReset: true; this discards the opposite-type active session and starts a new one. Don’t store sessions in localStorage. Use sessionStorage and clear it when the wallet disconnects. Don’t treat onStatusChange as the final result. SDK 3.0.1 can emit the legacy-compatible "confirming" callback even when the API settles directly. Use the returned ExecuteResult, then use balances and positions to confirm indexed activity. Don’t ignore isContractSigner. If your users connect smart wallets (Coinbase Wallet, Safe), set it to true or signing will fail.

Deposits & Withdrawals

Full deposit and withdrawal flows with cross-chain routing.

SDK Reference

Auth, accounts, balances, error codes, and types.
Last modified on July 24, 2026