import { useConnect } from "thirdweb/react";
import { createWallet } from "thirdweb/wallets";
import { shortenAddress } from "thirdweb/utils";
function App() {
const account = useActiveAccount();
const wallet = useActiveWallet();
const { connect, isConnecting, error } = useConnect();
const { disconnect } = useDisconnect();
if (account) {
return (
<div>
<p>Connected: {shortenAddress(account.address)} </p>
{wallet && (
<button onClick={() => disconnect(wallet)}>Disconnect</button>
)}
</div>
);
}
return (
<button
onClick={() =>
connect(async () => {
// 500+ wallets supported with id autocomplete
const wallet = createWallet("io.metamask");
await wallet.connect({ client });
return wallet;
})
}
>
Connect MetaMask
</button>
);
}