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.
In Dynamic, we treat each chain (EVM, SOL, etc.) and each wallet app (or wallet provider) as a separate entity, and when connected/verified,
will create a separate wallet account.
There are 3 ways to connect and verify a wallet:
-
Connect and verify in a single SDK call
In this case, the wallet account is only added to the wallet accounts list once it passes the verification step.
-
Connect without verifying
In this case, the wallet account is added to the wallet accounts list as soon as the user accepts the connection, but it will only be persisted in the local session and not associated to a Dynamic user.
-
Verify a wallet account that has been connected but not verified before
In this case, the wallet account remains in the wallet accounts list, no matter if the verification step is successful or not.
The difference is that the wallet account will have a new
verifiedCredentialId property, be persisted in the Dynamic server and associated to a Dynamic user.
1. Connect and verify a wallet in a single SDK call
On mobile, connectAndVerifyWithWalletProvider throws a DeeplinkConnectAndVerifyUnsupportedError
for deep link wallet providers (e.g. Phantom redirect). This is because it triggers two sequential
deep links and iOS will not honor the second one. Use options 2 and 3 below to connect and verify
separately. See the Phantom Redirect Extension docs
for a full example.
import { connectAndVerifyWithWalletProvider } from '@dynamic-labs-sdk/client';
const signInWithWallet = async (key) => {
try {
const walletAccount = await connectAndVerifyWithWalletProvider({ walletProviderKey: key });
console.log(`Connected and verified: ${walletAccount.accountAddress}`);
} catch (error) {
console.error('Error connecting or verifying wallet: ', error);
}
};
import { connectAndVerifyWithWalletProvider } from '@dynamic-labs-sdk/client';
import { useState } from 'react';
function ConnectWalletButton({ walletProviderKey }: { walletProviderKey: string }) {
const [isConnecting, setIsConnecting] = useState(false);
const [error, setError] = useState<unknown>(null);
const handleConnect = async () => {
setIsConnecting(true);
setError(null);
try {
await connectAndVerifyWithWalletProvider({ walletProviderKey });
// useWalletAccounts() consumers re-render automatically
} catch (err) {
setError(err);
} finally {
setIsConnecting(false);
}
};
return (
<button onClick={handleConnect} disabled={isConnecting}>
{isConnecting ? 'Connecting…' : 'Connect'}
</button>
);
}
2. Connect a wallet without verifying it
import { connectWithWalletProvider } from '@dynamic-labs-sdk/client';
const signInWithWallet = async (key) => {
try {
const walletAccount = await connectWithWalletProvider({ walletProviderKey: key });
console.log(`Connected: ${walletAccount.accountAddress}`);
} catch (error) {
console.error('Error connecting wallet: ', error);
}
};
import { connectWithWalletProvider } from '@dynamic-labs-sdk/client';
async function handleConnect(walletProviderKey: string) {
const walletAccount = await connectWithWalletProvider({ walletProviderKey });
// Session-only, not yet associated to a Dynamic user
}
3. Verify a connected wallet account
You can use this function to verify a wallet account that was connected but not verified before.
import { verifyWalletAccount } from '@dynamic-labs-sdk/client';
const verifyWallet = async (walletAccount) => {
try {
const verified = await verifyWalletAccount({ walletAccount });
console.log(`Verified: ${verified.accountAddress}`);
} catch (error) {
console.error('Error verifying wallet: ', error);
}
};
import { verifyWalletAccount, type WalletAccount } from '@dynamic-labs-sdk/client';
import { useState } from 'react';
function VerifyButton({ walletAccount }: { walletAccount: WalletAccount }) {
const [isVerifying, setIsVerifying] = useState(false);
const handleVerify = async () => {
setIsVerifying(true);
try {
await verifyWalletAccount({ walletAccount });
} finally {
setIsVerifying(false);
}
};
return (
<button onClick={handleVerify} disabled={isVerifying}>
{isVerifying ? 'Verifying…' : 'Verify wallet'}
</button>
);
}
Hardware wallet connections
Both connectWithWalletProvider and connectAndVerifyWithWalletProvider accept an optional
hardwareWalletVendor parameter to connect via a hardware wallet (e.g., Ledger) through a
compatible software wallet:
import {
getAvailableWalletsToConnect,
canConnectWithHardwareWallet,
connectAndVerifyWithWalletProvider,
} from '@dynamic-labs-sdk/client';
const ledgerProvider = getAvailableWalletsToConnect().find((provider) =>
canConnectWithHardwareWallet({
walletProviderKey: provider.key,
hardwareWalletVendor: 'ledger',
})
);
if (ledgerProvider) {
const walletAccount = await connectAndVerifyWithWalletProvider({
walletProviderKey: ledgerProvider.key,
hardwareWalletVendor: 'ledger',
});
}
See Hardware Wallet Support for the full guide,
including how to check support per provider and detect hardware wallet accounts.