@blend-money/node

中文文档
3.1.1发布于 2026/11/03TypeScriptES Module近 30 天下载 1.9万

npm version npm downloads per week [![npm

原始使用文档
文档目录12 节
  1. Install
  2. Quick Start
  3. Configuration
  4. API Reference
  5. Discovery
  6. Account Lookup
  7. Account Creation
  8. Scoped Client
  9. Amount Helpers
  10. Error Handling
  11. Development
  12. License

@blend-money/node

npm version npm downloads per week npm downloads per month

Server-side SDK for the Blend Protocol. API key authenticated for server-to-server integration.

Install

pnpm add @blend-money/node

Quick Start

import { BlendServerSdk } from "@blend-money/node";

const sdk = new BlendServerSdk({
  apiKey: "sk_live_...",
  accountTypeId: "your-account-type",
});

// 1. Discover what's available
const chains = await sdk.discover.depositChains();
const tokens = await sdk.discover.depositTokens(8453);

// 2. Look up an account by EOA address
const account = await sdk.lookupAccount("0x...");
// { accountId, safeAddress, chainsDeployed }

// 3. Or create one if it doesn't exist
const newAccount = await sdk.createAccount("0x...", 8453);

// 4. Get a scoped client for the account
const client = sdk.forAccount(account.accountId);

// 5. Use account data and session lifecycle
const balance = await client.account.balance();
const sessions = await client.sessions.list();

Configuration

const sdk = new BlendServerSdk({
  // Required
  apiKey: "sk_live_...", // Server-side API key (X-API-Key header)
  accountTypeId: "your-account-type", // Product identifier for URL routing

  // Optional
  baseUrl: "https://...", // API base URL override
  fiatCurrency: "EUR", // ISO 4217 code for multi-currency
  timeoutMs: 15000, // Request timeout (default: 15000)
  retries: 3, // Max retries for 429/5xx (default: 3)
});

API Reference

Discovery

No account scoping required.

const chains = await sdk.discover.depositChains();
// [{ chainId, name, displayName, iconUrl }]

const tokens = await sdk.discover.depositTokens(8453);
// [{ chainId, address, symbol, name, decimals, logoURI, price }]

const destinations = await sdk.discover.withdrawDestinations();
// [{ chainId, name, loanTokenAddress }]

const yieldData = await sdk.discover.yield();
// { accountTypeId, yieldBreakdown: [{ chainId, vaultAddress, breakdown, summary }] }

Account Lookup

const account = await sdk.lookupAccount("0x...");
// { accountId, safeAddress, chainsDeployed }

Account Creation

const account = await sdk.createAccount("0x...", 8453);
// { accountId, safeAddress, chainsDeployed }

Scoped Client

forAccount() returns a full BlendClient scoped to a specific account, with access to discovery, account data, and session lifecycle.

const client = sdk.forAccount(account.accountId);

// Account data
const balance = await client.account.balance();
const positions = await client.account.positions();
const returns = await client.account.returns();

// Safe management
const resolution = await client.account.safe.resolve(8453);
await client.account.safe.request(8453);

// Session lifecycle
const session = await client.sessions.createSession({ forceReset: true });
const quoted = await client.sessions.quoteDeposit(session.intentId, { ... });
const locked = await client.sessions.lock(session.intentId, { signerAddress: "0x..." });
const submitted = await client.sessions.submit(session.intentId, { txHashes: [...] });
const result = await client.sessions.execute(session.intentId, { ... });
const sessions = await client.sessions.list();
await client.sessions.cancel(session.intentId);

See the @blend-money/fe README for full documentation on account data, session lifecycle, amount helpers, and error handling — the scoped client API is identical.

Amount Helpers

Re-exported from @blend-money/core:

import { parseAmount, formatAmount } from "@blend-money/node";

const smallest = parseAmount("100.50", 6); // "100500000"
const human = formatAmount("100500000", 6); // "100.5"

Error Handling

All error types are re-exported from @blend-money/core:

import { SdkError, SESSION_ERROR_CODES } from "@blend-money/node";

try {
  await client.account.balance();
} catch (err) {
  if (err instanceof SdkError) {
    console.log(err.code); // e.g. "INTENT_NOT_FOUND"
    console.log(err.status); // HTTP status
    console.log(err.getUserMessage()); // human-readable message
    console.log(err.isRetryable()); // true for 429, 5xx, network errors
  }
}

Development

From the monorepo root:

pnpm install                                # Install all dependencies
pnpm --filter @blend-money/node build       # Build this package
pnpm --filter @blend-money/node dev         # Watch mode
pnpm --filter @blend-money/node test        # Run tests (interactive)
pnpm --filter @blend-money/node test:run    # Run tests (CI)
pnpm --filter @blend-money/node check-types # Type check

Or run pnpm build, pnpm test:run, etc. from the monorepo root to run across all packages.

License

MIT

版本与发布记录

@blend-money/node 共发布 15 个版本,首次发布于 2026/05/07;过去 12 个月发布了 15 个版本。

版本发布日期距今
3.1.1latest2026/11/035 天前
3.1.02026/10/051 个月前
3.0.12026/07/243 个月前
3.0.02026/07/233 个月前
2.0.02026/07/143 个月前
1.2.12026/07/044 个月前

关于 @blend-money/node 的常见问题

@blend-money/node 是什么?

[![npm

如何安装 @blend-money/node?

在项目目录运行 npm install @blend-money/node,或使用 pnpm add / yarn add / bun add。

@blend-money/node 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blend-money/node 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@blend-money/node 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.23.4 || ^24.22.1 || ^26.12.1。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@blend-money/node 可以商用吗?

@blend-money/node 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@blend-money/node 的下载量有多少?

根据 npm 官方下载统计,@blend-money/node 在 2026/10/09 – 2026/11/07 这 30 天内被下载 18,971 次,日均约 632 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blend-money/node 还在维护吗?

最新版本 3.1.1 发布于 2026/11/03(5 天前);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/05/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。