Skip to main content
This guide walks you through generating a Signed Key Request using viem that need to be passed in while registering auth address

System & Installation Requirements

Prerequisites

  • Node.js >= 18.x (LTS recommended)
  • npm >= 9.x OR yarn >= 1.22.x
Download and install node (if not installed)

Initialize project (optional)

Install viem

OR with yarn:

Code Breakdown and Steps

You can find full code at the end of this guide.
1

Import the required functions

The code starts by importing the necessary libraries:
2

Generate a random mnemonic and derive the auth address

Generates a mnemonic and converts it to an Ethereum address (auth_address)
3

Define EIP-712 domain

Describes the EIP-712 domain (context of signature).
4

Define the EIP-712 message structure

Defines the structure of the message to be signed.
5

Encode the auth_address

Encodes auth_address as 32 bytes.
6

App details

Replace "MNEMONIC_HERE" with your app mnemonic phrase and fid with your app’s fid.
7

Define a deadline

Sets a 24-hour expiration time.
8

Sign the EIP-712 message

Signs the message per EIP-712 standard.
9

Create a sponsor signature

If you want to sponsor the auth address, you can sign the EIP-712 signature again with a basic Ethereum signature. This route needs to be sponsored if not provided then neynar will sponsor it for you and you will be charged in credits.
10

Print output

Prints useful values for further use.
11

Run the code

Save the code in a file, e.g., generateSignedKeyRequest.js, and run it using Node.js:
12

cURL

Use the generated values to make a cURL request to register the auth address. Replace <api-key> with your actual API key and <string> with your redirect URL(if needed).

Full Final Code


Enjoy building! 🚀 For additional help, feel free to contact us.