JSPM

@folks-finance/folks-staking-sdk

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29
  • Score
    100M100P100Q77802F
  • License MIT

The official JavaScript SDK for the $FOLKS Staking

Package Exports

  • @folks-finance/folks-staking-sdk
  • @folks-finance/folks-staking-sdk/package.json

Readme

@folks-finance/folks-staking-sdk

License: MIT CI NPM version Downloads

JavaScript SDK for Folks staking.

Table of Contents

Getting Started

Installation

Package manager

Using npm:

npm install @folks-finance/folks-staking-sdk

Using yarn:

yarn add @folks-finance/folks-staking-sdk

Using pnpm:

pnpm add @folks-finance/folks-staking-sdk

Using bun:

bun add @folks-finance/folks-staking-sdk

SDK Structure and Usage

Initialize FolksCore before calling any other method. It accepts an optional Config object — if omitted, it defaults to the testnet configuration.

import { FolksCore, FolksStaking, CONFIG } from "@folks-finance/folks-staking-sdk";

// Use default testnet config
FolksCore.init();

// Or pass a custom config (e.g. mainnet once deployed)
FolksCore.init(CONFIG.TESTNET);

For write operations, also set a signer:

import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { bscTestnet } from "viem/chains";

const signer = createWalletClient({
  account: privateKeyToAccount("0x..."),
  chain: bscTestnet,
  transport: http(),
});

FolksCore.setSigner(signer);

SDK main component FolksStaking contains such methods:

  1. Read state (read):
    • getStakingPeriods()
    • getUserStakes(address)
    • getClaimable(address, stakeIndex)
    • activeTotalStaked()
    • activeTotalRewards()
    • isPaused()
  2. Submit transactions (write):
    • stake(periodIndex, amount, maxStakingDurationSeconds, maxUnlockDurationSeconds, minAprBps, referrer?)
    • stakeWithPermit(periodIndex, amount, maxStakingDurationSeconds, maxUnlockDurationSeconds, minAprBps, referrer?, permitDeadline?)
    • withdraw(stakeIndex)

stakeWithPermit is implemented according to ERC-2612, which allows users to submit only one transaction on chain. stake uses an approval transaction.

referrer is an optional field.

permitDeadline is an optional field (by default, the permit expires in 20 minutes).

Usage

Examples provided in ./examples folder.