
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
Congratulations @mahdiyari! Your post has been a top performer on the Hive blockchain and you have been rewarded with this rare badge
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOPCheck out our last posts: