MethodDescription
accountSwitchState: AccountSwitchStateThis enum type specifies the current state of switching or linking wallets in a multi-wallet enabled environment. This can be idle, linking_new_wallet, switching_primary, primary_not_connected
authMode: AuthModeTypeThis enum type specifies whether the SDK\’s users will need to sign to authenticate and prove ownership of their account, or just connect is enough. This can be connect-only or connect-and-sign
authToken: getAuthToken()JSON web token (JWT) stored if the user is authenticated. This is the authenticated user’s token. See: backend verification.
awaitingSignatureState: AwaitingSignatureStateThis enum type specifies the current state while waiting for a signature of a new wallet to link in a multi-wallet enabled environment. This can be idle, linking_new_wallet, transferring_wallet
connectedWallets: Wallet[]This contains a concatenated list of wallets between primaryWallet and secondaryWallets that are in a connected state.
handleLogOut: () => PromiseA helper-method to log-out the currently authenticated user account.
handleUnlinkWallet(walletId: string): PromiseHelper function to unlink a wallet given a wallet ID from the user account.
isAuthenticated: booleanReturns true when the user has been authenticated and has a JWT and valid user object.
isFullyConnected: booleanIndicates that all wallets specified in WalletsByChain are fully connected. If no WalletsByChain prop is provided, indicates whether the user has connected a single wallet.
isVerificationInProgress: booleanWhether any verifications are in progress for the current user (ex. connect, sign and email login verifications).
linkedWallets: Wallet[]Represents that wallets that are curently linked to the account (only relevant to connect-and-auth)
loadingNetwork: booleanReturns true when the SDK is looking for the network of the primary wallet\’s wallet connector.
multiWalletWidgetState: MultiWalletWidgetStateThis enum type specifies the current state of the widget in a multi-wallet enabled environment. This can be idle, awaiting_account_switch, awaiting_connection, awaiting_signature, detected_known_secondary_wallet, detected_new_wallet
network: number | undefinedThis represents the current network selected for the primary wallet
networkConfigurations: NetworkConfigurationMap | undefinedThis contains the current network configurations for various EVM and Solana chains. These information includes chain ID, RPC URLs, and other important information.
primaryWallet: Wallet | nullAn instance of a Wallet that represents the most recent connected Wallet.
qrcodeUri: stringURI for the QR code to scan in the current modal.
rpcProviders: DynamicRPCProvidersList of RPC providers and their settings to communicate with web3 services. These providers are configured on Dynamic’s dashboard.
sdkHasLoaded: booleanWhether the sdk’s data is done loading — useful for avoiding stale data flashes by not rendering until the sdk is done loading.
secondaryWallets: Wallet[]List of other authenticated wallets linked to the user account that are not primary wallets.
setMultiWalletWidgetState: MultiWalletWidgetStateSetterIt controls the intended state for a multi-wallet enabled environment.
setPrimaryWallet: (walletId: string) => voidIn a multi-wallet environment, this function can be used to indicate that a wallet, given the wallet ID, should be considered the primary wallet.
setShowAuthFlow: Dispatch<SetStateAction>It controls whether or not to display the DynamicAuthFlow SDK component.
setShowQrcodeModal: Dispatch<SetStateAction>It controls whether or not to display a QR code modal.
showAuthFlow: booleanThe value set by setShowAuthFlow, it controls whether or not to display the DynamicAuthFlow SDK component.
showQrcodeModal: booleanValue set by setShowQrcodeModal, it controls whether or not to display a QR code modal.
user: UserProfile | nullThe user object of the currently authenticated user.
walletConnector: WalletConnector | nullAn instance of a WalletConnector that represents the most recent connected Wallet.
wallets: WalletOption[]List of all available wallet options the environment\’s SDK users can select.

Examples

setShowAuthFlow - use it to start signature request from user

const ConnectButton = () => {
  const { setShowAuthFlow } = useDynamicContext();
  return (
    <button
      onClick={() => setShowAuthFlow(true)}
    >
      Connect your wallet
    </button>
  );
};

primaryWallet - use it to make operations on the currently active wallet

  • method to simply fetch balance of users wallet:
const getBalance = async () => {
  const balance = await primaryWallet.connector.getBalance();
  return balance;
};
  • get users primary wallet
const getAddress = () => {
  const address = primaryWallet.address;
  return address;
};
  • get all connected wallets by primary wallet connector
const getConnectedAccounts = async () => {
  const connectedAccounts = await primaryWallet?.connector.getConnectedAccounts();
  return connectedAccounts;
};

walletConnector - use it to use currently connected walletConnector instead of primaryWallet

const getConnectedAccounts = async () => {
  const connectedAccounts = await walletConnector?.getConnectedAccounts();
  return connectedAccounts;
};

handleLogOut - use it to log out currently logged in user

const LogoutButton = () => {
  const { handleLogOut } = useDynamicContext();
  return (
    <button
      onClick={() => handleLogOut(true)}
    >
      Log out
    </button>
  );
};

authToken - use it to get authenticated user jwt

const getJwt = () => {
  const jwt = authToken;
  return jwt;
};

isVerificationInProgress - use it along with onAuthFlowClose to tell whether it was manually closed or closed due to a verification process

<DynamicContextProvider
  settings={{
    eventsCallbacks: {
      onAuthFlowClose: () => {
        if (isVerificationInProgress) console.log('Closed due to verification process');
        else console.log('Manually closed by client');
      }
    }
  }}
>
 {/* ... rest of your app ... */}
</DynamicContextProvider>