Read
nonces
Returns the next available nonce for an address. Used for generating EIP-712 signatures in addFor.| Parameter | type | Description |
|---|---|---|
| owner | address | The address to query the nonce for |
Write
add
Add a new key for the caller’s fid and set its state toAdded. Revert if the key is already registered.
| Parameter | type | Description |
|---|---|---|
| keyType | uint32 | Must be set to 1. This is currently the only supported keyType. |
| key | bytes | The public key to add |
| metadataType | uint8 | Must be set to 1. This is currently the only supported metadataType. |
| metadata | bytes | Encoded SignedKeyRequestMetadata |
addFor
Add a key on behalf of another fid by providing a signature. The owner must sign an EIP-712Add message approving the key. Reverts if the key is already registered.
| Parameter | type | Description |
|---|---|---|
| fidOwner | address | Address of the fid owner |
| keyType | uint32 | Must be set to 1. This is currently the only supported keyType. |
| key | bytes | The public key to add |
| metadataType | uint8 | Must be set to 1. This is currently the only supported metadataType. |
| metadata | bytes | Encoded SignedKeyRequestMetadata |
| deadline | uint256 | Signature expiration timestamp |
| sig | bytes | EIP-712 Add signature from fidOwner |
Add signature
To add a key on behalf of another account, you must provide an EIP-712 typed signature from the account in the following format:Add(address owner,uint32 keyType,bytes key,uint8 metadataType,bytes metadata,uint256 nonce,uint256 deadline)
| Parameter | type | Description |
|---|---|---|
| owner | address | Address that owns the fid. The typed message must be signed by this address. |
| keyType | uint32 | Must be set to 1. This is currently the only supported keyType. |
| key | bytes | The public key to add |
| metadataType | uint8 | Must be set to 1. This is currently the only supported metadataType. |
| metadata | bytes | Encoded SignedKeyRequestMetadata |
| nonce | uint256 | Current nonce of the owner address |
| deadline | uint256 | Signature expiration timestamp |
[@farcaster/hub-web]
[Viem]
[helpers.ts]
[metadata.ts]
[signer.ts]
[clients.ts]
Errors
| Error | Selector | Description |
|---|---|---|
| InvalidMetadata | bcecb64a | The signed metadata provided with the key is invalid. |
| InvalidSignature | 8baa579f | The provided signature is invalid. It may be incorrectly formatted, or signed by the wrong address. |
| SignatureExpired | 0819bdcd | The provided signature has expired. Collect a new signature from the signer with a later deadline timestamp. |
Source
KeyGateway.sol
