Skip to content

NetworkId (Class)

Network identifier with optional suffix.

Represents a specific Kaspa network, optionally with a numeric suffix for testnets (e.g., "testnet-10", "testnet-11").

default_p2p_port property

default_p2p_port: int

The default P2P port for this network.

network_type property

network_type: NetworkType

The base network type (Mainnet, Testnet, Devnet, Simnet).

suffix property

suffix: Optional[int]

The optional numeric suffix (e.g., 10 for testnet-10), or None if not set.

__eq__

__eq__(other: object) -> bool

__new__

__new__(network_id: Any) -> NetworkId

Create a new NetworkId.

PARAMETER DESCRIPTION
network_id

A network string ("mainnet", "testnet-10") or NetworkType.

TYPE: Any

RETURNS DESCRIPTION
NetworkId

A new NetworkId instance.

TYPE: NetworkId

RAISES DESCRIPTION
Exception

If the network_id format is invalid.

__str__

__str__() -> str

The string representation.

RETURNS DESCRIPTION
str

The NetworkId as a string

TYPE: str

address_prefix

address_prefix() -> str

Get the address prefix for this network.

RETURNS DESCRIPTION
str

The prefix string ("kaspa", "kaspatest", "kaspadev", or "kaspasim").

TYPE: str

is_mainnet

is_mainnet() -> bool

Check if this is the mainnet.

RETURNS DESCRIPTION
bool

True if this is mainnet, False otherwise.

TYPE: bool

to_prefixed

to_prefixed() -> str

Get the prefixed string representation (e.g., "kaspa-mainnet").

RETURNS DESCRIPTION
str

The prefixed network identifier.

TYPE: str

to_string

to_string() -> str

Get the string representation (e.g., "mainnet", "testnet-10").

RETURNS DESCRIPTION
str

The network identifier string.

TYPE: str

with_suffix staticmethod

with_suffix(network_type: str | NetworkType, suffix: int) -> NetworkId

Create a NetworkId with a specific suffix.

PARAMETER DESCRIPTION
network_type

The base network type.

TYPE: str | NetworkType

suffix

The numeric suffix (e.g., 10 for testnet-10).

TYPE: int

RETURNS DESCRIPTION
NetworkId

A new NetworkId with the specified suffix.

TYPE: NetworkId