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- 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
Responses
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)
Setup project
Install Dependencies
Create the Script
Create a file namedgenerate-required-parameters.js
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.eUNIQUE_FID
from Step 1 and pass it on in the following command
Script Output
You’ll receive output containing several values, includingdeadline
, requested_user_custody_address
, fid
, signature
Step 3: Add a managed signer to new account (optional)
If you want to add a managed signer to the new account during registration, you can include signer details in the registration request. This allows your application to manage the account on behalf of the user.Create a Signer
First, create a signer using the Create Signer API:signer_uuid
and public_key
that you’ll need for the next step.
Generate Signed Key Request Metadata Signature
Use the following script to generate thesigned_key_request_metadata_signature
needed for the registration request.
Install Additional Dependencies
signed_key_request_metadata_signature
along with the signer_uuid
, app_fid
, and deadline
that you’ll include in the registration request.
Step 4: 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