Wallet React Demo
This page demonstrates the @chainlink/wallet-react library, which provides hooks for wallet integration. All wallet functionality is coordinated through the WalletCoordinatorContextProvider, with useWalletContext offering a convenient wrapper that combines all capabilities (WalletConnection, ConnectWalletModal).
No wallets connected
import { WalletProvider, useWalletContext } from '@chainlink/wallet-react' function App() { const [allowMultipleWallets, setAllowMultipleWallets] = useState(true) return ( <WalletProvider allowMultipleWallets={allowMultipleWallets}> <MyWalletComponent setAllowMultipleWallets={setAllowMultipleWallets} allowMultipleWallets={allowMultipleWallets} /> </WalletProvider> ) } function MyWalletComponent({ allowMultipleWallets, setAllowMultipleWallets }) { const [showFullAddressOnHover, setShowFullAddressOnHover] = useState(true) const [useSmallSize, setUseSmallSize] = useState(false) const { wallets, activeWallet, activeAddress, disconnect, WalletConnection, ConnectWalletModal } = useWalletContext() return ( <> <WalletConnection showFullAddressOnHover={showFullAddressOnHover} size={useSmallSize ? 'sm' : 'default'} /> <ConnectWalletModal /> </> ) }
No wallets connected
import { useWalletConnection, useConnectWalletModal } from '@chainlink/wallet-react' function MyWalletComponent() { const [showFullAddressOnHover, setShowFullAddressOnHover] = useState(true) const [useSmallSize, setUseSmallSize] = useState(false) const [allowMultipleWallets, setAllowMultipleWallets] = useState(true) const { openModal, ConnectWalletModal } = useConnectWalletModal() const { activeWallet, activeAddress, disconnect, WalletConnection } = useWalletConnection({ allowMultipleWallets, onConnect: openModal }) return ( <> <WalletConnection showFullAddressOnHover={showFullAddressOnHover} size={useSmallSize ? 'sm' : 'default'} /> <ConnectWalletModal /> </> ) }
import { useConnectWalletModal } from '@chainlink/wallet-react' function ConnectButton() { const { openModal, ConnectWalletModal } = useConnectWalletModal() return ( <> <button onClick={openModal}>Connect Wallet</button> <ConnectWalletModal /> </> ) }
No wallets connected
Want to host a demo? Contact the Frontend Engineering team or visit the slack #team-frontend to learn more