JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16
  • Score
    100M100P100Q45129F
  • License MIT

🌊 🏄 ⚛️ React hooks for interacting with Etherscan. Supports Android/iOS/Web/Expo.

Package Exports

  • react-use-etherscan

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-use-etherscan) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-use-etherscan

🌊 🏄 ⚛️ React hooks for interacting with Etherscan. Supports Android/iOS/Web/Expo. This is a lifecycle-aware wrapper around etherscan-api.

🚀 Getting Started

Using yarn:

yarn add react-use-etherscan

🌱 Example

import React, { useState, useEffect } from 'react';
import EtherscanProvider, { useEtherscan, useBalance, useTransactionList } from "react-use-etherscan";

function TransactionList({ address }) {
  const [loading, transactions, error] = useTransactionList({ address });
  console.warn(loading, transactions, error);
  return null;
}

function BalanceOf({ address }) {
  const [loading, balance, error] = useBalance({ address });
  console.warn(loading, balance, error);
  return null;
}

function EthPrice() {
  const { stats } = useEtherscan();
  useEffect(
    () => (async () => {
      const {result} = await stats.ethprice();
      console.warn(result);
    })() && undefined,
    [stats],
  );
  return null;
}

export default function App() {
  const [address] = useState("0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae");
  return (
    <EtherscanProvider apiKey="your-api-key">
      <TransactionList address={address} />
      <BalanceOf address={address} />
      <EthPrice />
    </EtherscanProvider>
  );
}

✌️ License

MIT