@web3-ui/core
TypeScript icon, indicating that this package has built-in type declarations

0.8.1 • Public • Published

@web3-ui/core

A set of React components and hooks made for web3-specific use cases. Fully compatible with and built on top of ChakraUI.

This package is an opinionated combination of @web3-ui/components and @web3-ui/hooks.

yarn add @web3-ui/core

Getting started

At the root of your React app, wrap your app in the <Provider> component:

// _app.tsx (or the root of your app)
import { Provider, NETWORKS } from '@web3-ui/core';

function MyApp({ Component, pageProps }) {
  return (
    <Provider network={NETWORKS.rinkeby}>
      <Component {...pageProps} />
    </Provider>
  );
}

Components

This is the list of components the package currently provides:


Provider

The Provider component is a parent provider, wrapping the ComponentsProvider and the HooksProvider. You need to wrap this component around your entire App.

Usage

See Getting Started for an example.


ConnectWallet

ConnectWallet is a Button based component with the following behaviour:

When wallet is connected,

  • shows user's address or ENS
  • on click, disconnects wallet

When wallet is not connected,

  • allows the user to connect to their wallet via Metamask or WalletConnect

Usage

import { ConnectWallet } from '@web3-ui/core';

<ConnectWallet />;

TokenBalance

TokeBalance is a component that fetches and renders the balance of an ERC20 token for a given address.

import { TokenBalance } from '@web3-ui/core';

<TokenBalance
  accountAddress="0x503828976D22510aad0201ac7EC88293211D23Da"
  tokenAddress="0x6B175474E89094C44Da98b954EedeAC495271d0F"
  usdRate={0.9955}
/>;

Hooks

This package exports all the hooks provided by the @web3-ui/hooks package.

// Example
import { useWallet } from '@web3-ui/core';

const { connectWallet } = useWallet();

Package Sidebar

Install

npm i @web3-ui/core

Weekly Downloads

2

Version

0.8.1

License

MIT

Unpacked Size

25.8 kB

Total Files

18

Last publish

Collaborators

  • e-roy
  • with-heart
  • dhaiwat10