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.
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:
Complete TypeScript rewrite of the library with significant API improvements and breaking changes.
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)Transaction.addOperation(): New async method for adding operationsTransaction.checkStatus(): Check transaction status after broadcastingcheckStatus parameter in broadcast() to wait for block inclusiondocs/QUICKSTART.md: Quick start guide for beginnersdocs/EXAMPLES.md: Comprehensive usage examplestx.create() replaced with await tx.addOperation(opName, opBody)call() replaced with callRPC() - returns result directly instead of JSON-RPC wrappercallRPC() now throws RPCError on errors instead of returning {error}Transaction.broadcast(timeout?, retry?) signature changed to Transaction.broadcast(checkStatus?)new Transaction(transaction) constructor changed to new Transaction({transaction, expiration})config.node (string) changed to config.nodes (array)Transaction.signedTransaction - signatures now available on Transaction.transactionconfig.healthcheckIntervalhttps://github.com/mahdiyari/hive-tx
https://www.npmjs.com/package/hive-tx
Consider giving a star on GitHub repository ;P