Skip to content

discv5/discv5_bootnodes.hpp

Namespaces

Name
discv5

Classes

Name
class discv5::IBootnodeSource
Abstract interface for providers of bootstrap seed records.
class discv5::StaticEnrBootnodeSource
Bootstrap source backed by a fixed list of "enr:…" URI strings.
class discv5::StaticEnodeBootnodeSource
Bootstrap source backed by a fixed list of "enode://…" URI strings.
class discv5::ChainBootnodeRegistry
Per-chain bootstrap seed registry.

Types

Name
enum class uint64_t ChainId { kEthereumMainnet = 1, kEthereumSepolia = 11155111, kEthereumHolesky = 17000, kPolygonMainnet = 137, kPolygonAmoy = 80002, kBscMainnet = 56, kBscTestnet = 97, kBaseMainnet = 8453, kBaseSepolia = 84532}
EVM chain identifiers supported by ChainBootnodeRegistry.

Types Documentation

enum ChainId

Enumerator Value Description
kEthereumMainnet 1
kEthereumSepolia 11155111
kEthereumHolesky 17000
kPolygonMainnet 137
kPolygonAmoy 80002
kBscMainnet 56
kBscTestnet 97
kBaseMainnet 8453
kBaseSepolia 84532

EVM chain identifiers supported by ChainBootnodeRegistry.

Add new entries here when additional chains need to be supported.

Source code

// Copyright 2025 GeniusVentures
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include <memory>
#include <string>
#include <vector>

#include <discv5/discv5_error.hpp>
#include <discv5/discv5_types.hpp>

namespace discv5
{

// ---------------------------------------------------------------------------
// IBootnodeSource — abstract source of bootstrap seed records
// ---------------------------------------------------------------------------

class IBootnodeSource
{
public:
    virtual ~IBootnodeSource() = default;

    [[nodiscard]] virtual std::vector<std::string> fetch() const noexcept = 0;

    [[nodiscard]] virtual std::string name() const noexcept = 0;
};

// ---------------------------------------------------------------------------
// StaticEnrBootnodeSource
// ---------------------------------------------------------------------------

class StaticEnrBootnodeSource : public IBootnodeSource
{
public:
    explicit StaticEnrBootnodeSource(
        std::vector<std::string> enr_uris,
        std::string              name = "static-enr") noexcept;

    [[nodiscard]] std::vector<std::string> fetch() const noexcept override;
    [[nodiscard]] std::string              name()  const noexcept override;

private:
    std::vector<std::string> enr_uris_;
    std::string              name_;
};

// ---------------------------------------------------------------------------
// StaticEnodeBootnodeSource
// ---------------------------------------------------------------------------

class StaticEnodeBootnodeSource : public IBootnodeSource
{
public:
    explicit StaticEnodeBootnodeSource(
        std::vector<std::string> enode_uris,
        std::string              name = "static-enode") noexcept;

    [[nodiscard]] std::vector<std::string> fetch() const noexcept override;
    [[nodiscard]] std::string              name()  const noexcept override;

private:
    std::vector<std::string> enode_uris_;
    std::string              name_;
};

// ---------------------------------------------------------------------------
// ChainId
// ---------------------------------------------------------------------------

enum class ChainId : uint64_t
{
    kEthereumMainnet   = 1,
    kEthereumSepolia   = 11155111,
    kEthereumHolesky   = 17000,
    kPolygonMainnet    = 137,
    kPolygonAmoy       = 80002,
    kBscMainnet        = 56,
    kBscTestnet        = 97,
    kBaseMainnet       = 8453,
    kBaseSepolia       = 84532,
};

// ---------------------------------------------------------------------------
// ChainBootnodeRegistry
// ---------------------------------------------------------------------------

class ChainBootnodeRegistry
{
public:
    ChainBootnodeRegistry() = default;

    [[nodiscard]] static std::unique_ptr<IBootnodeSource> for_chain(ChainId chain_id) noexcept;

    [[nodiscard]] static std::unique_ptr<IBootnodeSource> for_chain(uint64_t chain_id_int) noexcept;

    [[nodiscard]] static const char* chain_name(ChainId chain_id) noexcept;

private:
    // Per-chain factory helpers.
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_ethereum_mainnet()  noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_ethereum_sepolia()  noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_ethereum_holesky()  noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_polygon_mainnet()   noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_polygon_amoy()      noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_bsc_mainnet()       noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_bsc_testnet()       noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_base_mainnet()      noexcept;
    [[nodiscard]] static std::unique_ptr<IBootnodeSource> make_base_sepolia()      noexcept;
};

} // namespace discv5

Updated on 2026-04-13 at 23:22:46 -0700