npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@terminusbet/stake-vote-sdk

v1.2.5

Published

A simple SDK for interacting with terminusbet governance

Readme

StakeVoteSDK README

Installation

npm i @terminusbet/stake-vote-sdk

Notice (for front-end developers)

If you encounter an error regarding the crypto module when building a front-end project with frameworks such as React, Vue, or Next.js, consider installing a polyfill (for example, the node-polyfills plugin) or adding a crypto-browserify alias to your build configuration.

For example:

import { nodePolyfills } from 'vite-plugin-node-polyfills'

plugins: [
    nodePolyfills({
       include: ['crypto'],
    }),
],

OR

resolve: {
    alias: {
      crypto: 'crypto-browserify',
    }
},

StakeVoteSDK transaction

Get StakeVoteSDK transaction-related methods.

getStakeTransactions

async getStakeTransactions(
    user: PublicKey,
    stakePoolState: PublicKey,
    amount: BN
): Promise<Transaction>
  • Stake to get voting rights
  • Parameters:
    • user: The public key of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to stake.
  • Returns: A promise that resolves to a Transaction.

getStakeAddTransactions

async getStakeAddTransactions(
    user: PublicKey,
    stakePoolState: PublicKey,
    amount: BN,
    addType: number
): Promise<Transaction>
  • Increase the stake to get more voting rights
  • Parameters:
    • user: The public key of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to stake.
    • addType: Mint amount OR time.
  • Returns: A promise that resolves to a Transaction.

getStakeWithdrawTransactions

async getStakeWithdrawTransactions(
    user: PublicKey,
    stakePoolState: PublicKey,
    amount: BN
): Promise<Transaction>
  • Withdraw staked tokens
  • Parameters:
    • user: The public key of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to withdraw.
  • Returns: A promise that resolves to a Transaction.

getAutoVoteTransactions

async getAutoVoteTransactions(
    user: PublicKey,
    ballotBoxState: PublicKey,
    amount: bigint,
    slippage = 500n
): Promise<Transaction> 
  • Voting by custom amount
  • Parameters:
    • user: The public key of the user.
    • ballotBoxState: The public key of the ballot box.
    • amount: Amount of mint to vote.
    • slippage: Minimum number of voting rights to be accepted.
  • Returns: A promise that resolves to a Transaction.

getAutoWholeVoteTransactions

async getAutoWholeVoteTransactions(
    user: PublicKey,
    ballotBoxState: PublicKey
): Promise<Transaction>
  • The program automatically casts all votes
  • Parameters:
    • user: The public key of the user.
    • ballotBoxState: The public key of the ballot box.
  • Returns: A promise that resolves to a Transaction.

getRewardReceiveTransactions

async getRewardReceiveTransactions(
    user: PublicKey,
    rewardUseBallotBox: PublicKey
): Promise<Transaction>
  • Get Rewards
  • Parameters:
    • user: The public key of the user.
    • rewardUseBallotBox: The public key of the ballot box.
  • Returns: A promise that resolves to a Transaction.

getBatchRewardReceiveTransactions

async getBatchRewardReceiveTransactions(
    user: PublicKey,
    rewardUseBallotBoxs: PublicKey
): Promise<Transaction>
  • Get rewards from multiple voting boxes in batches
  • Parameters:
    • user: The public key of the user.
    • rewardUseBallotBoxs: The public key of the ballot boxes.
  • Returns: A promise that resolves to a Transaction.

Some preview methods for account

// Get the staking pool list
async getStakePoolStates(): : Promise<ProgramAccount<{
    stakePeriod: BN;
    rewardGrowBy: BN;
    growReduceBy: BN;
    decimal: number;
    rewardGrowMinBy: BN;
}>[]>

// Get all the user's voting rights
async getUserVouchers(user: PublicKey): Promise<{
    userVouchers: bigint;
    decimal: number;
}>

// Get users can receive rewards
async getUserRewards(ballotBoxState: PublicKey, user: PublicKey): Promise<{
  userRewards: bigint;
  rewardMint: PublicKey;
}>

// Get the staking pool config
async getStakePoolStateAccount(
  stakePoolState: PublicKey
): Promise<StakePoolState | null>

// Get user voting information
async getUserVoteStateAccount(
  ballotBoxState: PublicKey,
  user: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<UserVoteState | null>

// Get the voting details of a user in a staking pool
async getUserStakeVoteStateAccount(
  stakePoolState: PublicKey,
  user: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<UserStakeVoteState | null>

// Get the user's received reward data
async getUserRewardStateAccount(
  stakePoolState: PublicKey,
  user: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<UserRewardState | null>

// Get ballot box information
async getBallotBotStateAccount(
  ballotBot: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<BallotBotState | null>

// Get ballot box reward information
async getVoteRewardStateAccount(
  ballotBoxState: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<VoteRewardState | null>

// Get user's active ballot boxes
async getUserActiveBallotBoxStateAccount(
  stakePoolState: PublicKey,
  user: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<UserActiveBallotBoxState | null>

// Get global active ballot boxes
async getActiveBallotBoxStateAccount(
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<ActiveBallotBoxState | null>

// Get user's active ballot boxes
async getUserActiveBallotBoxStateAccount(
  stakePoolState: PublicKey,
  user: PublicKey,
  commitment: Commitment = DEFAULT_COMMITMENT
): Promise<UserActiveBallotBoxState | null>

// Get the lock amount for the staked pool
async lockedAmount(
  stakePoolState: PublicKey,
  user: PublicKey
): Promise<BN>

StakeVoteSDK Class

The StakeVoteSDK class provides methods for interacting with the Bet protocol. Below are the method signatures and descriptions.

stake

async stake(
  user: Keypair,
  stakePoolState: PublicKey,
  amount: BN,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to stake.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.

stakeAdd

async stakeAdd(
  user: Keypair,
  stakePoolState: PublicKey,
  amount: BN,
  addType: number,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to stake.
    • addType: Mint amount OR time.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.

stakeWithdraw

async stakeWithdraw(
  user: Keypair,
  stakePoolState: PublicKey,
  amount: BN,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • stakePoolState: Staking pool public key corresponding to different staking periods.
    • amount: Amount of mint to withdraw.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.

vote

async vote(
  user: Keypair,
  ballotBoxState: PublicKey,
  amount: bigint,
  slippage: bigint,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • ballotBoxState: The public key of the ballot box.
    • amount: Amount of mint to vote.
    • slippage: The slippage of voting rights to be accepted.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.

voteWhole

async voteWhole(
  user: Keypair,
  ballotBoxState: PublicKey,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • ballotBoxState: The public key of the ballot box.
    • isWhole: Whether to invest all holdings.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.

rewardReceive

async rewardReceive(
  user: Keypair,
  rewardUseBallotBox: PublicKey,
  priorityFees?: PriorityFee,
  commitment: Commitment = DEFAULT_COMMITMENT,
  finality: Finality = DEFAULT_FINALITY
): Promise<TransactionResult>
  • Parameters:
    • user: The Keypair of the user.
    • rewardUseBallotBox: The public key of the reward ballot box.
    • priorityFees: Priority fees (optional).
    • commitment: Commitment level (default: DEFAULT_COMMITMENT).
    • finality: Finality level (default: DEFAULT_FINALITY).
  • Returns: A promise that resolves to a TransactionResult.