lib-sl
v0.0.7-alpha
Published
sl library
Downloads
11
Readme
Splinterlands Client Library - ALPHA
Please note that this is still an early version. Breaking changes will most likely occur. Use it at your own risk.
import { SplinterlandsClient } from 'lib-sl';
const main = async () => {
/**
* Create new Client
* Metadata for custom_json broadcasting could be set here: { json: { prefix: 'sm_' <== default, app: 'myslapp' } }
*/
const slClient = new SplinterlandsClient();
/**
* Login with hive-account + private key (could be also email + password)
* This saves the access-token within the client & re-uses when needed
*/
await slClient.login('myaccount', 'privatekey');
const result = await slClient.players.getPlayer('myaccount');
console.log('Player', result);
/**
* Create custom_json operations to be broadcasted to claim staking rewards + ranked/license rewards
*/
const ops = [slClient.players.claimStaking('myaccount', 'SPS'), slClient.players.claimRewards('myaccount')];
/**
* Broadcast to the chain via dhive-sl
*/
await slClient.broadcast(ops, 'myprivatepostingkey');
};
main();
Why?
The goal for this library is to provide a better and less error-prone way to interact with the Splinterlands API by returning the raw API data with typings. On top of that, the api data is then being converted to classes and improved upon, i.e. by adding relevant classes (card-details for cards or battles), converting string-arrays to real arrays, etc.
This library should also provide a better way to interact with & broadcast to Hive - i.e. to transfer-tokens, vote on proposals, etc.