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.
Most WaaS-specific methods require you to pass a WaaS WalletAccount object. If you want to check if a certain wallet account is a
WaaS WalletAccount, you can use the isWaasWalletAccount helper method to avoid type errors.
import { isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';
const someAction = async (walletAccount) => {
if (!isWaasWalletAccount(walletAccount)) {
throw new Error('This wallet account is not a WaaS wallet account');
}
// Do something with WaaS, like export a private key
// ...
}
React
isWaasWalletAccount is a synchronous type guard that works the same way in React. Use it inside callbacks or effects to narrow wallet account types before calling WaaS-specific functions:
import { isWaasWalletAccount } from '@dynamic-labs-sdk/client/waas';
import { exportWaasPrivateKey } from '@dynamic-labs-sdk/client/waas';
import { useWalletAccounts } from '@dynamic-labs-sdk/react-hooks';
function ExportButton() {
const containerRef = useRef(null);
const walletAccounts = useWalletAccounts();
const walletAccount = walletAccounts[0];
const handleExport = async () => {
if (!walletAccount || !isWaasWalletAccount(walletAccount) || !containerRef.current) return;
await exportWaasPrivateKey({ walletAccount, displayContainer: containerRef.current });
};
return (
<div>
<button onClick={handleExport}>Export Key</button>
<div ref={containerRef} />
</div>
);
}