Defined in: account-kit/smart-contracts/src/msca/plugins/session-key/signer.ts:28
A simple session key signer that uses localStorage or sessionStorage to store a private key. If the key is not found, it will generate a new one and store it in the storage.
SmartAccountSigner<LocalAccountSigner<PrivateKeyAccount>>
new SessionKeySigner(config_): SessionKeySigner;Defined in: account-kit/smart-contracts/src/msca/plugins/session-key/signer.ts:48
Initializes a new instance of a session key signer with the provided configuration. This will set the signerType, storageKey, and storageType. It will also manage the session key, either fetching it from storage or generating a new one if it doesn't exist.
Example
import { SessionKeySigner } from "@account-kit/smart-contracts";
const signer = new SessionKeySigner();Parameters
| Parameter | Type | Description |
|---|---|---|
|
| the configuration for initializing the session key signer |
Returns
SessionKeySigner
| Property | Type | Description |
|---|---|---|
() => | An async function that retrieves the address using the inner object's Example | |
| ‐ | |
| ‐ | |
( | Signs a message using the inner signer. Example |
generateNewKey(): `0x${string}`;Defined in: account-kit/smart-contracts/src/msca/plugins/session-key/signer.ts:157
Generates a new private key and stores it in the storage.
Example
import { SessionKeySigner } from "@account-kit/smart-contracts";
const signer = new SessionKeySigner();
const newSessionKey = signer.generateNewKey();Returns
`0x${string}`
The public address of the new key.
signTypedData<TTypedData, TPrimaryType>(params): Promise<`0x${string}`>;Defined in: account-kit/smart-contracts/src/msca/plugins/session-key/signer.ts:135
Signs the provided typed data using the inner signer.
Example
import { SessionKeySigner } from "@account-kit/smart-contracts";
const signer = new SessionKeySigner();
console.log(
await signer.signTypedData({
types: {
Message: [{ name: "content", type: "string" }],
},
primaryType: "Message",
message: { content: "Hello" },
}),
);Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
| ‐ | The typed data type, which extends |
| keyof | The primary type of the typed data. |
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The parameters containing the typed data definition and primary type. |
Returns
Promise<`0x${string}`>
A promise that resolves to the signed typed data as a string.
Implementation of
SmartAccountSigner.signTypedData;