Skip to main content

useBloctoWallet

Hook that prompts users to connect their Blocto wallet to your app.

import { useBloctoWallet } from "@thirdweb-dev/react";

The bloctoWallet also needs to be added in ThirdwebProvider's supportedWallets if you want the wallet to auto-connect on next page load.

Usage

Call the function returned by the useBloctoWallet hook to prompt the user to connect their Blocto wallet to your dApp.

You can then use the useAddress hook to get the user's address.

import { useBloctoWallet } from "@thirdweb-dev/react";

function App() {
const connectWithBlocto = useBloctoWallet();

return <button onClick={() => connectWithBlocto()}>Connect Blocto</button>;
}

Configuration

chainId

To connect to a specific chain when connecting the wallet, pass the chainId in a configuration object as shown below.

This will prompt the user to switch to the given network after they connect.

connectWithBlocto({
chainId: Polygon.chainId,
});

If the chain is not configured in the users wallet, you must add this chain in ThirdwebProviders supportedChains prop:

import { Polygon } from "@thirdweb-dev/chains";
import { ThirdwebProvider } from "@thirdweb-dev/react";

export function YourApp() {
return (
<ThirdwebProvider supportedChains={[Polygon]} clientId="your-client-id">
<App />
</ThirdwebProvider>
);
}
appId (recommended)

To get advanced features and support from Blocto, you can create an appId from blocto dashboard

connectWithBlocto({
appId: "YOUR_BLOCTO_APP_ID",
});