Defined in: account-kit/signer/src/signer.ts:122
A SmartAccountSigner that can be used with any SmartContractAccount
new AlchemyWebSigner(params): AlchemyWebSigner;Defined in: account-kit/signer/src/signer.ts:146
Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});Parameters
| Parameter | Type | Description |
|---|---|---|
| { | The parameters for the Alchemy signer, including the client and session configuration |
| | | ‐ |
| { | ‐ |
|
| ‐ |
|
| ‐ |
|
| ‐ |
Returns
AlchemyWebSigner
Overrides
| Property | Type | Default value | Description |
|---|---|---|---|
( |
| Initiates the setup of a new MFA factor for the current user. The factor will need to be verified using verifyMfa before it becomes active. Example Throws If no user is authenticated | |
( |
| Adds a passkey to the user's account Example | |
( |
| Authenticate a user with either an email or a passkey and create a session for that user Example | |
() => |
| Clear a user session and log them out Example | |
( |
| Exports a private key for a given account encrypted with the provided public key Param the parameters for the export | |
( |
| Used to export the wallet for a given user If the user is authenticated with an Email, this will return a seed phrase If the user is authenticated with a Passkey, this will return a private key Example Param exportWallet parameters | |
() => |
| Retrieves the address of the current user by calling the | |
() => |
| Retrieves the list of MFA factors configured for the current user. Example Throws If no user is authenticated | |
() => |
| ‐ | |
| ‐ | ||
() => |
| Removes the email for the authenticated user, disallowing them from login with that email. Throws If the user is not authenticated | |
( |
| Removes existing MFA factors by their IDs. Example Throws If no user is authenticated | |
( |
| Removes a passkey from a user's account Example | |
() => |
| Removes the phone number for the authenticated user, disallowing them from login with that phone number. Throws If the user is not authenticated | |
( |
| Initiates an OTP (One-Time Password) verification process for a user contact.
Use this method before calling Throws If the user is not authenticated | |
( |
| Sets the phone number for the authenticated user, allowing them to login with that
phone number. Throws If the user is not authenticated | |
( |
| Signs an EIP-7702 Authorization and then returns the authorization with the signature. Example | |
|
| ‐ | |
( |
| Signs a raw message after hashing it. Example | |
< |
| Serializes a transaction, signs it with a raw message, and then returns the serialized transaction with the signature. Example | |
< |
| Signs a typed message by first hashing it and then signing the hashed message using the Example | |
( |
| Verifies a newly created MFA factor to complete the setup process. Example Throws If no user is authenticated |
addOauthProvider(args): Promise<OauthProviderInfo>;Defined in: account-kit/signer/src/base.ts:1270
Handles OAuth authentication by augmenting the provided arguments with a type and performing authentication based on the OAuth mode (either using redirect or popup).
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| Authentication parameters omitting the type, which will be set to "oauth" |
Returns
Promise<OauthProviderInfo>
A promise that resolves to an OauthProviderInfo object containing provider information and the ID token.
Inherited from
BaseAlchemySigner.addOauthProvider
protected fetchConfig(): Promise<SignerConfig>;Defined in: account-kit/signer/src/base.ts:1892
Returns
Promise<SignerConfig>
Inherited from
getAuthDetails(): Promise<User>;Defined in: account-kit/signer/src/base.ts:479
Gets the current logged in user If a user has an ongoing session, it will use that session and try to authenticate
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
// throws if not logged in
const user = await signer.getAuthDetails();Returns
Promise<User>
the current user
Throws
if there is no user logged in
Inherited from
BaseAlchemySigner.getAuthDetails
getConfig(): Promise<SignerConfig>;Defined in: account-kit/signer/src/base.ts:1884
Returns the signer configuration while fetching it if it's not already initialized.
Returns
Promise<SignerConfig>
A promise that resolves to the signer configuration
Inherited from
getMfaStatus(): object;Defined in: account-kit/signer/src/base.ts:719
Gets the current MFA status
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const mfaStatus = signer.getMfaStatus();
if (mfaStatus === AlchemyMfaStatus.REQUIRED) {
// Handle MFA requirement
}Returns
object
The current MFA status
| Name | Type |
|---|---|
|
|
|
|
Inherited from
BaseAlchemySigner.getMfaStatus
Unauthenticated call to look up a user's organizationId by email or phone
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const result = await signer.getUser({ type: "email", value: "[email protected]" });Param
the params to look up
Call Signature
getUser(email): Promise<
| null
| {
orgId: string;
}>;Defined in: account-kit/signer/src/base.ts:752
Unauthenticated call to look up a user's organizationId by email
Deprecated
Use getUser({ type: "email", value: email }) instead
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const result = await signer.getUser("[email protected]");Parameters
| Parameter | Type | Description |
|---|---|---|
|
| the email to lookup |
Returns
Promise<
| null
| {
orgId: string;
}>
the organization id for the user if they exist
Inherited from
Call Signature
getUser(params): Promise<
| null
| {
orgId: string;
}>;Defined in: account-kit/signer/src/base.ts:777
Unauthenticated call to look up a user's organizationId by email or phone
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const result = await signer.getUser({ type: "email", value: "[email protected]" });Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<
| null
| {
orgId: string;
}>
the organization id for the user if they exist
Inherited from
protected initConfig(): Promise<SignerConfig>;Defined in: account-kit/signer/src/base.ts:1874
Returns
Promise<SignerConfig>
Inherited from
listAuthMethods(): Promise<AuthMethods>;Defined in: account-kit/signer/src/base.ts:1315
Retrieves a list of auth methods associated with the authenticated user.
Returns
Promise<AuthMethods>
A promise that resolves to an AuthMethods object containing the user's email, OAuth providers, and passkeys.
Throws
Thrown if the user is not authenticated
Inherited from
BaseAlchemySigner.listAuthMethods
on<E>(event, listener): () => void;Defined in: account-kit/signer/src/base.ts:183
Allows you to subscribe to events emitted by the signer
Type Parameters
| Type Parameter |
|---|
|
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| the event to subscribe to |
| the function to run when the event is emitted |
Returns
a function to remove the listener
(): void;Returns
void
Inherited from
preparePopupOauth(): Promise<OauthConfig>;Defined in: account-kit/signer/src/base.ts:285
Prepares the config needed to use popup-based OAuth login. This must be
called before calling .authenticate with params { type: "oauth", mode: "popup" }, and is recommended to be called on page load.
This method exists because browsers may prevent popups from opening unless triggered by user interaction, and so the OAuth config must already have been fetched at the time a user clicks a social login button.
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
await signer.preparePopupOauth();Returns
Promise<OauthConfig>
the config which must be loaded before using popup-based OAuth
Inherited from
BaseAlchemySigner.preparePopupOauth
removeOauthProvider(providerId): Promise<any>;Defined in: account-kit/signer/src/base.ts:1302
Removes an OAuth provider by its ID if the user is authenticated.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The ID of the OAuth provider to be removed, as obtained from |
Returns
Promise<any>
A promise indicating the result of the removal process
Throws
Thrown if the user is not authenticated
Inherited from
BaseAlchemySigner.removeOauthProvider
Implementation for setEmail method.
Param
An object containing the verificationCode (or simply an email for legacy usage)
Call Signature
setEmail(email): Promise<string>;Defined in: account-kit/signer/src/base.ts:842
Sets the email for the authenticated user, allowing them to login with that email.
Deprecated
You must contact Alchemy to enable this feature for your team, as there are important security considerations. In particular, you must not call this without first validating that the user owns this email account. It is recommended to now use the email verification flow instead.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The email to set for the user |
Returns
Promise<string>
A promise that resolves to the updated email address
Throws
If the user is not authenticated
Inherited from
Call Signature
setEmail(params): Promise<string>;Defined in: account-kit/signer/src/base.ts:854
Uses a verification code to update a user's email, allowing them to login
with that email. sendVerificationCode should be called first to obtain
the code.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| An object containing the verification code |
Returns
Promise<string>
A promise that resolves to the updated email address
Throws
If the user is not authenticated
Inherited from
toSolanaSigner(): SolanaSigner;Defined in: account-kit/signer/src/base.ts:1133
Creates a new instance of SolanaSigner using the provided inner value.
This requires the signer to be authenticated first
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const solanaSigner = signer.toSolanaSigner();Returns
A new instance of SolanaSigner
Inherited from
BaseAlchemySigner.toSolanaSigner
toViemAccount(): object;Defined in: account-kit/signer/src/base.ts:1089
This method lets you adapt your AlchemySigner to a viem LocalAccount, which will let you use the signer as an EOA directly.
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
const account = signer.toViemAccount();Returns
object
a LocalAccount object that can be used with viem's wallet client
| Name | Type |
|---|---|
|
|
|
|
|
|
| ( |
| ( |
| ( |
| < |
| < |
|
|
|
|
Throws
if your signer is not authenticated
Inherited from
BaseAlchemySigner.toViemAccount
validateMultiFactors(params): Promise<User>;Defined in: account-kit/signer/src/base.ts:1815
Validates MFA factors that were required during authentication. This function should be called after MFA is required and the user has provided their MFA code. It completes the authentication process by validating the MFA factors and completing the auth bundle.
Example
import { AlchemyWebSigner } from "@account-kit/signer";
const signer = new AlchemyWebSigner({
client: {
connection: {
rpcUrl: "/api/rpc",
},
iframeConfig: {
iframeContainerId: "alchemy-signer-iframe-container",
},
},
});
// After MFA is required and user provides code
const user = await signer.validateMultiFactors({
multiFactorCode: "123456", // 6-digit code from authenticator app
multiFactorId: "factor-id",
});Parameters
| Parameter | Type | Description |
|---|---|---|
| Parameters for validating MFA factors |
Returns
Promise<User>
A promise that resolves to the authenticated user
Throws
If there is no pending MFA context or if orgId is not found