Defined in: aa-sdk/core/src/signer/wallet-client.ts:18
Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, sign typed data, and sign 7702 authorizations.
unknown<WalletClient>
new WalletClientSigner(client, signerType): WalletClientSigner;Defined in: aa-sdk/core/src/signer/wallet-client.ts:43
Initializes a signer with a given wallet client and signer type.
Example
import { WalletClientSigner } from "@aa-sdk/core";
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
});
const signer = new WalletClientSigner(client, "wallet");Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The wallet client to interact with |
|
| The type of signer; must be a valid signer type, otherwise an error will be thrown |
Returns
WalletClientSigner
Throws
If the signer type is invalid
| Property | Type | Description |
|---|---|---|
() => | Asynchronously retrieves addresses from the inner object and returns the first address after applying the Example | |
| ‐ | |
| ‐ | |
( | Signs a message using the account's signing method. Example |
signAuthorization(unsignedAuthorization): Promise<SignedAuthorization<number>>;Defined in: aa-sdk/core/src/signer/wallet-client.ts:173
Signs an EIP-7702 Authorization
Example
import { WalletClientSigner } from "@aa-sdk/core";
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
});
const signer = new WalletClientSigner(client, "wallet");
const authorization = await signer.signAuthorization({
contractAddress: "0x1234123412341234123412341234123412341234",
chainId: 1,
nonce: 0,
});Parameters
| Parameter | Type | Description |
|---|---|---|
|
| the authorization to be signed |
Returns
Promise<SignedAuthorization<number>>
a promise that resolves to the signed authorization
signTypedData<TTypedData, TPrimaryType>(typedData): Promise<`0x${string}`>;Defined in: aa-sdk/core/src/signer/wallet-client.ts:131
Signs the provided typed data using the account's private key.
Example
import { WalletClientSigner } from "@aa-sdk/core";
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
});
const signer = new WalletClientSigner(client, "wallet");
console.log(
await signer.signTypedData({
types: {
Message: [{ name: "content", type: "string" }],
},
primaryType: "Message",
message: { content: "Hello" },
}),
);Type Parameters
| Type Parameter | Default type |
|---|---|
| ‐ |
|
|
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The typed data to be signed |
Returns
Promise<`0x${string}`>
A promise that resolves to a hex string representing the signed data