0.0.13 • Published 2 years ago

web3-react-hooks v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Web3 React Hooks

A set of convenience hooks for web3 actions in react.

Usage

Install using npm or yarn:

npm i -S web3-react-hooks

This module has react as a peer dependency, since it provices react hooks 🤷‍♂️

Example usage:

import React from 'react'
import { useAddress, useENS } from 'web3-react-hooks'

export default function UserProfile() {

    const address = useAddress()
    const ens = useENS()

    return <p>Welcome back { address.slice( 0, 10 ) }! { ens ? `Your ENS name ${ ens } looks good!` : `You should get a fancy ENS ;)` }</p>


}

Available hooks

All hooks have jsdoc declarations you can use to get more details on what they do.

Useful frontend hooks

  • useAddress: last known selected address
  • useENS: ENS address of currently connected account on currently connected network
  • useAvatar: returns uri of the current ENS avatar

Chain/wallet

  • useIsConnected: whether or not the Ethereum provider is connected to its RPC
  • useChainID: chain ID as hex value, e.g. 0x01 is Ethereum Mainnet

Generic interfaces

For a more elaborate demo, run npm start inside the demo directory.

Feature requests

Do you need a hook not in this list? Suggest a feature here.

Contributing

Pull requests are welcome! If you want to implement backwards-incompatible changes please check in first.

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago