Your display name is what people see in clients like Warpcast when they visit your profile. Unlike your username (or fname), which must be reserved, your display name doesn’t require a reservation and can be set to any text-based value.
In this post, you’ll use your signer key to create a signed message that sets your display name for your FID. Once submitted to a hub, your new display name will appear across supported Farcaster clients.
Before you begin, make sure you’ve:
You can view the complete script on GitHub to copy, customize, or run it end-to-end.
To publish activity on Farcaster, you need to sign it with an authorized key and send it to a hub. We’ll use the signer we set up earlier.
Load the signer’s private key from an environment variable, then create a signer instance:
import { hexToBytes, type Hex } from 'viem';
import { NobleEd25519Signer } from '@farcaster/core';
const privateKeyBytes = hexToBytes(process.env.WALLET_SIGNER_PRIVATE_KEY! as Hex);
const signer = new NobleEd25519Signer(privateKeyBytes);
Make sure this key belongs to a signer already registered to your FID. If not, add a signer first.
Next, we’ll create and sign a message that sets the display name.
import { FarcasterNetwork, makeUserDataAdd, UserDataType } from '@farcaster/core';
const fid = Number(process.env.WALLET_FID);
const displayName = 'dr. dooloo';
const message = await makeUserDataAdd(
{ type: UserDataType.DISPLAY, value: displayName },
{ fid, network: FarcasterNetwork.MAINNET },
signer
);
console.log(message);
This prepares a signed message that tells the network: “This FID is now using dr. dooloo as its display name.” Your display name can be anything, but clients may truncate longer values. Stick to something short and sweet.
With your message signed, the final step is to send it to a Farcaster hub. Hubs validate and propagate user messages across the network, making your display name visible in clients.
You can use any public or self-hosted hub endpoint. We’ll use the public hub generously provided by Pinata.
import { Message } from '@farcaster/core';
const HUB_ENDPOINT = 'https://hub.pinata.cloud';
// Encode the message in binary format
const data = Message.encode(message.value).finish();
// Submit the message to the hub
const response = await fetch(`${HUB_ENDPOINT}/v1/submitMessage`, {
method: 'post',
headers: { 'Content-Type': 'application/octet-stream' },
body: data,
});
console.log(await response.json());
If successful, your new display name should show up on your profile within a few moments, depending on the client.
Your new display name is now live and should appear in Farcaster clients like Warpcast shortly after the hub processes your message.
Here’s what you might want to do next:
Add a bio, profile picture, and other user data using the same pattern shown in this post.
Open a Farcaster client like Warpcast or Neynar to confirm that your display name is showing correctly.