Documentation Index
Fetch the complete documentation index at: https://docs.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
You can choose when and which chains to create WaaS wallet accounts for, at any time (as long as the user is already authenticated).
Creating WaaS wallet accounts when user signs up
We provide a helper method for you to check which chains are missing WaaS wallet accounts and create them if needed.
Usage
import {
createWaasWalletAccounts,
getChainsMissingWaasWalletAccounts
} from '@dynamic-labs-sdk/client/waas';
const onSignIn = async () => {
const missingChains = getChainsMissingWaasWalletAccounts();
await createWaasWalletAccounts({ chains: missingChains });
};
Subscribe to userChanged so wallet creation fires once the user is authenticated:import {
createWaasWalletAccounts,
getChainsMissingWaasWalletAccounts,
} from '@dynamic-labs-sdk/client/waas';
import { useEffect } from 'react';
function useAutoCreateWaasWallets() {
const user = useUser(); // re-renders on userChanged
useEffect(() => {
if (!user) return;
const missingChains = getChainsMissingWaasWalletAccounts();
if (missingChains.length > 0) {
createWaasWalletAccounts({ chains: missingChains });
}
}, [user]);
}
Then you can call this onSignIn function when the authentication process is complete
See Signing in with Email, Signing in with SMS and Signing in with Social for more information.
Creating WaaS wallet accounts once user already has WaaS wallet accounts
You can pass an array of chains to the createWaasWalletAccounts method to create wallet accounts for those chains.
If the same chain is passed multiple times, just as many wallet accounts will be created for that chain
Usage
In this example, we are creating 2 EVM wallet accounts and 1 SOL wallet account,
no matter what other WaaS wallet accounts the user already has.
import {
createWaasWalletAccounts,
getChainsMissingWaasWalletAccounts
} from '@dynamic-labs-sdk/client/waas';
const createWaasWalletAccounts = async () => {
const chains = ['EVM', 'EVM', 'SOL'];
await createWaasWalletAccounts({ chains });
};
Error Handling
- If you didn’t add the required WaaS extensions for the chains that you are trying to create wallet accounts for, it will throw a
NoWalletProviderFoundError.