morphit/node_modules/@beblurt/dblurt/guide/examples.md

2.1 KiB

Examples

Question answered by this guide: where should developers find safe, reusable dblurt examples?

The canonical executable example catalog is ../examples/README.md. This guide explains the policy and points to that catalog instead of duplicating every row.

npm run docs:check validates example metadata and checks that every example file under examples/node, examples/typescript and examples/browser appears in the catalog. Add or remove examples there first, then update the catalog in the same change.

Example policy

  • Start with blockchain query examples.
  • Label runtime, safety, validation, required RPC and expected output in each example file.
  • Prefer real files in examples/ over long snippets in guides.
  • Do not hard-code private keys.
  • Keep broadcast examples out of the starter set unless they are explicitly safety-reviewed.

Canonical catalog

Use ../examples/README.md for:

  • the maintained list of examples;
  • expected output shapes;
  • validation levels;
  • runtime and safety labels;
  • example-specific RPC requirements.

Minimal CommonJS starter

For a short inline example, see Getting started.

For a reusable file, prefer the catalog entry for the current head-block example:

node examples/node/read-head-block.cjs

Minimal TypeScript starter

Use ../examples/typescript/read-account.ts as the first typed consumer example.

The guide in TypeScript explains the package declaration contract.

Browser starter

Use ../examples/browser/unpkg.html for a manual browser check.

The guide in Browser usage explains the browser bundle and runtime requirements.

Broadcast and signing

Broadcasting is intentionally not included in the first examples set.

Before adding or running broadcast examples, read: