Skip to main content

getSignerForSmartWalletAccount

Gets a WalletClient instance for the EOA (Externally Owned Account) that owns the smart wallet account. This signer can be used to sign EVM transactions directly with the underlying EOA.

Usage

import { getSignerForSmartWalletAccount } from "@dynamic-labs-sdk/zerodev";
import { isEvmWalletAccount } from "@dynamic-labs-sdk/evm";
import { getPrimaryWalletAccount } from "@dynamic-labs-sdk/client";

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isEvmWalletAccount(walletAccount)) {
  const signer = await getSignerForSmartWalletAccount({
    smartWalletAccount: walletAccount,
  });

  // Use the signer to sign messages or transactions with the EOA
  const signature = await signer.signMessage({
    message: "Hello, World!",
  });
}

Parameters

ParameterTypeDescription
smartWalletAccountEvmWalletAccountThe smart wallet account to get the signer for
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Returns

Promise<WalletClient> - A promise that resolves to a viem WalletClient instance for the EOA.

Errors

ErrorDescription
NoSmartWalletAccountSignerFoundErrorThrown when no signer wallet account is found for the given smart wallet account