> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gelato.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Verifier Node

> Learn how to run a Verifier Node

A Verifier Node is a crucial component in securing your rollup by verifying the accuracy of data posted by the sequencer on the settlement layer. It acts as an observation node that monitors the rollup protocol, ensuring its integrity and security.

## Downloading the Client

To begin, download the appropriate client based on your operating system:

* `verifier-linux.zip`
* `verifier-macos.zip`
* `verifier-win.zip`

Unzip the downloaded file to get a folder containing the verifier node application:

* Linux: `verifier-linux/verifier-node-app-linux`
* macOS: `verifier-macos/verifier-node-app-macos`
* Windows: `verifier-win/verifier-node-app-win.exe`

## Minting the Node Key

Before running a node, an ERC2771 node key is required.

### Getting the Gas Token

To mint the node key, you need the custom gas token of the chain. Visit the network's public page and request the custom gas token from the faucet. After receiving it on the testnet, bridge it to the target chain following the instructions on the page.

### Minting the Key

Once you have the gas token, mint the node key by calling the mint function on the contract:

1. Navigate to `NodeKey.mint`
2. Fill in the required parameters:
   * `_to`: Address to mint to
   * `_amount`: Number of NFTs to mint

> Note: Projects can build a frontend page to make this process seamless and customized for users.

### Delegating the Key

After minting your node key, delegate rights to an Operator to sign attestation transactions on your behalf. This ensures secure and efficient operation of your node.

1. Navigate to `DelegateRegistry.delegateERC721`
2. Fill in the required parameters:
   * `to`: Operator address
   * `contract_`: NodeKey contract address
   * `tokenId`: ID of node key NFT
   * `rights`: `0x0000000000000000000000000000000000000000000000000000000000000000`
   * `enable`: true
   * `send native CGT`: 0

> Note: For production projects, this step will be done on delegate.xyz.

## Getting a Gelato API Key

The Gelato API Key is crucial for running the node as it allows the node to use Gelato for transaction fees. This simplifies the process by enabling the use of various tokens (like USDC) to pay for gas fees.

To obtain the Gelato API Key:

1. Go to [Gelato App](https://app.gelato.cloud)
2. Connect your wallet to create your account
3. Click "Create App" and complete the basic details
4. After creating the app, go to the details and copy the API key

## Running the Node Client

### On a Personal Computer

#### Using the CLI

1. Open the terminal or command prompt
2. Navigate to the directory containing the verifier node application
3. Execute the application:
   * Linux: `./verifier-node-app-linux`
   * macOS: `./verifier-node-app-macos`
   * Windows: `verifier-node-app-win.exe`
4. When prompted, enter the required details:
   * Operator private key
   * Gelato Relay API Key
   * Node key IDs

#### Using the .env File

To avoid entering settings each time you launch the application, you can use a `.env` file:

1. Create a `.env` file in the folder containing the node application
2. Add the following environment variables:

```env theme={null}
OPERATOR_PK=
RELAY_API_KEY=
# Set either one
#------------1-------------
NODE_KEY_IDS= # [1,2,3]
#------------2-------------
AUTO_KEY_IDS=true
WALLETS=[]
# [] (Use all fetched node key IDs delegated to operator) or
# ["0x...","0x..."] (Use fetched node key IDs that are delegated to operator and owned by defined wallets)
#-------------------------
# Optionals
DEBUG= # true/false
ONCE= # true/false
INTERVAL= # In ms (Must be > 60000)
L1_RPC_URL=
# Your personal RPC URL of settlement chain
# Setting `L1_RPC_URL` is highly recommended for better reliability and performance
```

### On a Server

The verifier node is also available as a Docker image. Follow these steps to run it on a server:

1. Create a Cloud Run job pulling the `gelatodigital/verifier-node` image
2. Set up the environment variables
3. Add a scheduler trigger to execute the container every hour

## Claiming Rewards

To claim rewards, call the `claimReward` function on the Referee smart contract:

```solidity theme={null}
function claimReward(uint256 nodeKeyId, uint256 numberOfBatches) external
```

With foundry cast:

```bash theme={null}
$ cast calldata "claimReward(uint256,uint256)" ${nodeKeyId} 50
```

You will get the payload to call that looks like `0x86bb8f3700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000032`

Send a transaction with the payload:

```bash theme={null}
$ cast send --rpc-url ${RPC_URL} --private-key ${privateKey} ${REFEREE_ADDRESS} ${payload}
```

## Smart Contracts

As part of the Verifier Node package, Gelato provides essential smart contracts for this service:

* **NodeKey**: NFT contract for node licenses
* **Referee**: Manages attestations and rewards
* **NodeRewards**: Handles reward distribution

These contracts serve as the baseline and can be customized by projects to fit their specific requirements.

## Benefits of Running a Verifier Node

* **Community Engagement**: Encourage community members to take an active role in securing the rollup
* **Revenue Source**: Projects can use Verifier Nodes as a revenue source through Node License sales
* **Decentralization**: Enable users to verify blocks and secure the network in exchange for rewards
* **Security and Reliability**: All smart contracts and the node client undergo rigorous audits

## Package Includes

* **Smart Contracts**: Essential contracts for running the Node Sale
* **Node Client**: User-friendly client for easy setup and operation
* **Hosted Node Integrations**: Partnerships with node hosting providers for simplified deployment
