Create new Farcaster Account
Currently, this API is allowlisted. Please get in touch with us if you wish to access this feature.
Currently, this API is allowlisted. Please get in touch with us if you wish to access this feature.
Each new user account costs $X (based on the contract) and the total will be charged at the end of the month. Related API: Register new account
This guide enables developers to seamlessly create and register new user accounts on Farcaster through Neynar. This API is allowlisted so if you’re interested in using it, reach out to @rish . By the end, you will:
- Claim and register a new user account.
- Assign a fname and username to the new user account.
- Obtain a
signer_uuid
for the new user account and make changes on Farcaster. - Get an understanding of the entire flow behind the scenes.
Prerequisites
- Ensure you’re allowlisted for the Register new user API (contact rish if needed)
- Installation of curl, yarn, and Node.js and npm.
Step 1: Claim an account for the new user
To register a new user, you need to claim an account for that user.
API Call
Note: Replace NEYNAR_API_KEY with your actual API key.
Responses
In the next step, you’ll need this fid here to generate a signature.
Step 2: Ask the user to sign a message accepting their new Farcaster account
To create a Farcaster account, users must sign a message proving they’re willing to accept the account using a particular wallet address. The user needs to sign a message containing
- fid (fetched in the previous step)
- the address that will custody the Farcaster account (connected address on the client/app developer)
- and a deadline until which their signature is valid. (generated by the client/app developer)
Usually, client or application developers must implement this step by constructing a message and asking the user to sign it in their connected web3 wallet.
However, for the sake of testing out the flow, here’s a script that effectively produces the equivalent signatures you would get back from eth.sign
Setup project
Install Dependencies
Create the Script
Create a file named generate-required-parameters.js
Paste the following script in it. This script generates certain parameters that you’ll need to make the next API call.
Replace FID_TO_COLLECT_SIGNATURE_FOR
with fid returned from GET - /v2/farcaster/user/fid
and NEW_ACCOUNT_MNEMONIC
with a new account MNEMONIC.
Execute Script
Run the script to generate the necessary parameters for user registration. Get the FID i.e UNIQUE_FID
from Step 1 and pass it on in the following command
Script Output
You’ll receive output containing several values, including deadline
, requested_user_custody_address
, fid
, signature
Step 3: Ask the user to pick their fname (optional)
Client applications should ask users to pick a username for their Farcaster account. The fname availability API should be used to check if their chosen username is available. The fname should match the following regex - /^[a-z0-9][a-z0-9-]{0,15}$/
. Official regex defined in the farcaster/core library
Step 4: Register the User
Construct a POST request with the generated parameters to finalize the user’s registration.
Finalize Registration
Responses
Step 5: Profile setup (optional)
Using the approved signer_uuid from the response in Step 4, you can ask the user to update their profile by picking a profile photo, display name, bio, and more.
Was this page helpful?