Fetch Signers - Frontend (Wallet Integration)
This guide demonstrates how to get a list of signers for an account if the developer can’t access the user’s mnemonic. (If the developer has access to the mnemonic, check: Backend)
Related API: Fetch signers
Important Note
The Neynar Client Instantiation and API calls (fetchNonce
and fetchSigners
) should ideally be performed on the backend to protect your API key and maintain security.
Prerequisites
Ethereum-Enabled Browser
Browser Ensure you are using a browser with a wallet like MetaMask installed.
API Key
Obtain an API key from dev portal
Dependencies Installed
Install the required packages:
Code Breakdown and Steps
Import Required Libraries
The code starts by importing the necessary libraries:
Configure Neynar API Client
Set up the Neynar API client with your API key and base path. Note that this should ideally be done on the backend for security reasons:
Create the Wallet Client
The createWalletClient
function initializes a wallet client using the viem
library. It uses window.ethereum
to connect to the browser’s wallet:
Create the SIWE Message
The createSiweMessage
function generates a SIWE message with details such as domain, address, and nonce:
Sign and Verify the Message
The fetchSigners
function retrieves the user’s Ethereum address, generates a SIWE message, signs it, and verifies the signature using the Neynar API.
Note:
- Neynar API should ideally be accessed from the backend
- The
address
should be thecustody_address
of the farcaster account (Check custody_address here)
Execute the Function
Call the fetchSigners
function and handle the response or errors:
Expected Output
For additional help, feel free to contact us.
Was this page helpful?