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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ton-staking-sdk/react-kit

v0.0.14

Published

React hooks and components for TON staking contracts.

Downloads

32

Readme

@ton-staking-sdk/react-kit

React hooks and components for TON staking contracts.

Installation

We recommend using pnpm for installation to ensure consistent dependencies across the monorepo:

pnpm add @ton-staking-sdk/react-kit

Alternatively, you can use npm or yarn:

npm install @ton-staking-sdk/react-kit
or
yarn add @ton-staking-sdk/react-kit

Usage

Provider Setup

First, wrap your app with TONStakingProvider:

import { TONStakingProvider } from '@ton-staking-sdk/react-kit';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { sepolia } from 'viem/chains';

// Optional: Setup wallet client for write operations
const account = privateKeyToAccount('YOUR_PRIVATE_KEY');
const wallet = createWalletClient({
  account,
  chain: sepolia,
  transport: http(),
});

function App() {
  return (
    <TONStakingProvider
      rpcUrl="YOUR_RPC_URL"
      chainId={11155111}
      walletClient={wallet} // Optional: Include for write operations
    >
      <YourComponents />
    </TONStakingProvider>
  );
}

Read Operations

import {
  useAllOperatorsTotalStaked,
  useOperatorStake,
} from '@ton-staking-sdk/react-kit';

// Get total staked amount
function TotalStaked() {
  const { data, isLoading, error } = useAllOperatorsTotalStaked();
  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;
  return <div>Total Staked: {formatEther(data)} TON</div>;
}

// Get operator stake
function OperatorStake({ candidateAddress }) {
  const { data, isLoading, error } = useOperatorStake({ candidateAddress });
  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;
  return <div>Operator Stake: {formatEther(data)} TON</div>;
}

Write Operations

import { useStakeTON, useStakeWTON } from '@ton-staking-sdk/react-kit';
// Stake TON
function StakeTONButton({ candidateAddress, amount }) {
  const { stakeTON, isLoading, isPending, error, hash } = useStakeTON();
  const handleStake = async () => {
    try {
      const { hash } = await stakeTON({
        args: [candidateAddress, amount],
      });
      console.log('Transaction hash:', hash);
    } catch (err) {
      console.error('Staking failed:', err);
    }
  };
  return (
    <button onClick={handleStake} disabled={isLoading || isPending}>
      {isPending ? 'Confirming...' : isLoading ? 'Staking...' : 'Stake TON'}
    </button>
  );
}

// Stake WTON
function StakeWTONButton({ candidateAddress, amount }) {
  const { stakeWTON, isLoading, isPending, error, hash } = useStakeWTON();
  const handleStake = async () => {
    try {
      const { hash } = await stakeWTON({
        args: [candidateAddress, amount],
      });
      console.log('Transaction hash:', hash);
    } catch (err) {
      console.error('Staking failed:', err);
    }
  };
  return (
    <button onClick={handleStake} disabled={isLoading || isPending}>
      {isPending ? 'Confirming...' : isLoading ? 'Staking...' : 'Stake WTON'}
    </button>
  );
}

Available Hooks

Read Hooks

  • useAllCandidatesTotalStaked() - Get total staked amount across all operators
  • useCandidateStake({ candidateAddress }) - Get stake amount for specific operator
  • useUserStakeAmount({ candidateAddress, accountAddress }) - Get user's stake amount
  • useTONBalance({ account }) - Get TON balance of an account
  • useTONTotalSupply() - Get total supply of TON tokens
  • useExpectedSeig(candidateAddress, stakedAmount, account) - Calculate expected seigniorage rewards for a staked amount

Candidate Hooks

  • useAllCandidates() - Get list of all candidate addresses
  • useAllCandidatesNums() - Get total number of candidates
  • useCandidateByIndex(index) - Get candidate address by index
  • useClaimableL2Seigniorage({ candidateAddress }) - Get claimable seigniorage amount for a Layer2
  • useCheckCandidateType({ candidateAddress }) - Check the type of a candidate

CadnidateAddOn Hooks

  • useIsCandidateAddOn({ candidateAddress }) - Check if a candidate is an CandidateAddon
  • useOperatorManager({ candidateAddress }) - Get operator manager information
  • useRollupConfig({ operatorManagerAddress }) - Get rollup configuration for a candidate
  • useCheckL1BridgeDetail({ operatorManagerAddress }) - Get details of an L1 bridge
  • useL2SequencerAddress({ operatorManagerAddress }) - Get the L2 sequencer address for a candidate
  • useLayer2RewardInfo({ candidateAddress }) - Get Layer2 reward information from SeigManager
  • useTONBridgeTVL({operatorManagerAddress}) - Get the Total TON Value Locked (TVL) in the Bridge

Write Hooks

  • useStakeTON() - Stake TON/WTON tokens to an Candidate
  • useWithdrawTON() - Request and Withdraw staked TON/WTON tokens
  • useSeigniorageUpdate({ candidateAddress }) - Update seigniorage for an candidate
  • useClaimSeigniorage({ operatorManagerAddress }) - Claim seigniorage for a Sequencer

SDK Utility Hooks

  • useBlockNumber({ watch, pollingInterval }) - Get current block number with optional polling
  • useAccount() - Get connected account information without wagmi dependency
  • useClient() - Get publicClient and walletClient from SDK

Development

bash Build package pnpm build Run tests pnpm test Watch mode pnpm dev

License

MIT License