react-binance-wallet
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.5 • Public • Published

    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

    Keywords

    none

    Install

    npm i react-binance-wallet

    DownloadsWeekly Downloads

    178

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    372 kB

    Total Files

    13

    Last publish

    Collaborators

    • andoanwkm