> ## Documentation Index
> Fetch the complete documentation index at: https://new-docs.squads.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Ephemeral Signers

## Overview

Ephemeral Signers are keys expected to sign a transaction and be discarded immediately after. They present challenges for Smart Wallets that don't execute transactions immediately.

## Problem

An Ephemeral Signer (ES) is a key that signs a transaction and is then discarded. A common example is the `SystemProgram.createAccount` instruction, which requires the new account to be a signer to verify authority.

The `Keypair.generate()` method is typically used by app developers to create ephemeral signers, but this mechanism doesn't work with Smart Wallets that don't execute transactions immediately. The ephemeral keypair will not be available to sign the "execute" transaction because it has already been lost.

## Solution 1: Use createAccountWithSeed

Avoid Ephemeral Signers by using `SystemProgram.createAccountWithSeed` instead of `SystemProgram.createAccount`. The difference is that the latter requires the new account's signature, whereas the former doesn't because the new account is "controlled" by the `basePubkey`.

Example for wrapping SOL via an auxiliary token account:

```jsx theme={null}
// Generate a random seed.
const seed = Keypair.generate().publicKey.toBase58().slice(0, 32);

// Calculate a publicKey that will be controlled by the walletPubkey.
const auxAccountPubkey = await PublicKey.createWithSeed(
  walletPubkey,
  seed,
  TOKEN_PROGRAM_ID
);

// Create token account.
// Using `createAccountWithSeed` allows us to avoid the second signer,
// because this instruction requires signing only from `basePubkey`.
const createAccountIx = SystemProgram.createAccountWithSeed({
  fromPubkey: walletPubkey,
  basePubkey: walletPubkey,
  seed,
  newAccountPubkey: auxAccountPubkey,
  lamports: (await getMinimumBalanceForRentExemptAccount(connection)) + amount,
  space: ACCOUNT_SIZE,
  programId: TOKEN_PROGRAM_ID,
});
```

## Solution 2: Use getEphemeralSigners API

If Solution 1 doesn't fit your needs and you require a second signer, SquadsX exposes the `getEphemeralSigners` API. This allows apps to request ephemeral signers from the wallet. The wallet returns an array of account addresses for use in transactions.

The API is exposed via the Wallet Standard feature detection mechanism:

```jsx theme={null}
import { useWallet } from "@solana/wallet-adapter-react";

const { wallet } = useWallet()

// ...

<button
  onClick={async () => {
    const adapter = wallet?.adapter;

    const ephemeralSignerAddress = adapter &&
      "standard" in adapter &&
      "fuse:getEphemeralSigners" in adapter.wallet.features &&
      (await adapter.wallet.features["fuse:getEphemeralSigners"].getEphemeralSigners(1))[0]

    const ephemeralSignerPubkey = ephemeralSignerAddress ? new PublicKey(ephemeralSignerAddress) : null

    // Use `ephemeralSignerPubkey` in your transaction.
  }}
/>
```

The addresses belong to the next transaction your Squad creates. If your app builds several transactions for one signing request, pass the transaction's position as a second argument for the later ones: `getEphemeralSigners(1, 2)` for the second transaction, `getEphemeralSigners(1, 3)` for the third.

`fuse:getEphemeralSigners` is specific to SquadsX. It was proposed for the Wallet Standard in [sRFC 00019](https://forum.solana.com/t/srfc-00019-wallet-standard-get-ephemeral-signers-feature/340) but has not been adopted.

## Related

* [Overcoming Integration Obstacles](/integrations/squadsx/developer-guide/integration-obstacles)
* [Large Transactions](/integrations/squadsx/developer-guide/large-transactions)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.