0.0.7-alpha • Published 8 months ago

lib-sl v0.0.7-alpha

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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.

0.0.7-alpha

8 months ago

0.0.6-alpha

9 months ago

0.0.5-alpha

10 months ago

0.0.4-alpha

1 year ago

0.0.3-alpha

1 year ago

0.0.2-alpha

1 year ago

0.0.1-alpha

1 year ago