Skip to main content
The Signed Key Request Validator validates the signed metadata associated with keys. The Key Registry calls the validator before adding a key, to check that the provided Signed Key Request is valid. If you want to construct or check a Signed Key Request, use the Signed Key Request Validator.
What is a Signed Key Request? - When a user adds a key to their account (the primary fid), it must include a signature from the person that requested it (the request fid). This enables anyone to identify who requested a specific key. Typically, the primary fid is the end user and the requesting fid is an app the user wishes to connect to.

Read

encodeMetadata

Convert a SignedKeyRequestMetadata struct into bytes to pass into contract functions like add, register.

SignedKeyRequestMetadata struct

The SignedKeyRequestMetadata struct contains data to validate authenticity of a Signed Key Request: requesting fid, the requesting fid owner, and an EIP-712 SignedKeyRequest signature. See below for code examples that demonstrate two methods of generating encoded SignedKeyRequestMetadata — using the @farcaster/hub-web library to sign and encode in a single step, or using Viem to sign and encode separately.
[@farcaster/hub-web]
[Viem]
[signature.ts]
[helpers.ts]
[signer.ts]

validate

Validate an encoded SignedKeyRequestMetadata. The KeyRegistry calls this function internally when a user adds a key to validate the Signed Key Request. If you are creating keys on behalf of users, you can call this function yourself to validate the Signed Key Request created by your app.

SignedKeyRequest signature

The SignedKeyRequest message is an EIP-712 typed signature signed by the requesting fid owner in the following format: SignedKeyRequest(uint256 requestFid,bytes key,uint256 deadline)
Why sign metadata? - The SignedKeyRequest signature proves that the requesting fid asked the primary fid to authorize a key pair. For example, when an app asks a user to add a new key, the app creates a Signed Key Request proving that it made the request and the KeyRegistry emits it in an onchain event. This allows anyone to attribute a signer to the specific person who requested it, which is useful for a wide range of things from knowing which apps are being used to filtering content based on the applications that generated them.
[@farcaster/hub-web]
[Viem]
[helpers.ts]
[signer.ts]

Source

SignedKeyRequestValidator.sol