0.3.3 • Published 1 month ago

@asterium-dev/use-cardano-wallet v0.3.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

use-cardano-wallet

A simple react hook to connect your application to cardano wallets. This library does not take care of transaction building. For that, you should use something like Lucid.

ℹ This library does not depend on cardano-serialization-lib, so you don't have to worry about big budle sizes!

Installation

npm i @asterium-dev/use-cardano-wallet
yarn add @asterium-dev/use-cardano-wallet

Basic usage

const {
  connect,
  isConnecting,
  isConnected,
  lovelaceBalance,
  address,
  network,
  selectedWallet,
  connectedWallet,
  api,
  disconnect,
  isRefetchingBalance,
  refetchBalance,
} = useCardanoWallet();

Example

Check out the example in this folder


API

useCardanoWallet(options?): ReturnVal

Parameters

NameTypeDefault value
optionsUseCardanoWalletOptionsdefaultOptions

UseCardanoWalletOptions:

NameTypeDescription
autoConnect?booleanSpecify if the connector should automatically try to connect to previously connected wallets. Relies on localStorage.
localStorageKey?stringSpecify a local storage key to store the connected wallet name

Returns object:

NameTypeDescription
addressnull | stringbech32 representation of the wallet address
apinull | WalletApiThe CIP30 object of the connected wallet
connectFunctionPrimary function to connect the desired wallet
connectedWalletnull | stringThe wallet that is currently connected.
disconnectFunctionDisconnects the current wallet
isConnectedbooleanTrue if the wallet is connected
isConnectingbooleanLoading indicator for the wallet connection
isRefetchingBalancebooleanLoading indicator for balance refetch
lovelaceBalancenull | numberWallet balance, in lovelace (1 ADA = 1000000 lovelace)
networknull | NetworkId0 if testnet, 1 if mainnet
refetchBalanceFunctionRefresh the wallet's balance
selectedWalletnull | stringThe wallet that was selected to connect.
0.3.2

1 month ago

0.3.3

1 month ago

0.3.1

1 month ago

0.1.2

3 months ago

0.2.3

3 months ago

0.1.3

3 months ago

0.1.1

2 years ago

0.1.0

2 years ago