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

# Fetch Signers - Backend

> This guide demonstrates how to get a list of signers for an account if the developer has the user's mnemonic/account private key (If not check: [Frontend (Wallet Integration)](docs/fetch-signers-frontend-wallet-integration))

<Info>
  ### Related API: [List signers](/reference/fetch-signers)
</Info>

## **Prerequisites**

<Steps>
  <Step title="Node.js Installed">
    Ensure you have Nodejs installed on your system. You can download it from [Node.js' official website](https://nodejs.org/).
  </Step>

  <Step title="API Key and Mnemonic">
    Obtain an API key from the [dev portal](https://dev.neynar.com/app) Ensure you have a valid Ethereum mnemonic phrase of the account with a signer associated with the above API key.
  </Step>

  <Step title="Dependencies Installed">
    Install the required packages:

    <CodeGroup>
      ```bash Shell theme={"system"}
      yarn add siwe viem @neynar/nodejs-sdk
      ```
    </CodeGroup>
  </Step>
</Steps>

## **Code Breakdown and Steps**

<Steps>
  <Step title="Import Required Libraries">
    The code begins by importing the necessary libraries:

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      import { SiweMessage } from "siwe";
      import { mnemonicToAccount } from "viem/accounts";
      import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";
      ```
    </CodeGroup>
  </Step>

  <Step title="Define Your Mnemonic">
    Replace `"YOUR_MNEMONIC_HERE"` with your Ethereum mnemonic phrase:

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      const mnemonic = "YOUR_MNEMONIC_HERE";
      ```
    </CodeGroup>
  </Step>

  <Step title="Convert Mnemonic to Account">
    The `mnemonicToAccount` function converts your mnemonic into an account object:

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      const account = mnemonicToAccount(mnemonic);
      ```
    </CodeGroup>
  </Step>

  <Step title="Configure Neynar API Client">
    Replace `"YOUR_API_KEY_HERE"` with your API key and set the correct base path for the Neynar API:

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      const config = new Configuration({
        apiKey: "YOUR_API_KEY_HERE",
      });

      const client = new NeynarAPIClient(config);
      ```
    </CodeGroup>
  </Step>

  <Step title="Create the SIWE Message">
    The `createSiweMessage` function generates a SIWE message with details such as domain, address, and [nonce](/reference/fetch-nonce):

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      async function createSiweMessage(address, statement) {
        const { nonce } = await client.fetchNonce();

        const message = new SiweMessage({
          scheme: "http",
          domain: "localhost:8080",
          address,
          statement,
          uri: "http://localhost:8080",
          version: "1",
          chainId: "1",
          nonce: nonce,
        });

        return message.prepareMessage();
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Sign and Verify the Message">
    The `fetchSigners` function handles the signing process and fetches signers:

    **Note:** The `address` should be the `custody_address` of the farcaster account ([Check custody\_address in User API](/reference/fetch-bulk-users))

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      async function fetchSigners() {
        const address = account.address;

        let message = await createSiweMessage(
          address,
          "Sign in with Ethereum to the app."
        );

        const signature = await account.signMessage({ message });

        const { signers } = await client.fetchSigners({ message, signature });

        return signers;
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="Execute the Function">
    Call the `fetchSigners` function and handle success or errors:

    <CodeGroup>
      ```javascript Javascript theme={"system"}
      fetchSigners()
        .then((signers) => {
          console.log("\n\nsigners:", signers, "\n\n");
        })
        .catch((error) => {
          console.error("error:", error);
        });
      ```
    </CodeGroup>
  </Step>
</Steps>

## **Expected Output**

<CodeGroup>
  ```json JSON theme={"system"}
  [
    {
      "object": "signer",
      "signer_uuid": "19d0c5fd-9b33-4a48-a0e2-bc7b0555baec",
      "public_key": "0xe4abc135d40f8a6ee216d1a6f2f4e82476dff75f71ea53c5bdebca43f5c415b7",
      "status": "approved",
      "fid": 0
    },
    {
      "object": "signer",
      "signer_uuid": "08c71152-c552-42e7-b094-f510ff44e9cb",
      "public_key": "0xe4cd577123def73295dd9991c589b59b48cdc976b5e83a9ad8d2a13fcfcc0e72",
      "status": "approved",
      "fid": 0
    }
  ]
  ```
</CodeGroup>

For additional help, [feel free to contact us](https://neynar.com/slack).
