SessionKeySigner
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.
Implements
SmartAccountSigner<LocalAccountSigner<PrivateKeyAccount>>
Constructors
Constructor
1 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
1 import { SessionKeySigner } from "@account-kit/smart-contracts"; 2 3 const signer = new SessionKeySigner();
Parameters
| Parameter | Type | Description |
|---|---|---|
| { | the configuration for initializing the session key signer |
|
| ‐ |
|
| ‐ |
Returns
SessionKeySigner
Properties
| Property | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
() => | An async function that retrieves the address using the inner object’s Example
| |||||||||
| ‐ | |||||||||
| ‐ | |||||||||
( | Signs a message using the inner signer. Example
|
Methods
generateNewKey()
1 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
1 import { SessionKeySigner } from "@account-kit/smart-contracts"; 2 3 const signer = new SessionKeySigner(); 4 const newSessionKey = signer.generateNewKey();
Returns
`0x${string}`
The public address of the new key.
signTypedData()
1 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
1 import { SessionKeySigner } from "@account-kit/smart-contracts"; 2 3 const signer = new SessionKeySigner(); 4 console.log( 5 await signer.signTypedData({ 6 types: { 7 Message: [{ name: "content", type: "string" }], 8 }, 9 primaryType: "Message", 10 message: { content: "Hello" }, 11 }), 12 );
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
1 SmartAccountSigner.signTypedData;