Archive post
Introducing: dhive-sl
If you've ever coded with Javascript/Typescript, you've probably stumbled upon 1 of 3 libraries: hive-js , hive-tx-js and dhive ; all great, but the latter being my personal favourite
If you've ever coded with Javascript/Typescript, you've probably stumbled upon 1 of 3 libraries: `hive-js`, `hive-tx-js` and `dhive`; all great, but the latter being my personal favourite.
For over half a year now, as part of my work at Splinterlands, I've been continuously developing a new version of dhive. Because as great as dhive is, I believe an amazing business, running on an amazing blockchan with an amazing community, needs an ... amazing library.
So with this said, I'm happy to announce that `dhive-sl`, brought to you by Splinterlands and myself, is now ready for _testing_!
_Please note that there might be more breaking changes introduced until a stable version is released. (currently on 2.0.0-prerelease.9)_
#### Info
- name: `dhive-sl`
- version: `2.0.0-prerelease.9`
- npm: https://www.npmjs.com/package/dhive-sl
- repo: https://github.com/steem-monsters/dhive-sl/tree/v2
Okay, but you might be asking yourself now:
### Why should I test this?
Here might be a few reasons:
1. It's now over 66% smaller than before (63.5kb vs 186.7kb gzipped)
2. It (should be) tree-shakable
3. Memo encoding is natively supported within dhive (async, thus requires await/then)
4. Hashing/crypto packages have been replaced with newer/better ones
5. Old unmaintained packages such as bytebuffer and ecurve have been added as native code and thus massively reduced in size.
6. Hive Engine is now natively supported `client.engine.blockchain.getLatestBlock()`
7. Types have been updated
8. Peakd Beacon is now supported (https://beacon.peakd.com/)
and much more.
Please note that there are breaking changes if you upgrade from `@hiveio/dhive`, but Typescript should display them for you.
I've also written some tests to test the compatibility between `dhive-sl` and `@hiveio/dhive`/`@hiveio/hive-js`.
[Compatibility tests](https://github.com/steem-monsters/dhive-sl/blob/v2/src/__tests__/compatibility.test.ts)
### Code Example
```
import { Client } from 'dhive-sl';
const main = async () => {
// Client
// Loads beacon nodes once if no nodes are provided or if all of them are unresponsive
const client = new Client()
// (Optional) const client = new Client({ nodes: ['api.hive.blog', 'api.deathwing.me', 'anyx.io'] })
// Getting data from Hive
const account = await client.database.getAccount('splinterlands')
// Encoding & decoding memos
const encoded = await client.memo.encode('test', 'pub-key-B', 'private-key-A')
const decoded = await client.memo.decode(encoded, 'private-key-B')
// Getting data from Hive Engine (layer2 of Hive)
const block = await client.engine.blockchain.getLatestBlock()
};
main();
```
### Size Comparison
##### dhive-sl

---
##### dhive

---
#### I found a bug, have a question or an issue
While I've of course developed dhive-sl for Splinterlands to have an amazing library to interact with Hive & Hive Engine. In the spirit of open source, giving back to the community and making it also easier for community developers to build cool stuff for Hive & Splinterlands, I'm also very much interested in hearing from you if you're a Javascript/Typescript developer.
So if you found a bug or an issue, please open a Github issue here: https://github.com/steem-monsters/dhive-sl/issues
If you have a question or feedback, I'm available on Discord, Mattermost as well as within the comments section.
With this said,
Happy New Year
Wolf