useWallet
This hook provides tools for connecting to a wallet, accessing account information, and disconnecting from a wallet. Account information will update in real time when changes are made in the wallet extension.
Basic Usage
import { useWallet, useAllWallets } from 'useink'
export const WalletConnect = () => {
const wallets = useAllWallets()
const { isConnected, connect, disconnect, setAccount } = useWallet()
if (isConnected) return <button onClick={disconnect}>Disconnect</button>
return (
<ul>
{wallets.map(w => (
<li key={w.title}>
{w.installed ? (
<button onClick={() => connect(w.extensionName)}>
<img src={w.logo.src} alt={w.logo.alt} />
Connect to {w.title}
</button>
) : (
<a href={w.installUrl}>
<img src={w.logo.src} alt={w.logo.alt} />
Install {w.title}
</a>
)}
</li>
))}
</ul>
)
}Changing the Active Account
You can set the active account using setAccount. account is used in all hooks as the caller address.
Return Type
Last updated
Was this helpful?