rbw

react-binance-wallet

A library helps client connect to wallet extension like Metamask, Binance Chain

Showing:

Popularity

Downloads/wk

107

GitHub Stars

7

Maintenance

Last Commit

4mos ago

Contributors

0

Package

Dependencies

4

Size (min+gzip)

23.9KB

License

MIT

Type Definitions

Tree-Shakeable

Yes?

Categories

Readme

React Binance Wallet

A library helps the client connect to wallet extensions like Metamask, Binance Chain. This project based on source code of use-wallet

NPM JavaScript Style Guide

Install

npm install --save react-binance-wallet

yarn add react-binance-wallet

Usage

index

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import { WalletProvider } from 'react-connect-wallet'

ReactDOM.render(<WalletProvider><App /></WalletProvider>, document.getElementById('root'))

App

import React from 'react'
import {useWallet} from 'react-connect-wallet'

const App = () => {
  const { account, connect, reset, status, error, balance, chainId } = useWallet()
  return (
    <div>
      <h1>Binance Chain Connector</h1>
      {status === 'disconnected' ? (
        <>
        <button style={{ display: 'block', marginBottom: 16 }} onClick={() => connect('injected')}>Connect Metamask</button>
        <button style={{ display: 'block' }} onClick={() => connect('bsc')}>Connect Binance Chain Wallet</button>
        </>
      ) : (
        <button onClick={() => reset()}>Disconnect</button>
      )}
      { error?.message }
      { chainId != null && <p>chainId: {chainId}</p> }
      {account && <p>Connected as {account}</p>}
      {Number(balance) >= 0 && <p>{balance}</p>}
    </div>
  )
}

export default App

License

MIT © andoanwkm

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100