npm.io
0.4.5 • Published 1 year ago

@le7el/web3_wallet

Licence
MPL-2.0
Version
0.4.5
Deps
9
Size
6.4 MB
Vulns
0
Weekly
0

Web3 Wallet

Libary to connect and interact with web3 wallets Supported wallet providers: metamask, wallet-connect

Installation

npm install @le7el/web3_wallet

Getting started

This library exposes multiple publicly accesible methods, which could help in different web3 wallet use cases

Typical library usage for connecting a wallet and listen for its changes:
import { useProvider, connectWallet, listenWallet } from '@le7el/web3_wallet'

useProvider('metamask')
  .then(connectWallet)
  .then(connectedWalletAddress => {
    console.log('wallet connection success')
  })
  .then(() => {
    // in case when you need to listen on wallet changes, like: account changed or network changed,
    // you'll also need to call listenWallet with approproate callbacks
    const onWalletChange = (newWalletAddress) => {}
    const onWalletError = (error) => {}

    listenWallet(onWalletChange, onWalletError)
  })
  .catch(error => {
    console.log('wallet connection failed')
  })

Keywords