Skip to content
Alchemy Logo

Authentication quickstart

Using React? Follow this quickstart guide instead for easy-to-use React hooks and integration with Smart Wallets.

If you're not using React, use the @account-kit/signer package to create and use Smart Wallets.

  1. Get your API key by creating a new app in your dashboard

    Make sure your desired network is enabled for your app under the Networks tab.

  2. Activate smart wallets for your app in your dashboard

    1. Apply the config to your app from step 1

      apply the config to the app from the first step
    2. Enable authentication methods you want to support.


      Email auth

      If you want to use email auth, toggle on email.

      • For testing, use http://localhost:3000 as the Redirect URL (Note http not https)
      • The Redirect URL is where redirection occurs when using the magic link email flow
      • Optionally stylize the email with your brand color and logo.
      configure email auth
      Social auth

      If you want to enable social login, toggle which auth providers you want to support.

      • For testing, add http://localhost:3000 as a whitelisted origin

      • Add the link that your dApp will be running on to the whitelisted origin list

      • Optionally enter your own OAuth credentials or use the defaults

        configure social auth
  3. Create the config and copy the API key

    how to copy the api key

Prerequisites

  • minimum Typescript version of 5

Installation

yarn add @account-kit/signer

import { AlchemyWebSigner } from "@account-kit/signer";
 
export const signer = new AlchemyWebSigner({
  client: {
    connection: {
      apiKey: "API_KEY",
    },
    iframeConfig: {
      iframeContainerId: "alchemy-signer-iframe-container",
    },
  },
});

Next, authenticate your user before you can use it as an owner on the account.

In this example, email auth is used, but a number of other auth methods are supported. See the other guides for more examples.

import { signer } from "./signer";
 
const result = await signer.authenticate({
  type: "email",
  email: "example@mail.com",
});

Now that you have authenticated your user, use the authentication provider as an owner on a smart wallet.

import { createLightAccount } from "@account-kit/smart-contracts";
import { sepolia } from "@account-kit/infra";
import { http } from "viem";
import { signer } from "./signer";
 
const account = await createLightAccount({
  signer,
  chain: sepolia,
  transport: http(`${sepolia.rpcUrls.alchemy.http[0]}/API_KEY`),
});
Was this page helpful?