controller.ts

Overview

`controller.ts` defines the API controller for interacting with the Arbitrum Nova blockchain network using EVM-compatible RPC calls. It provides RESTful endpoints for estimating gas costs (`POST /gas/estimate`) and retrieving current gas fee recommendations (`GET /gas/fees`).

This file acts as a specialized extension of a generic EVM controller tailored for the Arbitrum Nova network. It connects blockchain data indexing (via Blockbook), gas fee estimation (via a Gas Oracle), and RPC interaction to expose critical gas-related blockchain operations in a secure, validated API.

Key responsibilities include:


Classes and Methods

class ArbitrumNova extends EVM implements BaseAPI, API

This class extends the generic `EVM` controller and implements interfaces [BaseAPI](/projects/291/69264) and `API`. It defines HTTP routes under `/api/v1` with `v1` tags, exposing methods for gas-related blockchain queries specific to Arbitrum Nova.


estimateGas(body: EstimateGasBody): Promise<GasEstimate>

Estimates the gas required for a transaction on the Arbitrum Nova network.

POST /api/v1/gas/estimate
{
  "data": "0x",
  "from": "0x0000000000000000000000000000000000000000",
  "to": "0x6e249a692314bceb8ac43b296262df1800915bf4",
  "value": "1337"
}

Response:
{
  "gasLimit": "30641"
}

getGasFees(): Promise<GasFees>

Retrieves the current recommended gas fees for transactions on the Arbitrum Nova network.

GET /api/v1/gas/fees

Response:
{
  "baseFeePerGas": "10000000",
  "slow": {
    "gasPrice": "1166100000",
    "maxFeePerGas": "1167100000",
    "maxPriorityFeePerGas": "1157100000"
  },
  "average": {
    "gasPrice": "1240550000",
    "maxFeePerGas": "1241050000",
    "maxPriorityFeePerGas": "1231050000"
  },
  "fast": {
    "gasPrice": "1240550000",
    "maxFeePerGas": "1241050000",
    "maxPriorityFeePerGas": "1231050000"
  }
}

Important Implementation Details


Interaction with Other System Components


Visual Diagram

classDiagram
    class ArbitrumNova {
        +estimateGas(body: EstimateGasBody): Promise<GasEstimate>
        +getGasFees(): Promise<GasFees>
    }
    class EVM {
        <<abstract>>
        +service: Service
    }
    class Service {
        -blockbook: Blockbook
        -gasOracle: GasOracle
        -explorerApiUrl: URL
        -client: PublicClient
        -logger: Logger
        +estimateGas(body: EstimateGasBody): Promise<GasEstimate>
        +getGasFees(): Promise<GasFees>
    }
    class Blockbook {
        -httpURL: string
        -wsURL: string
        -logger: Logger
    }
    class GasOracle {
        -logger: Logger
        -client: PublicClient
        -coinstack: string
    }
    class Logger {
        -namespace: string[]
        -level: string
    }
    class PublicClient {}

    ArbitrumNova --|> EVM
    EVM o-- Service
    Service *-- Blockbook
    Service *-- GasOracle
    Service *-- Logger
    Service *-- PublicClient
    Blockbook *-- Logger
    GasOracle *-- Logger
    GasOracle *-- PublicClient

Summary

`controller.ts` is a specialized Arbitrum Nova blockchain API controller that exposes gas estimation and fee retrieval endpoints. It leverages a modular service layer built on shared EVM components and integrates with blockchain indexers and gas oracles to provide accurate and reliable transaction cost data. This file is a critical part of the broader system's API layer, enabling clients to interact seamlessly with the Arbitrum Nova network through standardized REST endpoints.