0.0.2 • Published 1 year ago
@hotpotdao/react-hooks v0.0.2
react-hooks
des
- 钱包: 激活、取消
- 账户: 链接、断开
usage
example
import { useEvm } from '@hotpotdao/react-hooks';
const Homepage = () => {
const { isActive, activate, accounts, connect, chainId, wallet } = useEvm();
const connectWallet = async () => {
if (!isActive) await activate('metamask'); // 需要激活或者链接的钱包
if (connect) await connect();
console.log(wallet); // wallet is provider
};
return (
<>
<main>
<h2>{chainId}</h2>
<h3>{accounts}</h3>
<button onClick={connectWallet}>链接钱包</button>
</main>
</>
);
};
export default Homepage;