In the last section we covered how to access a wallet through the SDK, but said nothing about how to interact with it - let’s fix that! You probably noticed the connector field in the wallet object in the previous section. This is the object that allows you to interact with the wallet. It’s an instance of the WalletConnector interface, which is a generic interface that allows you to interact with the wallet in a standard way.

There are some fields and methods specific to each chain, so what we’ll do here is list the fields available on every single chain, and then you can go to the specific chain page (i.e. EVM interactions) to see the additional fields and methods available for that chain.

WalletConnector Interface

FieldDescription
chainRpcProviders: typeof ChainRpcProviders | undefinedThe RPC providers for the chain the wallet is connected to
walletBookInstanceA list of all of the wallets we support connections with
didSetup: booleanWhether the wallet has been set up
canConnectViaEmail: booleanWhether the wallet can be connected via email
canConnectViaCustodialService: booleanIf the wallet needs to be connected via a custodial service such as Blocto, this will be true.
canConnectViaQrCode: booleanIf the wallet is not installed, and can be connected via a QR code, this will be true.
canConnectViaSocial: booleanWhether this connector can be connected via social login.
connectedChain: ChainThe chain this wallet is connected to
endSession(): Promise<void>Close the wallet connection
fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>Get the public address of the wallet
getAdditionalAddresses(mainAddress?: string): Promise<WalletAdditionalAddress[]>Get the additional addresses of the wallet, given the main address
setAdditionalAddresses(mainAddress: string, additionalAddresses: WalletAdditionalAddress[]): Promise<void>Set the additional addresses of the wallet, given the main address
getBalance(): Promise<string | undefined>Get the balance of the wallet
getConnectedAccounts(): Promise<string[]>Get the address silently
getDeepLink(): string | undefinedGet the deep link of the wallet
getNetwork(): Promise<number | string | undefined>Get current network of connected wallet
getNameService(): Promise<NameServiceData | undefined>Get the name service of the wallet
getPublicClient(): Promise<unknown>Get the RPC provider for the wallet
getSigner(): Promise<unknown>Get the signer for the wallet
getSession(): unknown | Promise<T>Get the session for the wallet
getWalletClient(): unknownGet the wallet client
init(): Promise<void>Initialize the wallet connector with any async operations
isEmbeddedWallet: booleanIf the wallet generated by a valid embedded wallet provider
isInstalledOnBrowser(): booleanCheck if the wallet is installed on the browser
isWalletConnect: booleanFlag if it is wallet Connect
key: stringOverride key or the normalized wallet name if needed
overrideKey: string | undefinedOverride key for the wallet (used for injected wallet linking)
getMobileOrInstalledWallet(): WalletConnectorWhether the wallet connector should fall back to a different wallet connector
proveOwnership(messageToSign: string): Promise<string | undefined>In most cases this is an alias for signMessage
providerResources: string[] | undefinedAdditional resources to add to the message to be signed
setupEventListeners(): voidSet up event listeners for the wallet
signMessage(messageToSign: string): Promise<string | undefined>Sign a message
switchNetworkOnlyFromWallet: boolean | undefinedRequires switching network in the wallet itself
teardownEventListeners(): voidTear down event listeners for the wallet
getSupportedNetworks(): Promise<string[] | undefined>Get the supported networks (walletConnect wallet only)
isInitialized: booleanWhether the connector has been initialized
setVerifiedCredentials(verifiedCredentials: JwtVerifiedCredential[]): voidReceive the user verified credentials
ethers?: EthersExtensionAn extension to the wallet connector that allows you to interact with the wallet using ethers.js, will only be present if you’ve enabled Ethers

There’s a lot going on here, so let’s pick out the main aspects you’ll need to work with. We will give examples for EVM here.

Read only actions

If you want to read data from the blockchain, you will want either a “Public Client” (Viem terminology), or a “Provider” (Ethers terminology). Both allow you read only access to the blockchain.

import { useDynamicContext } from '@dynamic-labs/sdk-react-core';

const { primaryWallet } = useDynamicContext();

const getBalance = async () => {
  const publicClient = await primaryWallet?.connector?.getPublicClient();

  // Now you can use the public client to read data from the blockchain
  const balance = await publicClient?.getBalance(primaryWallet.address);
  return balance
}

Write actions

If you want to write data to the blockchain, you will need a “Wallet Client” (Viem terminology), or a “Signer” (Ethers terminology). Both allow you to sign transactions with the private key.

import { useDynamicContext } from '@dynamic-labs/sdk-react-core';

const { primaryWallet } = useDynamicContext();

const sendTransaction = async () => {
  const walletClient = await primaryWallet?.connector?.getWalletClient();

  // Now you can use the wallet client to write data to the blockchain
  const tx = await walletClient?.sendTransaction({
    to: '0x1234567890abcdef',
    value: '1000000000000000000'
  });
  return tx
}

What next?

Check out our chain specific docs, illustrating how to take various actions with wallets!