Generate API key
To interact with the offchain system, an API key is required for each ENS name. Here's how you can generate and manage API keys:
Generating an API Key
The generateApiKey method creates an API key for a given ENS name. It requires the signerAddress and a SignerFunction to generate a token. Below is the implementation of the key generation process:
generateApiKey method uses sign message under the hood, it constructs a token which is then sent to backend service. The backend will verify that wallet which requests an api key has required permissions for the name it wants to get api key for.
Below is the implementation of the key generation process using Viem:
Using the API Key
Once the API key is generated, you can set it for an ENS name using the setApiKey method:
This ensures all subsequent requests for the ENS name use the provided API key.