Network

Cardano network types.

class pycardano.network.Network(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: CBORSerializable, Enum

Network ID

TESTNET = 0
MAINNET = 1
to_primitive() int

Convert the instance and its elements to CBOR primitives recursively.

Returns:

A CBOR primitive.

Return type:

Primitive

Raises:

SerializeException – When the object or its elements could not be converted to CBOR primitive types.

classmethod from_primitive(value: int) Network

Turn a CBOR primitive to its original class type.

Parameters:
  • cls (CBORBase) – The original class type.

  • value (Primitive) – A CBOR primitive.

  • type_args (Optional[tuple]) – Type arguments for the class.

Returns:

A CBOR serializable object.

Return type:

CBORBase

Raises:

DeserializeException – When the object could not be restored from primitives.