0.49.0 • Published 2 years ago
staker-hooks v0.49.0
staker-hooks
DEPRECATED: people interest in this package please consider to useDapp
React Hooks for Ethereum and compatible chains
Currently provide useEthscanBalance
and useEthscanTokensBalance
to query balances via eth-scan and expand the support chain to Ethereum, xDai, Binance Smart Chain, and Polygon (Matic POS chain).
Install
npm install --save staker-hooks
Get native and token balances
import React from 'react'
import {useEthscanBalance, useEthscanTokensBalance} from 'staker-hooks';
export const XdaiBalances = ({addresses, chainId}) => {
const [nativeLoading, nativeBalance] = useEthscanBalance(
addresses,
chainId, // can neglect if use ethereum chain
);
const [tokenLoading, tokenBalance] = useEthscanTokensBalance(
addresses,
chainId, // can neglect if use ethereum chain
);
if (nativeLoading || tokenLoading) {
return (<Text>Loading</Text>);
}
const balance = [...formatData(nativeBalance), ...formatData(tokenBalance)];
return balance.length > 0 ?
(<>
{balance.map(token => (
<View key={token.token}>
<Text>{token.token}</Text>
<Text>{token.balance}</Text>
</View>
))}
</>) :
null;
}
Get tokens price
import React from 'react'
import {useTokensPrice} from 'staker-hooks';
export const Balances = () => {
const [prices] = useTokensPrice(['ETH','BTC'])
return (
<Text>
{JSON.stringify(prices)}
</Text>
)
}
License
MIT © gasolin
This hook is created using create-react-hook.
0.49.0
2 years ago
0.48.0
3 years ago
0.47.0
3 years ago
0.46.1
3 years ago
0.46.0
3 years ago
0.44.3
3 years ago
0.44.2
3 years ago
0.44.0
3 years ago
0.43.2
3 years ago
0.43.1
3 years ago
0.43.0
3 years ago
0.42.3
3 years ago
0.42.2
3 years ago
0.42.1
3 years ago
0.42.0
3 years ago
0.41.3
3 years ago
0.41.2
3 years ago
0.41.1
3 years ago