@blend-money/node
v1.1.4
Published
[](https://www.npmjs.com/package/@blend-money/node) [](https://www.npmjs.com/package/@blend-money/node) [![npm
Readme
@blend-money/node
Server-side SDK for the Blend Protocol. API key authenticated for server-to-server integration.
Install
pnpm add @blend-money/nodeQuick 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 checkOr run pnpm build, pnpm test:run, etc. from the monorepo root to run across all packages.
License
MIT
