Use the embedded wallet
Obtain an instance of the connected wallet
- React & React Native
- Other Frameworks
In react, you can access the wallet instance using the useWallet
hook.
import { useWallet } from "@thirdweb-dev/react"; // or /react-native
const embeddedWallet = useWallet("embeddedWallet");
In other frameworks, you can create an use your own instance of the wallet.
import { EmbeddedWallet } from "@thirdweb-dev/wallets";
import { Goerli } from "@thirdweb-dev/chains";
const embeddedWallet = new EmbeddedWallet({
chain: Goerli, // chain to connect to
clientId: "YOUR_CLIENT_ID", // Your thirdweb client ID
});
Get the user email
const email = await embeddedWallet.getEmail();
Get the user wallet address
- React & React Native
- Other Frameworks
import { useAddress } from "@thirdweb-dev/react"; // or /react-native
const address = useAddress();
const address = await embeddedWallet.getAddress();
Get the user's signer
- React & React Native
- Other Frameworks
import { useSigner } from "@thirdweb-dev/react"; // or /react-native
const signer = useSigner();
await embeddedWallet.getSigner();
Transfer funds
await embeddedWallet.transfer("0x...", 0.1); // amount in ETH
Sign a message
await embeddedWallet.sign("Hello World!");