TypeScript
@beblurt/dblurt ships TypeScript declarations for the public package surface. Use this guide for import style, typed clients, examples and the boundary between guide-level explanations and exact API reference details.
For new documentation and application examples, prefer TypeScript with ESM-style imports.
Install and import
npm install @beblurt/dblurtimport { Client } from '@beblurt/dblurt';
const client = new Client(['https://rpc.blurt.blog']);Package metadata owns the declaration entrypoints. Do not copy the current package version or compiler smoke-test version into documentation; use package.json and CI validation as the source of truth.
A typed blockchain query
import { Client, type ExtendedAccount } from '@beblurt/dblurt';
const client = new Client(['https://rpc.blurt.blog']);
async function loadAccount(name: string): Promise<ExtendedAccount | undefined> {
const accounts = await client.condenser.getAccounts([name]);
return accounts[0];
}
const account = await loadAccount('beblurt');
console.log(account?.balance);This example uses a Layer 1 account query and does not require any private key.
Prefer option objects for complex helpers
Some helpers support historical positional signatures for compatibility. For new code, prefer option objects when a helper has pagination, nullable cursors, filters or observer values.
const posts = await client.nexus.getRankedPosts({
sort: 'trending',
tag: 'blurt',
limit: 10,
observer: null
});Option objects make call sites easier to review and safer to change.
Use exported enums and types
Import exported enums and types instead of passing undocumented string values.
import { BlockchainMode } from '@beblurt/dblurt';
const irreversible = await client.blockchain.getCurrentBlockNum(BlockchainMode.Irreversible);
console.log(irreversible);When exact literal unions, overloads or option fields matter, use the API reference rather than copying the shape into a guide.
Type-only imports
Use type imports when a symbol is only used at compile time:
import { Client, type ExtendedAccount } from '@beblurt/dblurt';This keeps application code clear and avoids implying that type-only symbols are runtime values.
Error typing
classifyError lets applications inspect stable metadata without depending on string matching.
import { classifyError, isDBlurtError } from '@beblurt/dblurt';
try {
await client.condenser.getAccounts(['beblurt']);
} catch (error) {
const metadata = classifyError(error);
if (metadata.retryable) {
// retry or fail over according to your application policy
}
if (isDBlurtError(error)) {
console.error(error.category, error.code);
}
}Do not log private keys, signed transactions with sensitive context or user secrets in error handlers.
CommonJS compatibility
The package still supports CommonJS consumers. Keep CommonJS examples on compatibility pages rather than guide pages, and use Package exports when you need runtime entrypoint details.
The preferred learning path remains TypeScript + ESM-style imports.
What this page intentionally does not duplicate
This guide does not duplicate:
- all exported interfaces;
- constructor overloads;
- every Nexus option object;
- operation tuple shapes;
- generated method signatures;
- compiler-version promises not declared in package metadata.
Those details belong to the generated API reference and package metadata.
Validation path
The documentation validation command compiles the TypeScript example path without emitting output:
npm run docs:checkProject tests also verify that the public declaration bundle is present and that test-framework ambient types do not leak into published declarations.
Validated examples
Related docs
API details
Use the API reference for exact exports, method signatures and option types:
