1.0.9 • Published 1 year ago

metamask-hook-gambaru v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

:::::::Example Provider::::::

import { ProvideMetamask } from 'metamask-hook-gambaru'

<div>
  <ProvideMetamask>
    <Component />
  </ProvideMetamask>
</div>

:::::::Example Hook::::::

import { useMetamask } from 'metamask-hook-gambaru'

const {
    web3
    address,
    getAddressMetamask, 
    chainId, 
    getChainId, 
    loading, 
    chainName,
    setChainIdMetamask,
    errorAddress,
    warningMessage,
    notInstalled
  }: any = useMetamask()
  const handleSignIn = async (e: any) => {
    e.preventDefault()
    await getAddressMetamask()
  }
  const handleChain = async (e: any) => {
    e.preventDefault()
    await getChainId()
  }
  const handleSetNetwork = async (e: any) => {
    e.preventDefault()
    await setChainIdMetamask(
      '0x61',
      'Binance Smart Chain',
      'https://assets-cdn.trustwallet.com/blockchains/smartchain/info/logo.png',
      'BNB',
      'BNB',
      18,
      'https://data-seed-prebsc-1-s1.binance.org:8545/',
      'https://testnet.bscscan.com/'
    )
  }
<div>
  <p><strong>{loading ? 'NoAddress' : address}</strong></p>
  <p><strong>{chainId}</strong></p>
  <p><strong>{chainName}</strong></p>
  <button onClick={handleSignIn}>getAddress</button>
  <button onClick={handleChain}>getChainId</button>
  <button onClick={handleSetNetwork}>setChaiId</button>
</div>  
1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago