Skip to content

Capsule Signer

CapsuleSigner is a signer implementation which extends SmartAccountAuthenticator to leverage the Capsule SDK. It supports features such as authentication, message and typed data signing, and authentication details retrieval.

CapsuleSigner provides implementations for all methods on SmartAccountAuthenticator:

  1. authenticate -- supports user authentication.
  2. getAddress -- gets the address of the the smart contract account's connected EOA signer account.
  3. signMessage -- supports message signatures.
  4. signTypedData -- supports typed data signatures.
  5. getAuthDetails -- supports authentication details retrieval.

Install Dependencies

CapsuleSigner requires installation of the @usecapsule/web-sdk SDK. aa-signers lists it as an optional dependency.

npm i -s @usecapsule/web-sdk
yarn add @usecapsule/web-sdk


import { createCapsuleSigner } from "./capsule";

const capsuleSigner = await createCapsuleSigner();

const address = await capsuleSigner.getAddress();

const details = await capsuleSigner.getAuthDetails();

const signedMessage = await capsuleSigner.signMessage("test");

const typedData = {
  types: {
    Request: [{ name: "hello", type: "string" }],
  primaryType: "Request",
  message: {
    hello: "world",
const signTypedData = await capsuleSigner.signTypedData(typedData);
import { sepolia } from "@alchemy/aa-core";
import { CapsuleSigner } from "@alchemy/aa-signers/capsule";
import { Environment } from "@usecapsule/web-sdk";
import { http } from "viem";

export const createCapsuleSigner = async () => {
  // get an API Key by filling out this form:
  const capsuleSigner = new CapsuleSigner({
    env: Environment.DEVELOPMENT,
    apiKey: "CAPSULE_API_KEY",
    walletConfig: {
      chain: sepolia,
      // get your own Alchemy API key at:
      transport: http(`${sepolia.rpcUrls.alchemy.http[0]}/ALCHEMY_API_KEY`),

  await capsuleSigner.authenticate();

  return capsuleSigner;