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 callIn this case, the wallet account is only added to the wallet accounts list once it passes the verification step.
Connect without verifyingIn 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 beforeIn 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
Copy
Ask AI
import { connectAndVerifyWithWalletProvider } from '@dynamic-labs-sdk/client';const signInWithWallet = async (key) => { try { const walletAccount = await connectAndVerifyWithWalletProvider({ walletProviderKey: key, }); console.log(`Wallet account connected and verified: ${walletAccount.accountAddress}`); // walletAccount is now available with getWalletAccounts(), and is associated to a Dynamic user // ... } catch (error) { console.error('Error connecting or verifying wallet: ', error); // no new wallet account was added to the wallet accounts list }};
import { connectWithWalletProvider } from '@dynamic-labs-sdk/client';const signInWithWallet = async (key) => { try { const walletAccount = await connectWithWalletProvider({ walletProviderKey: key, }); console.log(`Wallet account connected: ${walletAccount.accountAddress}`); // walletAccount is now available with getWalletAccounts(), persisted in the session and is not associated to a Dynamic user // ... } catch (error) { console.error('Error connecting wallet: ', error); // no new wallet account was added to the wallet accounts list }};
You can use this function to verify a wallet account that was connected but not verified before.
Copy
Ask AI
import { verifyWalletAccount } from '@dynamic-labs-sdk/client';const verifyWallet = async (walletAccount) => { try { const walletAccount = await verifyWalletAccount({ walletAccount }); console.log(`Wallet is now verified: ${walletAccount.accountAddress}`); // walletAccount is still available with getWalletAccounts(), but is now associated to a Dynamic user // ... } catch (error) { console.error('Error verifying wallet: ', error); // walletAccount is still available with getWalletAccounts(), but is not associated to a Dynamic user }};