
Security News
/Research
Fake Corepack Site Distributes Infostealer and Proxyware to Developers
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.
@knine-sdk/react
Advanced tools
React helpers for Knine Finance projects. Part of Knine JS SDK
yarn add @knine-sdk/react
contractHooksFactory creates set of hooks, which return RPC and Web3 contracts.
// use typechain package to generate factories for your contracts
import { YOUR_ABI_FACTORY } from 'your/abi/folder';
import { contractHooksFactory } from '@knine-sdk/react';
import { CHAINS, TOKENS } from '@knine-sdk/constants';
const getMyContractAddress = (chainId) => {
// should return contract address
};
const { useContractRPC, useContractWeb3 } = contractHooksFactory(
YOUR_ABI_FACTORY,
getMyContractAddress,
);
useSTETHContractRPC();
useSTETHContractWeb3();
useWithdrawalQueueContractRPC();
useWithdrawalQueueContractWeb3();
hooksFactory binds a token address to the ERC20 hooks and returns an object of them. The factory function takes a callback, that uses to get a token address by chain id.
import { hooksFactory } from '@knine-sdk/react';
const getMyContractAddress = (chainId) => {
// should return contract address
};
const {
useTokenBalance,
useTotalSupply,
useDecimals,
useAllowance,
useApprove,
} = hooksFactory(getMyContractAddress);
useSTETHBalance()
useSTETHTotalSupply()
useSTETHDecimals()
useSTETHAllowance(spender: string)
useSTETHApprove(amount: BigNumber, spender: string, wrapper: UseApproveWrapper)
To use ERC20 hooks, your app must be wrapped with <ProviderSDK />.
import { ProviderSDK } from '@knine-sdk/react';
import { CHAINS } from '@knine-sdk/constants';
const supportedChainIds = [CHAINS.Mainnet, CHAINS.Goerli];
const defaultChainId = CHAINS.Mainnet;
const providerRpc = getRpcProvider(
CHAINS.Goerli,
`/api/rpc?chainId=${CHAINS.Goerli}`,
);
const providerMainnetRpc = getRpcProvider(
CHAINS.Mainnet,
`/api/rpc?chainId=${CHAINS.Mainnet}`,
);
const App = ({ children }) => {
const { chainId, providerWeb3 } = FromYourLibrary; // web3-react for example
return (
<ProviderSDK
chainId={chainId || defaultChainId}
supportedChainIds={supportedChainIds}
providerRpc={providerRpc}
providerMainnetRpc={providerMainnetRpc}
providerWeb3={providerWeb3}
>
{children}
</ProviderSDK>
);
};
All request hooks accept SWR config as optional last argument.
import { useTotalSupply } from '@knine-sdk/react';
const Component = () => {
const token = 'token address';
const { data, loading } = useTotalSupply(token, { isPaused: !token });
const totalSupply = data?.toString();
return <div>{loading ? 'loading...' : totalSupply}</div>;
};
import { useTokenBalance } from '@knine-sdk/react';
const Component = () => {
const token = 'token address';
const account = 'account address';
const { data, loading } = useTokenBalance(token, account);
const balance = data?.toString();
return <div>{loading ? 'loading...' : balance}</div>;
};
import { useAllowance } from '@knine-sdk/react';
const Component = () => {
const token = 'token address';
const spender = 'spender address';
const { data, loading } = useAllowance(token, spender);
const balance = data?.toString();
return <div>{loading ? 'loading...' : balance}</div>;
};
import { useApprove } from '@knine-sdk/react';
import { BigNumber } from '@ethersproject/bignumber';
const Component = () => {
const amount = BigNumber.from(10);
const token = 'token address';
const spender = 'spender address';
const { approve } = useApprove(amount, token, spender);
return <button onClick={approve}>Approve</button>;
};
import { useDecimals } from '@knine-sdk/react';
const Component = () => {
const token = 'token address';
const { data, loading } = useDecimals(token);
return <div>{loading ? 'loading...' : data}</div>;
};
useLidoSWR hook is a wrapped useSWR. The hook additionally returns:
update function, which implements mutate(undefined, true)loading and initialLoading flagsimport { useLidoSWR } from '@knine-sdk/react';
const Component = () => {
const { data, loading } = useLidoSWR('/data', fetcher);
return <div>{loading ? 'loading...' : data}</div>;
};
Immutable version of useLidoSWR. It has the same API interface as the normal hook.
useLidoSWRImmutable('/data', fetcher);
// equal to
useLidoSWR('/data', fetcher, {
dedupingInterval: 86_400_000,
revalidateOnFocus: false,
revalidateOnReconnect: false,
});
useLidoSWR for contracts
import { useContractSWR } from '@knine-sdk/react';
import { CHAINS, TOKENS } from '@knine-sdk/constants';
const Component = () => {
const accountAddress = 'your address';
const tokenAddress = getTokenAddress(CHAINS.Mainnet, TOKENS.STETH);
const contractRpc = getERC20Contract(tokenAddress, providerRpc);
const { data, loading } = useContractSWR({
contract: contractRpc,
method: 'balanceOf',
params: [accountAddress],
});
const balance = data?.toString();
return <div>{loading ? 'loading...' : balance}</div>;
};
useLidoSWR over contract.estimateGas[method]
import { useContractEstimateGasSWR } from '@knine-sdk/react';
import { CHAINS, TOKENS } from '@knine-sdk/constants';
const Component = () => {
const { data, loading } = useContractEstimateGasSWR({
contract: myContractInstance,
method: 'myMethod',
params: ['argument'],
});
const gas = data?.toString();
return <div>{loading ? 'loading...' : gas}</div>;
};
useLidoSWR for RPC provider
import { useEthereumSWR } from '@knine-sdk/react';
const Component = () => {
const { data, loading } = useEthereumSWR({ method: 'getGasPrice' });
const gasPrice = data?.toString();
return <div>{loading ? 'loading...' : gasPrice}</div>;
};
import { useEthereumBalance } from '@knine-sdk/react';
const Component = () => {
const { data, loading } = useEthereumBalance();
const balance = data?.toString();
return <div>{loading ? 'loading...' : balance}</div>;
};
import { useFeeHistory } from '@knine-sdk/react';
const Component = () => {
const { data, loading } = useFeeHistory({ blocks: 1024 });
const { oldestBlock, baseFeePerGas, gasUsedRatio } = data;
return <div>{loading ? 'loading...' : oldestBlock}</div>;
};
import { useFeeAnalytics } from '@knine-sdk/react';
const Component = () => {
const { percentile, loading } = useFeeAnalytics({ blocks: 1024 });
return <div>{loading ? 'loading...' : percentile}</div>;
};
import { useEthPrice } from '@knine-sdk/react';
const Component = () => {
const { data, loading } = useEthPrice();
const ethPrice = data?.toString();
return <div>{loading ? 'loading...' : ethPrice}</div>;
};
import { useTxPrice } from '@knine-sdk/react';
const Component = () => {
const gasLimit = 10_000;
const { data, loading } = useTxPrice(gasLimit);
const txPrice = data?.toString();
return <div>{loading ? 'loading...' : txPrice}</div>;
};
import { useTokenToWallet } from '@knine-sdk/react';
const Component = () => {
const token = 'token address';
const { addToken } = useTokenToWallet(token);
return <button onClick={addToken}>Add token</button>;
};
import { useLocalStorage } from '@knine-sdk/react';
const Component = () => {
const initialValue = null;
const [value, setValue] = useLocalStorage('unique-key-in-LS', initialValue);
return <button onClick={() => setValue(2)}>{value}</button>;
};
import { useDebounceCallback } from '@knine-sdk/react';
const Component = () => {
const debounced = useDebounceCallback(callback);
};
FAQs
React helpers for Knine Finance projects. Part of Knine JS SDK
The npm package @knine-sdk/react receives a total of 5 weekly downloads. As such, @knine-sdk/react popularity was classified as not popular.
We found that @knine-sdk/react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
A fake corepack.org site is impersonating the Node.js tool and delivers an infostealer and proxyware to developers who download it.

Research
/Security News
A large-scale campaign abused GitHub Actions in compromised repositories to exploit CVE-2026-41940 in cPanel and WHM and steal server credentials.

Security News
Five frontier LLMs generated the same nonexistent package names, leaving 53 available for potential slopsquatting across PyPI and npm.