codechain-sdk-stakeholder-helper
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

CodeChain SDK Stakeholder Helper

A JavaScript implementation for CodeChain stake token related custom actions and custom transactions

Features

It adds the following features to CodeChain SDK for JavaScript:

  • Get the list of stakeholders
  • Get the stake token balance of a stakeholder
  • Transfer stake tokens

How to

You first need to install the package.

# npm 
npm install codechain-sdk-stakeholder-helper
 
# yarn 
yarn add codechain-sdk-stakeholder-helper

Get the list of stakeholders

const SDK = require("codechain-sdk");
const { getCCSHolders } = require("codechain-sdk-stakeholder-helper");
 
const sdk = new SDK({
  server: "http://localhost:8080",
  networkId: "tc"
});
 
getCCSHolders(sdk)
  .then(holders => {
    // holders: PlatformAddress[]
    ...
  });

Get the stake token balance of a stakeholder

const sdk = ...
const { getCCSBalance } = require("codechain-sdk-stakeholder-helper");
 
getCCSBalance(sdk, "tccq9h7vnl68frvqapzv3tujrxtxtwqdnxw6yamrrgd")
  .then(balance => {
    // balance: U64
    ...
  })

Transfer stake tokens

const sdk = ...
const { createTransferCCSTransaction } = require("codechain-sdk-stakeholder-helper");
 
// Transfer 100 tokens to tccq94guhkrfndnehnca06dlkxcfuq0gdlamvw9ga4f
const tx = createTransferCCSTransaction(sdk, "tccq94guhkrfndnehnca06dlkxcfuq0gdlamvw9ga4f", 100);
const signedTx = tx.sign({ secret: "...", seq: "...", fee: "..." });
sdk.rpc.chain.sendSignedTransaction(signedTx)
  .then(txhash => {
    // txhash: H256
    ...
  });

Readme

Keywords

none

Package Sidebar

Install

npm i codechain-sdk-stakeholder-helper

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

8.14 kB

Total Files

5

Last publish

Collaborators

  • jjg_kodebox