Skip to main content
In this guide, you’ll learn how to perform a full EIP-712-based Ethereum address verification for Farcaster using:
  • Privy RPC for secure off-chain signing
  • Viem for EIP-712 hash computation and local signature verification
  • Neynar API for submitting the verification to Farcaster
This tutorial is for advanced users who want to automate or deeply understand the Farcaster address verification process, including smart contract wallets.

Prerequisites

  • Node.js ≥ 18
  • A .env file with:
  • Install dependencies:

1. Setup & Imports

Start by importing dependencies and loading your environment variables:

2. Environment Variables & Constants

Define your configuration and constants:

3. EIP-712 Domain & Types

These are taken from Farcaster’s official EIP-712 spec:
We recommend using their package to import these but they’re providing for clarity.

4. Compose the Typed Data

Build the EIP-712 message to be signed. Make sure to include the correct chainId and protocol fields as these are different for smart account verification:

5. Compute the EIP-712 Hash

Use Viem’s hashTypedData to get the digest for signing:
We generate the hashTypedData directly due to an issue with privys typed data signers.

6. Sign via Privy RPC

Request a signature from Privy over the EIP-712 hash:
It is necessary to use secp256k1_sign due to the aforementioned issue with their typed signers.

7. Local Signature Verification

Double-check the signature locally before submitting:

8. Submit to Neynar

Send the verification to Neynar for on-chain registration:

9. Error Handling

If anything fails, log and exit:

References & Further Reading

If you have questions or want to share what you built, tag @neynar on Farcaster or join the Slack!
privy-validation-signer.ts