[v7.0.0] Hive-tx - JavaScript/TypeScript library for Hive Blockchain
This is a technical post for developers.
What is hive-tx? It is a lightweight and complete TypeScript/JavaScript toolkit for building on Hive with minimal dependencies.
v7.0.0
Added more features but also reduced the overall size of the library. I'll add more QoL features going forward. But for now, I think this is a good place for a stable release.
The highlight of the new version for me is callWithQuorum() which cross-checks the API result with multiple nodes. Trusting one single public node in sensitive tasks is a bit risky. With this, your confidence in the data can be quite high. The function rotates the nodes and calls random nodes every time and return the result once enough nodes (passed as quorum to function) agree on the result. By default quorum is 2. Meaning two nodes must agree on the result.
Example call:
const accounts = await callWithQuorum('condenser_api.get_accounts', [['username']], 2)
console.log('Account:', result[0])
Hopefully I will be able to maintain and improve this library further. There have been a lot of changes that can break the older apps. v7.0.0 requires node version 20+. So test and let me know. Feature requests are welcome.
Here is the rough list of the changes:
Major Changes
Complete TypeScript rewrite of the library with significant API improvements and breaking changes.
Added
- TypeScript Support: Complete rewrite in TypeScript with full type definitions
- Type-Safe Operations: Added comprehensive types for all 46 Hive blockchain operations
- JSDoc Documentation: All methods now include detailed JSDoc comments
- New API Methods:
callRPC(): Simplified JSON-RPC calls with automatic retry and failovercallREST(): Type-safe REST API calls with full endpoint typingcallWithQuorum(): Cross-check results with multiple nodes for enhanced reliability (JSON-RPC call)
- Enhanced Transaction API:
Transaction.addOperation(): New async method for adding operationsTransaction.checkStatus(): Check transaction status after broadcasting- Support for
checkStatusparameter inbroadcast()to wait for block inclusion
- Multiple Build Targets:
- ES Module (ESM) build with source maps and declarations
- CommonJS (CJS) build for Node.js compatibility
- Browser UMD build (minified, ~29KB gzipped)
- Comprehensive Testing:
- Operation tests validating transaction serialization
- Coverage tests for all major functionality
- Automated testing against live Hive blockchain
- Enhanced Documentation:
docs/QUICKSTART.md: Quick start guide for beginnersdocs/EXAMPLES.md: Comprehensive usage examples- Updated README with clear examples and migration guide
Changed
- Breaking:
tx.create()replaced withawait tx.addOperation(opName, opBody) - Breaking:
call()replaced withcallRPC()- returns result directly instead of JSON-RPC wrapper - Breaking:
callRPC()now throwsRPCErroron errors instead of returning{error} - Breaking:
Transaction.broadcast(timeout?, retry?)signature changed toTransaction.broadcast(checkStatus?) - Breaking: All timeout values changed from seconds to milliseconds
- Breaking: All expiration values changed from seconds to milliseconds
- Breaking:
new Transaction(transaction)constructor changed tonew Transaction({transaction, expiration}) - Breaking:
config.node(string) changed toconfig.nodes(array) - Breaking: Removed
Transaction.signedTransaction- signatures now available onTransaction.transaction - Breaking: Removed
config.healthcheckInterval - Improved: Better error messages and error handling throughout
https://github.com/mahdiyari/hive-tx
https://www.npmjs.com/package/hive-tx
Consider giving a star on GitHub repository ;P
Leave [v7.0.0] Hive-tx - JavaScript/TypeScript library for Hive Blockchain to:
Read more #hive posts
Best Posts From Mahdi Yari
We have not curated any of mahdiyari's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Mahdi Yari
- Witness update - 4/22
- Dark Souls 3
- Hive Bridge - 1.0.0-beta.1
- [v7.0.0] Hive-tx - JavaScript/TypeScript library for Hive Blockchain
- Rant 1.0
- [Proposal] Public HAF database & HafSQL maintenance
- [Update] Public HAF, HafSQL, Hivemind, and Hafbe database
- Witness update - Public nodes update
- TypeScript - Web Development
- HafSQL public node update
- [Docker compose] How to run a hived node / seed node / witness node
- HafSQL update 2.0.0-rc1 - Breaking changes
- [Update] hafsql.mahdiyari.info is back online - sort of
- [UPDATE] & [Downtime] "hafsql.mahdiyari.info" will be down for 2 days
- [Proposal] Public HAF/HafSQL database maintenance & development of HafSQL
- Witness update
- Public HafSQL database on HAF
- DHF proposals that I don't support
- HBD interest rate - Hive economics
- Running Hivemind & HAfAH on HAF + Jussi - 2023