Hooks
useEmbeddedWallet
This hook gives you control over when you create an embedded wallet for any given user.
It gives you access to a function to create an embedded wallet, and function to check if the user currently has an embedded wallet.
Usage
import { useEmbeddedWallet } from “@dynamic-labs/sdk-react-core”
const { createEmbeddedWallet, userHasEmbeddedWallet } = useEmbeddedWallet();
const onClick = async () => {
if(!userHasEmbeddedWallet()) {
try {
const walletId = await createEmbeddedWallet();
// do whatever you want with that Id
} catch(e) {
// handle error
}
}
}
return (
<button onClick={() => onClick()}>Create Wallet</button>
)
Return Values
- createEmbeddedWallet returns a promise which will resolve to a wallet ID once the creation flow has been successful.
- userHasEmbeddedWallet returns a boolean which will be true if the user has an embedded wallet at that time.
Was this page helpful?