> ## Documentation Index
> Fetch the complete documentation index at: https://litprotocol-feat-rusk-sdk.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# EOA (External Owned Account)

> Externally Owned Account (EOA) authentication uses your existing Ethereum account to authenticate and mint PKPs. You can either use a private key or connect your wallet.

# Prerequisites

<Note>
  💰 Need Test Tokens? Visit the [Chronicle Yellowstone
  Faucet](https://chronicle-yellowstone-faucet.getlit.dev/) to get test tokens
  for your EOA account.
</Note>

<Steps>
  <Step title="Create an account">
    <CodeGroup>
      ```typescript wagmi theme={null}
      // 1. import the useWalletClient function from wagmi
      import { useWalletClient } from 'wagmi';

      // 2. Use your connected wallet as the account
      const { data: myAccount } = useWalletClient();
      ```

      ```typescript viem/accounts theme={null}
      // 1. import the privateKeyToAccount function from viem/accounts
      import { privateKeyToAccount } from 'viem/accounts';

      // 2. Convert your private key to a viem account object that can be used for payment operations.
      const myAccount = privateKeyToAccount(
        process.env.PRIVATE_KEY as `0x${string}`
      );
      ```
    </CodeGroup>
  </Step>

  <Step title="Authenticate with EOA">
    Use the `WalletClientAuthenticator` or `ViemAccountAuthenticator` to authenticate your connected wallet and generate auth data.

    <CodeGroup>
      ```ts wagmi theme={null}
      import { WalletClientAuthenticator } from '@lit-protocol/auth';

      const authData = await WalletClientAuthenticator.authenticate(walletClient);

      // Override SIWE fields (e.g., when running on production domains)
      const authDataForProd = await WalletClientAuthenticator.authenticate(
        walletClient,
        undefined,
        {
          domain: 'example.com',
          uri: 'https://example.com/login',
        }
      );
      ```

      ```ts viem/accounts theme={null}
      import { ViemAccountAuthenticator } from '@lit-protocol/auth';

      const authData = await ViemAccountAuthenticator.authenticate(myAccount);
      ```
    </CodeGroup>
  </Step>

  <Step title="Get or Mint a PKP">
    You can select an existing PKP associated with your account or mint a new one.

    <CodeGroup>
      ```ts Mint a fresh PKP theme={null}
      const mintedPkpWithEoaAuth = await litClient.mintWithAuth({
        account: myAccount, // or walletClient depending on method
        authData: authData,
        scopes: ['sign-anything'],
      });
      ```

      ```ts Using an existing PKP theme={null}
      const result = await litClient.viewPKPsByAuthData({
        authData: {
          authMethodType: authData.authMethodType,
          authMethodId: authData.authMethodId,
        },
        pagination: {
          limit: 5,
          offset: 0,
        }
      });
      ```
    </CodeGroup>
  </Step>

  <Step title="Generate Auth Context">
    Use your PKP's public key to create an AuthContext. This method will cache two things:

    1. session key pair - a temporary cryptographic key pair generated on the client side that acts as a temporary identity for the client application. It consists of:
       * A public key - shared with the Lit nodes
       * A secret key (private key) - kept securely on the client
    2. Delegation AuthSig (aka. the inner auth sig) - a cryptographic attestation from the Lit Protocol nodes that authorises your session key to act on behalf of your PKP.

    ```ts theme={null}

    const authContext = await authManager.createPkpAuthContext({
      authData: authData, // <-- Retrieved earlier
      pkpPublicKey: pkpInfo.pubkey,
      authConfig: {
        resources: [
          ["pkp-signing", "*"],
          ["lit-action-execution", "*"],
        ],
        expiration: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(),
        statement: "",
        domain: window.location.origin,
      },
      litClient: litClient,
    });
    ```
  </Step>
</Steps>
