> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neynar.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Messages

> The fundamental data type in the Farcaster network - messages represent actions like casts, reactions, and verifications

A message is the fundamental data type in the Farcaster network.

When an account takes an action like casting a public message, changing its profile, or verifying an Ethereum account, it
generates a new message.

## 1. Message

The message is a protobuf that contains the data, its hash and a signature from the author.

| Field             | Type                                | Label | Description                                                                                                                                                                                                                                                      |
| ----------------- | ----------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data              | [MessageData](#MessageData)         |       | Contents of the message. Alternatively, you can use the data\_bytes to serialize the `MessageData`                                                                                                                                                               |
| hash              | bytes                               |       | Hash digest of data                                                                                                                                                                                                                                              |
| hash\_scheme      | [HashScheme](#HashScheme)           |       | Hash scheme that produced the hash digest                                                                                                                                                                                                                        |
| signature         | bytes                               |       | Signature of the hash digest                                                                                                                                                                                                                                     |
| signature\_scheme | [SignatureScheme](#SignatureScheme) |       | Signature scheme that produced the signature                                                                                                                                                                                                                     |
| signer            | bytes                               |       | Public key or address of the key pair that produced the signature                                                                                                                                                                                                |
| data\_bytes       | bytes                               |       | Alternate to the "data" field. If you are constructing the [MessageData](#MessageData) in a programming language other than Typescript, you can use this field to serialize the `MessageData` and calculate the `hash` and `signature` on these bytes. Optional. |

### 1.1 MessageData

MessageData is a generic envelope that contains a type, fid, timestamp and network which must be present in all
Farcaster messages. It also contains a body whose type is determined by the MessageType.

| Field     | Type                                                                                                                                                                                                                                                                                                                                                                                   | Label | Description                                    |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ---------------------------------------------- |
| type      | [MessageType](#MessageType)                                                                                                                                                                                                                                                                                                                                                            |       | Type of Message contained in the body          |
| fid       | uint64                                                                                                                                                                                                                                                                                                                                                                                 |       | Farcaster ID of the user producing the message |
| timestamp | uint32                                                                                                                                                                                                                                                                                                                                                                                 |       | Farcaster epoch timestamp in seconds           |
| network   | [FarcasterNetwork](#FarcasterNetwork)                                                                                                                                                                                                                                                                                                                                                  |       | Farcaster network the message is intended for  |
| body      | [CastAddBody](#CastAddBody), [CastRemoveBody](#CastRemoveBody), [ReactionBody](#ReactionBody), [VerificationAddAddressBody](#VerificationAddAddressBody), [VerificationRemoveBody](#VerificationRemoveBody), [UserDataBody](#UserDataBody), [LinkBody](#LinkBody), [UserNameProof](#UserNameProof), [FrameActionBody](#FrameActionBody), [LinkCompactStateBody](#LinkCompactStateBody) | oneOf | Properties specific to the MessageType         |

### 1.2 HashScheme

Type of hashing scheme used to produce a digest of MessageData

| Name                 | Number | Description                            |
| -------------------- | ------ | -------------------------------------- |
| HASH\_SCHEME\_NONE   | 0      |                                        |
| HASH\_SCHEME\_BLAKE3 | 1      | Default scheme for hashing MessageData |

### 1.3 Signature Scheme

Type of signature scheme used to sign the Message hash

| Name                       | Number | Description                          |
| -------------------------- | ------ | ------------------------------------ |
| SIGNATURE\_SCHEME\_NONE    | 0      |                                      |
| SIGNATURE\_SCHEME\_ED25519 | 1      | Ed25519 signature (default)          |
| SIGNATURE\_SCHEME\_EIP712  | 2      | ECDSA signature using EIP-712 scheme |

### 1.4 Message Type

Type of the MessageBody

| Name                                           | Number | Description                      |
| ---------------------------------------------- | ------ | -------------------------------- |
| MESSAGE\_TYPE\_NONE                            | 0      | Invalid default value            |
| MESSAGE\_TYPE\_CAST\_ADD                       | 1      | Add a new Cast                   |
| MESSAGE\_TYPE\_CAST\_REMOVE                    | 2      | Remove an existing Cast          |
| MESSAGE\_TYPE\_REACTION\_ADD                   | 3      | Add a Reaction to a Cast         |
| MESSAGE\_TYPE\_REACTION\_REMOVE                | 4      | Remove a Reaction from a Cast    |
| MESSAGE\_TYPE\_LINK\_ADD                       | 5      | Add a Link to a target           |
| MESSAGE\_TYPE\_LINK\_REMOVE                    | 6      | Remove a Link from a target      |
| MESSAGE\_TYPE\_VERIFICATION\_ADD\_ETH\_ADDRESS | 7      | Add a Verification of an Address |
| MESSAGE\_TYPE\_VERIFICATION\_REMOVE            | 8      | Remove a Verification            |
| MESSAGE\_TYPE\_USER\_DATA\_ADD                 | 11     | Add metadata about a user        |
| MESSAGE\_TYPE\_USERNAME\_PROOF                 | 12     | Add or replace a username proof  |
| MESSAGE\_TYPE\_FRAME\_ACTION                   | 13     | Frame action (not stored)        |
| MESSAGE\_TYPE\_LINK\_COMPACT\_STATE            | 14     | Compact state for links          |

### 1.5 Farcaster Network

Farcaster network the message is intended for

| Name                        | Number | Description            |
| --------------------------- | ------ | ---------------------- |
| FARCASTER\_NETWORK\_NONE    | 0      |                        |
| FARCASTER\_NETWORK\_MAINNET | 1      | Public primary network |
| FARCASTER\_NETWORK\_TESTNET | 2      | Public test network    |
| FARCASTER\_NETWORK\_DEVNET  | 3      | Private test network   |

## 2. UserData

A UserData message represents user metadata (e.g. a profile picture url) .

### 2.1 UserDataBody

Body of a UserData message

| Field | Type                          | Label | Description           |
| ----- | ----------------------------- | ----- | --------------------- |
| type  | [UserDataType](#UserDataType) |       | Type of metadata      |
| value | string                        |       | Value of the metadata |

### 2.2 UserDataType

Type of UserData message

| Name                                   | Number | Description                           |
| -------------------------------------- | ------ | ------------------------------------- |
| USER\_DATA\_TYPE\_NONE                 | 0      | Invalid default value                 |
| USER\_DATA\_TYPE\_PFP                  | 1      | Profile Picture for the user          |
| USER\_DATA\_TYPE\_DISPLAY              | 2      | Display Name for the user             |
| USER\_DATA\_TYPE\_BIO                  | 3      | Bio for the user                      |
| USER\_DATA\_TYPE\_URL                  | 5      | URL of the user                       |
| USER\_DATA\_TYPE\_USERNAME             | 6      | Preferred Farcaster Name for the user |
| USER\_DATA\_TYPE\_LOCATION             | 7      | Location for the user                 |
| USER\_DATA\_TYPE\_TWITTER              | 8      | Twitter username for the user         |
| USER\_DATA\_TYPE\_GITHUB               | 9      | GitHub username for the user          |
| USER\_DATA\_TYPE\_BANNER               | 10     | Banner image for the user             |
| USER\_DATA\_PRIMARY\_ADDRESS\_ETHEREUM | 11     | Primary Ethereum address              |
| USER\_DATA\_PRIMARY\_ADDRESS\_SOLANA   | 12     | Primary Solana address                |

See [FIP-196](https://github.com/farcasterxyz/protocol/discussions/196) for more information on Location.
See [FIP-19](https://github.com/farcasterxyz/protocol/discussions/199) for more information on Twitter/X and GitHub usernames.

## 3. Cast

A Cast message is a public post from a user.

### 3.1 CastAddBody

Adds a new Cast message.

| Field               | Type                  | Label        | Description                                 |
| ------------------- | --------------------- | ------------ | ------------------------------------------- |
| embeds\_deprecated  | string                | repeated     | URLs to be embedded in the cast             |
| mentions            | uint64                | repeated     | Fids mentioned in the cast                  |
| parent\_cast\_id    | [CastId](#CastId)     | oneOf parent | Parent cast of the cast                     |
| parent\_url         | string                | oneOf parent | Parent URL of the cast                      |
| text                | string                |              | Text of the cast                            |
| mentions\_positions | uint32                | repeated     | Positions of the mentions in the text       |
| embeds              | [Embed](#Embed)       | repeated     | URLs or cast ids to be embedded in the cast |
| type                | [CastType](#CastType) |              | Type of cast (regular, long, etc.)          |

#### Embed

| Field    | Type              | Label | Description |
| -------- | ----------------- | ----- | ----------- |
| url      | string            |       |             |
| cast\_id | [CastId](#CastId) |       |             |

### 3.2 CastRemoveBody

Removes an existing Cast message.

| Field        | Type  | Label | Description                |
| ------------ | ----- | ----- | -------------------------- |
| target\_hash | bytes |       | Hash of the cast to remove |

### 3.3 CastId

Identifier used to look up a Cast

| Field | Type   | Label | Description                          |
| ----- | ------ | ----- | ------------------------------------ |
| fid   | uint64 |       | Fid of the user who created the cast |
| hash  | bytes  |       | Hash of the cast                     |

## 4. Reaction

A Reaction message creates a relationship between an account and a cast. (e.g. like)

### 4.1 ReactionBody

Adds or removes a Reaction from a Cast

| Field            | Type                          | Label | Description                    |
| ---------------- | ----------------------------- | ----- | ------------------------------ |
| type             | [ReactionType](#ReactionType) |       | Type of reaction               |
| target\_cast\_id | [CastId](#CastId)             |       | CastId of the Cast to react to |
| target\_url      | string                        |       | URL to react to                |

### 4.2 ReactionType

Type of Reaction

| Name                   | Number | Description                              |
| ---------------------- | ------ | ---------------------------------------- |
| REACTION\_TYPE\_NONE   | 0      | Invalid default value                    |
| REACTION\_TYPE\_LIKE   | 1      | Like the target cast                     |
| REACTION\_TYPE\_RECAST | 2      | Share target cast to the user's audience |

## 5. Link

A Link message creates a relationship between two users (e.g. follow)

### 5.1 LinkBody

Adds or removes a Link

| Field            | Type   | Label    | Description                                                                                                             |
| ---------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| type             | string |          | Type of link, \<= 8 characters                                                                                          |
| displayTimestamp | uint32 | optional | User-defined timestamp that preserves original timestamp when message.data.timestamp needs to be updated for compaction |
| target\_fid      | uint64 |          | The fid the link relates to                                                                                             |

## 6. Verification

A Verification message is a proof of ownership of something.

### 6.1 VerificationAddAddressBody

Adds a bi-directional signature proving that an fid has control over an address (supports multiple protocols).

| Field              | Type                  | Label | Description                                          |
| ------------------ | --------------------- | ----- | ---------------------------------------------------- |
| address            | bytes                 |       | Address being verified                               |
| claim\_signature   | bytes                 |       | Signature produced by the user's address             |
| block\_hash        | bytes                 |       | Hash of the latest block when the claim was produced |
| verification\_type | uint32                |       | Type of verification (0 = EOA, 1 = contract)         |
| chain\_id          | uint32                |       | Chain ID of the verification                         |
| protocol           | [Protocol](#Protocol) |       | Protocol of the address (Ethereum, Solana, etc.)     |

### 6.2 VerificationRemoveBody

Removes a Verification of any type

| Field   | Type  | Label | Description                           |
| ------- | ----- | ----- | ------------------------------------- |
| address | bytes |       | Address of the Verification to remove |

## 7. Frame Action

Represents an action performed by a user on a frame. This message is not stored on the nodes and cannot be submitted,
only validated.

### 7.1 FrameActionBody

A user action on a frame

| Field           | Type              | Label | Description                                           |
| --------------- | ----------------- | ----- | ----------------------------------------------------- |
| url             | bytes             |       | The original url of the frame as embedded in the cast |
| button\_index   | uint32            |       | The button that was pressed (indexed from 1)          |
| cast\_id        | [CastId](#CastId) |       | The cast id that hosted the frame                     |
| input\_text     | bytes             |       | Any text the user input as part of the action         |
| state           | bytes             |       | Serialized state passed from frame to server          |
| transaction\_id | bytes             |       | Transaction ID for transaction frames                 |
| address         | bytes             |       | Address involved in the frame action                  |

## 8. Protocol

Type of protocol for addresses

| Name               | Number | Description |
| ------------------ | ------ | ----------- |
| PROTOCOL\_ETHEREUM | 0      | Ethereum    |
| PROTOCOL\_SOLANA   | 1      | Solana      |

## 9. CastType

Type of cast

| Name         | Number | Description                 |
| ------------ | ------ | --------------------------- |
| CAST         | 0      | Regular cast                |
| LONG\_CAST   | 1      | Extended length cast        |
| TEN\_K\_CAST | 2      | Ten thousand character cast |

## 10. LinkCompactStateBody

Compact state representation for links

| Field        | Type   | Label    | Description          |
| ------------ | ------ | -------- | -------------------- |
| type         | string |          | Type of link         |
| target\_fids | uint64 | repeated | Array of target fids |
