earth

Set Your Farcaster Profile Picture

April 14, 2025

Your profile picture (PFP) is one of the first things people see on Farcaster. It helps personalize your account and makes your profile more recognizable across clients like Warpcast.

Setting your PFP is a lot like setting a display name or username, it’s just a signed message sent to a Farcaster hub. If you’re not familiar with the underlying process, check out these guides first:

Script

Once you’re ready, here’s how to set your PFP:

import { hexToBytes, type Hex } from 'viem';
import {
	FarcasterNetwork,
	makeUserDataAdd,
	Message,
	NobleEd25519Signer,
	UserDataType,
} from '@farcaster/core';

const HUB_ENDPOINT = 'https://hub.pinata.cloud';
const fid = Number(process.env.WALLET_FID);
const privateKeyBytes = hexToBytes(process.env.WALLET_SIGNER_PRIVATE_KEY! as Hex);
const signer = new NobleEd25519Signer(privateKeyBytes);

// Your PFP URL (hosted image, ideally square and optimized for web)
const pfpUrl = 'https://i.imgur.com/JRM3zjc.png';

// Create a signed message to set the PFP
const message = await makeUserDataAdd(
	{ type: UserDataType.PFP, value: pfpUrl },
	{ fid, network: FarcasterNetwork.MAINNET },
	signer
);

console.log('Signed message:', message);

// Encode and submit the message to a Farcaster hub
const data = Message.encode(message.value).finish();

const response = await fetch(`${HUB_ENDPOINT}/v1/submitMessage`, {
	method: 'post',
	headers: { 'Content-Type': 'application/octet-stream' },
	body: data,
});

console.log('Hub response:', await response.json());

Next Steps

Once the message is processed by the hub, your new profile picture will appear in supported Farcaster clients. Make sure your image is accessible via URL and stays online. If the URL breaks, your PFP will too.

Want to set other parts of your profile? Check out these posts: