How knowledgr/knowledgr-js works
1. What this repo is
- steem-js is a client-side and server-side JavaScript SDK for the Steem blockchain.
- It is not a backend service; it is a library that wraps Steem RPC nodes and exposes higher-level API, auth, and transaction-broadcast functions.
2. Top-level public surface
- The main entrypoints are src/index.js for Node/CommonJS and src/browser.js for browser builds.
- These aggregate the main namespaces exposed to consumers: api, auth, broadcast, formatter, and config.
3. RPC/API subsystem
- src/api/ is the read/query layer for blockchain data.
- methods.js defines the RPC methods, while transports/ contains the concrete network adapters.
- transports/http.js and transports/ws.js are the two transport boundaries; both sit behind transports/base.js and are selected through transports/index.js.
4. Network/data flow to Steem nodes
- Application code calls steem.api.* methods.
- Those methods are serialized into RPC requests and sent through HTTP or WebSocket transport.
- The library talks to external Steem RPC endpoints such as api.steemit.com, node.steem.ws, and this.piston.rocks.
5. Auth and cryptography subsystem
- src/auth/ is the signing and key-management layer.
- src/auth/ecc/ is a self-contained crypto package for key generation, signing, hashing, AES, signatures, and address handling.
- src/auth/memo.js handles memo encryption/decryption, which is a distinct auth concern from transaction signing.
6. Serialization subsystem
- src/auth/serializer/ is another major boundary: it converts Steem operations and types into the chain’s canonical serialized form.
- It includes type definitions, operation templates, object-id parsing, precision/number helpers, and validation.
- This layer is used by broadcasting and by any code that needs chain-compatible binary/structured payloads.
7. Broadcast subsystem
- src/broadcast/ builds and submits signed blockchain operations.
- operations.js and param_types.js define the supported transaction operations and how their arguments are shaped.
- helpers.js and the top-level broadcast API coordinate signing plus submission through the API layer.
8. End-to-end transaction flow
- For writes, the flow is: consumer code → broadcast → auth/serializer → signed transaction → api transport → Steem RPC node.
- For reads, the flow is simpler: consumer code → api → transport → Steem RPC node → response back to the caller.
9. Formatting and utility layer
- src/formatter.js and src/utils.js provide presentation and convenience helpers, such as reputation formatting and general-purpose transforms.
- These are not network-facing; they sit above the raw API/auth layers and normalize blockchain data for app use.
10. Environment/build boundaries
- The repo supports both Node and browser usage.
- webpack.config.js and webpack/ build browser bundles; examples/webpack-example/ shows consumption from a bundled frontend.
- browser.js is the browser-specific entry, which is an important architectural split from the Node entry.
11. Examples as integration references
- examples/ contains concrete usage paths for key auth, posting, multisig, vote broadcast, streaming, and HTML/browser demos.
- These examples show the library’s intended integration points rather than additional subsystems.
12. Tests reflect the main seams
- test/ covers crypto, key formats, memo handling, serializer/types, broadcast, API behavior, and browser usage.
- The test layout mirrors the architecture: network/API, auth/crypto, serialization, and end-to-end broadcast are all separate seams.
13. Overall architecture to diagram
- A useful diagram would show a central SDK façade feeding three core internal domains: API/RPC, Auth/Crypto+Serializer, and Broadcast.
- Around that core are environment-specific entrypoints for Node and browser, plus external Steem RPC nodes as the only runtime dependency.
Main entry points: src/index.js SDK entry · browser.js Browser entry · broadcast/index.js Broadcast facade · api/index.js API facade
Components 23
Entry points
Runtime-facing SDK entry modules for Node and browser consumers.
- SDK entry · CommonJS/Node public surface that aggregates the main namespaces.
src/index.js - Browser entry · Browser-specific public surface for bundled consumers.
src/browser.js - Config · Shared configuration surface for node selection and SDK behavior.
src/config.js - Formatter · Helpers that normalize blockchain data for display and app use.
src/formatter.js - Utils · General-purpose convenience transforms used across the SDK.
src/utils.js
API/RPC
Read/query layer and transport boundaries for Steem RPC endpoints.
- API facade · Public read/query namespace that invokes RPC methods through transports.
src/api/index.js - RPC methods · Method definitions and request shaping for Steem RPC calls.
src/api/methods.js - HTTP transport · HTTP boundary used to send RPC requests.
src/api/transports/http.js - WS transport · WebSocket boundary used to send RPC requests.
src/api/transports/ws.js - Transport base · Shared transport behavior beneath HTTP and WebSocket adapters.
src/api/transports/base.js - Transport select · Chooses or exposes the concrete transport implementation.
src/api/transports/index.js
Auth & serialization
Signing, memo crypto, and chain serialization boundary.
- Auth facade · Public signing and key-management namespace.
src/auth/index.js - Memo crypto · Memo encryption and decryption utilities.
src/auth/memo.js - ECC crypto · Key generation, hashing, signing, AES, and signature primitives.
src/auth/ecc/index.js - Serializer · Canonical serialization for operations and chain-compatible types.
src/auth/serializer/index.js
Broadcast
Transaction construction and submission flow.
- Broadcast facade · Public transaction construction and submission surface.
src/broadcast/index.js - Operations · Supported transaction operations and their structure.
src/broadcast/operations.js - Param types · Argument shaping for broadcast operations.
src/broadcast/param_types.js - Broadcast helpers · Helpers that coordinate signing and submission via the API layer.
src/broadcast/helpers.js
Build & examples
Browser bundling and usage examples.
- Webpack build · Browser bundle configuration and build pipeline.
webpack.config.js - Build helper · Webpack configuration helper used by the build setup.
webpack/makeConfig.js - Examples · Integration examples for auth, posting, voting, streaming, and browser usage.
examples
External
Steem RPC nodes consumed by the SDK.
- Steem RPC · External Steem blockchain nodes accessed over HTTP or WebSocket.
Connections 31
- SDK entry → API facade: exports · Main SDK entry exposes the read/query API.
- SDK entry → Auth facade: exports · Main SDK entry exposes signing and key management.
- SDK entry → Broadcast facade: exports · Main SDK entry exposes transaction broadcast APIs.
- SDK entry → Formatter: exports · Main SDK entry exposes formatting helpers.
- SDK entry → Config: exports · Main SDK entry exposes configuration.
- Browser entry → API facade: exports · Browser entry exposes the read/query API.
- Browser entry → Auth facade: exports · Browser entry exposes auth primitives.
- Browser entry → Broadcast facade: exports · Browser entry exposes transaction broadcast APIs.
- Browser entry → Formatter: exports · Browser entry exposes formatting helpers.
- Browser entry → Config: exports · Browser entry exposes configuration.
- API facade → RPC methods: uses · API facade maps consumer calls to RPC methods.
- API facade → Transport select: sends via · API facade sends requests through the selected transport.
- Transport select → HTTP transport: selects · Transport selector can resolve the HTTP adapter.
- Transport select → WS transport: selects · Transport selector can resolve the WebSocket adapter.
- HTTP transport → Transport base: extends · HTTP transport inherits shared transport behavior.
- WS transport → Transport base: extends · WebSocket transport inherits shared transport behavior.
- HTTP transport → Steem RPC: connects · HTTP transport talks to external Steem nodes.
- WS transport → Steem RPC: connects · WebSocket transport talks to external Steem nodes.
- Auth facade → ECC crypto: uses · Auth facade delegates cryptographic primitives to ECC.
- Auth facade → Memo crypto: uses · Auth facade provides memo crypto support.
- Broadcast facade → Broadcast helpers: uses · Broadcast facade coordinates signing and submission helpers.
- Broadcast facade → Operations: uses · Broadcast facade relies on supported operation definitions.
- Broadcast facade → Param types: uses · Broadcast facade uses parameter typing and shaping.
- Broadcast helpers → Auth facade: signs with · Broadcast helpers use auth for transaction signing.
- Broadcast helpers → Serializer: serializes with · Broadcast helpers use serializer for canonical payloads.
- Broadcast helpers → API facade: submits via · Broadcast helpers submit signed transactions through the API layer.
- Serializer → Broadcast facade: supports · Serializer provides chain-compatible encoding for writes.
- RPC methods → Steem RPC: targets · RPC method calls ultimately target external Steem nodes.
- Examples → SDK entry: demonstrates · Examples illustrate usage of the SDK entry surface.
- Webpack build → Browser entry: bundles · Webpack builds the browser entry into frontend bundles.
- Webpack build → Build helper: uses · Webpack configuration is composed through helper logic.