React Hooks for Ethereum and Kali DAO Apps
Kali Hooks is a Rect Hooks library that aims to simplify development of Kali DAO based web3 apps. Kali Hooks extends the wagmi hooks library and follows the wagmi best practices.
- 🚀 React hooks for working with Kali DAO EVM contracts.
- 👟 Caching, request deduplication, multicall, batching, and persistence
- 🦄 TypeScript ready
Checks if the user is connected to a target chain. Useful for preventing users from writing to contracts on the wrong chain.
Example React component snippet:
import { useChainGuard } from '@kalidao/hooks'
const daoHomeChain = chain.arbitrum
const { isUserOnCorrectChain, isUserConnected, userChain } = useChainGuard({ chainId: daoHomeChain.id })
let wrongChainWarning
if (!isUserOnCorrectChain) {
wrongChainWarning = (!isUserConnected) ?
wrongChainWarning = `Your Web3 wallet is disconnected. Please connect to ${daoHomeChain.name}.`
:
wrongChainWarning = `Your Web3 wallet is connected to ${userChain.name}. Please switch to ${daoHomeChain.name}.`
}
Install Kali Hooks and its peer dependencies.
npm install @kalidao/hooks wagmi ethers
If you're interested in contributing, please read the contributing docs before submitting a pull request.
MIT License