WalletClientSigner
The WalletClientSigner
is useful if you want to convert a viem
WalletClient
to a SmartAccountSigner
which can be used as a signer to use to connect to Smart Contract Accounts
Usage
ts
import {
WalletClientSigner,
sepolia,
type SmartAccountSigner,
} from "@alchemy/aa-core";
import { createWalletClient, custom } from "viem";
const externalProvider = window.ethereum; // or anyother EIP-1193 provider
const walletClient = createWalletClient({
chain: sepolia, // can provide a different chain here
transport: custom(externalProvider),
});
export const signer: SmartAccountSigner = new WalletClientSigner(
walletClient,
"json-rpc" // signerType
);
Methods
constructor(client: WalletClient)
Creates a new WalletClient
using the WalletClient
to sign messages
getAddress(): Promise<Address>
Returns the public address of the underlying Wallet
signMessage(msg: string | Hex | ByteArray): Promise<Hex>
Signs and returns a message in EIP-191 format
signTypedData(params: SignTypedDataParams): Promise<Hex>
Signs and returns a message in EIP-712 format using eth_signTypedData_v4