Reference
Environments
hive-tx supports Node.js, browsers, workers, and serverless runtimes.
Module formats
The package type is module. The package also ships CommonJS.
- ESM:
import { PrivateKey } from 'hive-tx' - CommonJS:
const { PrivateKey } = require('hive-tx')
Use version 7.2.1 or later. Version 7.2.0 CommonJS throws an error on key encoding.
Node.js
The engine field is node >= 20. The library uses fetch and AbortSignal.timeout.
Browser and CDN
Load dist/index.mjs. The file has no extra chunk. Crypto code is in the file.
Serverless
The build has no nested runtime packages. A Lambda or a Worker can load the file without bs58 or @noble/* in node_modules.
Do not change config.nodes in each concurrent invocation if those invocations share a process.
Tests
From 7.2.1 the published files are self-contained. Jest 30 can load hive-tx in the Node environment:
const { PrivateKey } = require('hive-tx')
test('derives a posting key', () => {
const pub = PrivateKey.fromLogin('alice', 'x', 'posting').createPublic().toString()
expect(pub.startsWith('STM')).toBe(true)
})
ESM Jest also works with NODE_OPTIONS=--experimental-vm-modules and a .mjs test file. Version 7.2.0 CommonJS fails in Jest because of a bs58 interop bug. Use 7.2.1 or later.