🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

staker-hooks

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staker-hooks

React Hooks for Ethereum and compatible chains

Source
npmnpm
Version
0.43.2
Version published
Weekly downloads
8
100%
Maintainers
1
Weekly downloads
 
Created
Source

staker-hooks

React Hooks for Ethereum and compatible chains

NPM

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

Usage

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;
}

License

MIT © gasolin

This hook is created using create-react-hook.

Keywords

ethereum

FAQs

Package last updated on 01 Apr 2021

Did you know?

Socket

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.

Install

Related posts