Create New Farcaster Account
Create a Farcaster Account with Wallet Integration
This document outlines the steps to successfully create a Farcaster account without having a end user mnemonic.
Follow the example code while reading the guide for better understanding
Prerequisites
- A browser with a wallet extension (e.g., MetaMask, Coinbase, etc.) installed.
- Access to the Farcaster API and ID Registry smart contract.
- Familiarity with JavaScript and Ethereum wallet interactions.
Step 1: Connect a Wallet
To connect a wallet in the browser:
- Check if the browser supports
window.ethereum
. - Use
eth_requestAccounts
to request wallet connection.
Code Example:
Step 2: Switch to the Optimism Network
To interact with the ID Registry contract, ensure the wallet is on the Optimism network.
Code Example:
Step 3: Fetch FID
Use the GET-/v2/farcaster/user/fid
endpoint to retrieve the FID of the account that will be transferred to the wallet’s address
Code Example:
Step 4: Generate signTypedData
with Viem
To generate a signature for FID registration:
- Fetch the nonce from the ID Registry contract.
- Create EIP-712 typed data and request a signature from the wallet.
Code Example:
Step 5: Check fname
Availability
Before registering a username, check if it is available using the GET /v2/farcaster/fname/availability
endpoint.
Code Example:
Step 6: Call the POST-/v2/farcaster/user
Endpoint
Submit the required data to create the Farcaster account.
Code Example:
Conclusion
By following these steps, you can create an account using the user’s wallet. (No mnemonic required)