Skip to content

Eth 2 keymanager

This module contains the Eth2KeyManager class, which is the main class of the eth-2-key-manager-api-client package.

Eth2KeyManager

Eth2KeyManager class is the main class of the eth2-key-manager-api-client package.

It provides a centralized way to manage keys for the Ethereum validators. It handles the following operations:

  • Importing keystores
  • Listing keys
  • Deleting keys
  • Setting fee recipients
  • Listing fee recipients
  • Deleting fee recipients
  • Setting gas limits
  • Getting gas limits
  • Deleting gas limits
  • Deleting remote keys
  • Importing remote keys
  • Listing remote keys

Parameters:

Name Type Description Default
base_url Union[str, None]

The base URL of the Eth2 Key Manager API.

None
token Union[str, None]

The API token to authenticate with the Eth2 Key Manager API.

None
cookies Dict[str, str]

Optional cookies to send with requests.

{}
headers Dict[str, str]

Optional headers to send with requests.

{}
timeout float

The timeout for requests.

10.0
verify_ssl Union[str, bool, SSLContext]

Whether to verify SSL certificates.

False
raise_on_unexpected_status bool

Whether to raise an exception if a request returns an unexpected status code.

False
follow_redirects bool

Whether to follow redirects.

False

Raises:

Type Description
ConfigurationMissing

If the base_url or token is not provided.

Source code in eth_2_key_manager_api_client/eth_2_keymanager.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@attr.s(auto_attribs=True, init=False)
class Eth2KeyManager:
    """Eth2KeyManager class is the main class of the eth2-key-manager-api-client package.

    It provides a centralized way to manage keys for the Ethereum validators. It handles the following operations:

    * Importing keystores
    * Listing keys
    * Deleting keys
    * Setting fee recipients
    * Listing fee recipients
    * Deleting fee recipients
    * Setting gas limits
    * Getting gas limits
    * Deleting gas limits
    * Deleting remote keys
    * Importing remote keys
    * Listing remote keys

    Args:
        base_url: The base URL of the Eth2 Key Manager API.
        token: The API token to authenticate with the Eth2 Key Manager API.
        cookies: Optional cookies to send with requests.
        headers: Optional headers to send with requests.
        timeout: The timeout for requests.
        verify_ssl: Whether to verify SSL certificates.
        raise_on_unexpected_status: Whether to raise an exception if a request returns an unexpected status code.
        follow_redirects: Whether to follow redirects.

    Raises:
        ConfigurationMissing: If the base_url or token is not provided.
    """

    def __init__(
        self,
        base_url: Union[str, None] = None,
        token: Union[str, None] = None,
        cookies: Dict[str, str] = {},
        headers: Dict[str, str] = {},
        timeout: float = 10.0,
        verify_ssl: Union[str, bool, ssl.SSLContext] = False,
        raise_on_unexpected_status: bool = False,
        follow_redirects: bool = False,
    ):
        if base_url is None:
            base_url = os.getenv("ETH_2_KEY_MANAGER_API_BASE_URL")
        if token is None:
            token = os.getenv("ETH_2_KEY_MANAGER_API_TOKEN")
        if base_url is None or token is None:
            raise ConfigurationMissing

        self.client = AuthenticatedClient(
            base_url=base_url,
            token=token,
            cookies=cookies,
            headers=headers,
            timeout=timeout,
            verify_ssl=verify_ssl,
            raise_on_unexpected_status=raise_on_unexpected_status,
            follow_redirects=follow_redirects,
        )
        self.import_keystores = ImportKeystores(self.client)
        self.list_keys = ListKeys(self.client)
        self.delete_keys = DeleteKeys(self.client)
        self.set_fee_recipient = SetFeeRecipient(self.client)
        self.list_fee_recipient = ListFeeRecipient(self.client)
        self.delete_fee_recipient = DeleteFeeRecipient(self.client)
        self.set_gas_limit = SetGasLimit(self.client)
        self.get_gas_limit = GetGasLimit(self.client)
        self.delete_gas_limit = DeleteGasLimit(self.client)
        self.delete_remote_keys = DeleteRemoteKeys(self.client)
        self.import_remote_keys = ImportRemoteKeys(self.client)
        self.list_remote_keys = ListRemoteKeys(self.client)