Wallet Hooks
React hooks for interacting with connected wallets.
React Hooks allow function components to have access to state and other React features. With Mesh Hooks, you can easily interact and access wallet data.
useWallet Hook
Provide information on the current wallet's state, and functions for connecting and disconnecting user wallet.
wallet
is a Browser Wallet instance, which expose all CIP wallets functions from getting assets to signing tranasction.
connected
, a boolean, true
if user's wallet is connected.
name
, a string, the name of the connect wallet.
connecting
, a boolean, true
if the wallet is connecting and initializing.
connect(walletName: string)
, a function, provide the wallet name to connect wallet. Retrive a list of available wallets with useWalletList()
.
disconnect()
, a function, to disconnect the connected wallet.
error
, returns the error object if any error occurs during wallet connection, such as "account not set".
Interact with user's wallet
Connected?: Not connected
Connecting wallet?: No
Name of connected wallet:
useWalletList Hook
Returns a list of wallets installed on user's device.
You can define the NuFi network to connect to by adding the network
prop.
List of wallets installed on user's device
useAddress Hook
Return address of connected wallet.
accountId
is an optional parameter, that allows you to choose which address to return.
List of wallets installed on user's device
useAssets Hook
Return a list of assets in connected wallet from all UTXOs.
List assets of connected wallet
useLovelace Hook
Return amount of lovelace in wallet.
Fetch the lovelace balance of the connected wallet
useNetwork Hook
Return the network of connected wallet.
Fetch the network of the connected wallet