1.0.0 • Published 2 years ago

@cuonghx.gu-tech/gu-wallet-connector v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Overview

@gusdk/gu-wallet-connector provide hooks to connect, interactive Ethereum network

Getting started

Install package

  npm install @gusdk/gu-wallet-connector

Usage

App.tsx

import * as React from 'react'
import * as ReactDOM from 'react-dom/client'

import { App } from './App'
import reportWebVitals from './reportWebVitals'
import { GUWalletConnectorProvider, InjectedConnector, createClient } from '@gusdk/gu-wallet-connector'

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)

const client = createClient({
  connectors: [new InjectedConnector()]
})

root.render(
  <GUWalletConnectorProvider client={client}>
    <App />
  </GUWalletConnectorProvider>,
)

reportWebVitals()

Component

import { useChainId, ConnectModal, useAccount, useSwitchNetwork } from '@gusdk/gu-wallet-connector'

export function App() {
  const chainId = useChainId()
  const account = useAccount()
  const { switchNetwork } = useSwitchNetwork()

  return (
    <>
      <ConnectModal />
      <p>chainId: {chainId}</p>  
      <p>Account: {account}</p>

      <button onClick={() => switchNetwork(99999)}>switch to gu sandbox</button>
    </>
  )
}
1.0.0

2 years ago

0.9.7

2 years ago

0.9.5

2 years ago

0.9.4

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.9.0

2 years ago