earth

Set Your Farcaster Location

April 16, 2025

Farcaster supports sharing your general location using a Geo URI—a standardized way to express geographic coordinates. This is part of FIP-18, which defines how to encode location data without revealing precise details.

To submit a location, you’ll need a signer that’s already been added to your Farcaster account. If you haven’t done that yet, follow this guide first.

Location data is optional and can be updated or removed at any time. Let’s walk through how to set yours.

Pick Your Coordinates

Latitude and longitude coordinates are used to represent your location on Farcaster. To get your location in the correct format, use latlong.net and round to two decimal places for privacy and FIP-18 compliance.

For example, Dallas, TX becomes:

geo:32.77,-96.79

Script

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);

// Load the authorized signer
const privateKeyBytes = hexToBytes(process.env.WALLET_SIGNER_PRIVATE_KEY! as Hex);
const signer = new NobleEd25519Signer(privateKeyBytes);

// Use a geo URI in the format "geo:latitude,longitude"
const geo = 'geo:32.77,-96.79'; // Dallas, TX

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

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

// Encode and submit to the hub
const data = Message.encode(message.value).finish();
console.log('Encoded message:', data);

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 submitted, your location will appear on your profile in Farcaster clients that support UserDataType.LOCATION. Remember:

  • Keep coordinates approximate (2 decimals max)
  • You can remove or update your location at any time by sending a new message
  • For full spec details, see FIP-18

Want to keep building out your profile? Check out these other guides: