The Key Registry stores the public keys associated with each Farcaster account. If you want to read information about a Farcaster account’s keys or remove an existing key, use the Key Registry. If you want to add a new key, use the Key Gateway instead.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.
Read
totalKeys
Get the number of active keys (uint256) for an fid.
| Parameter | type | Description |
|---|---|---|
| fid | uint256 | fid to look up |
| state | uint8 (1 for Added, 2 for Removed) | State of the key (added or removed) |
keysOf
List all public keys (bytes[]) for an fid.
| Parameter | type | Description |
|---|---|---|
| fid | uint256 | fid to look up |
| state | uint8 (1 for Added, 2 for Removed) | State of the key (added or removed) |
| startIdx | uint256 (optional) | Start index for pagination |
| batchSize | uint256 (optional) | Batch size for pagination |
keyDataOf
Returns the state (uint8) and keyType (uint32) of particular key for an fid.
| Parameter | type | Description |
|---|---|---|
| fid | uint256 | fid to look up |
| key | bytes | public key to check |
Write
add
Will revert if called directly. Must be called via the Key Gatewayremove
Removes a public key from the caller’s fid and marks it asRemoved.
| Parameter | type | Description |
|---|---|---|
| key | bytes | public key to remove |
removeFor
Remove a key on behalf of another fid by providing a signature. The fid owner must sign an EIP-712Remove message approving the removal. Reverts if the key does not exist or is already removed.
| Parameter | type | Description |
|---|---|---|
| fidOwner | address | fid owner address |
| key | bytes | public key to remove |
| deadline | uint256 | signature deadline |
| sig | bytes | EIP-712 signature from the fidOwner |
Remove signature
To remove a key on behalf of another account, you must provide an EIP-712 typed signature from the account in the following format:Remove(address owner,bytes key,uint256 nonce,uint256 deadline)
| Parameter | type | Description |
|---|---|---|
| owner | address | Address that owns the fid. The typed message must be signed by this address. |
| key | bytes | The public key to remove |
| nonce | uint256 | Current nonce of the owner address |
| deadline | uint256 | Signature expiration timestamp |
[@farcaster/hub-web]
[Viem]
[helpers.ts]
[signer.ts]
[clients.ts]
Errors
| Error | Selector | Description |
|---|---|---|
| ExceedsMaximum | 29264042 | Adding the key exceeds the maximum number of keys allowed per fid (currently 1000) |
| InvalidSignature | 8baa579f | The provided signature is invalid. It may be incorrectly formatted, or signed by the wrong address. |
| InvalidState | baf3f0f7 | The action violates state transition rules. (Adding a key that already exists, removing a key that does not exist, adding a key that has been removed) |
| SignatureExpired | 0819bdcd | The provided signature has expired. Collect a new signature from the signer with a later deadline timestamp. |
Source
KeyRegistry.sol