Skip to content

KMD Version Information

← Back to KMD Client

This example demonstrates how to retrieve version information from the KMD (Key Management Daemon) server using the version() method. Prerequisites:

  • LocalNet running (via algokit localnet start)

From the repository’s examples directory:

Terminal window
cd examples
uv run python kmd_client/01_version.py

View source on GitHub

01_version.py
# ruff: noqa: N999, C901, PLR0912, PLR0915
"""
Example: KMD Version Information
This example demonstrates how to retrieve version information from the KMD
(Key Management Daemon) server using the version() method.
Prerequisites:
- LocalNet running (via `algokit localnet start`)
"""
import sys
from shared import (
create_kmd_client,
print_error,
print_header,
print_info,
print_step,
print_success,
)
def main() -> None:
print_header("KMD Version Information Example")
# Create a KMD client connected to LocalNet
kmd = create_kmd_client()
# =========================================================================
# Step 1: Get Version Information
# =========================================================================
print_step(1, "Getting KMD version information with version()")
try:
version_response = kmd.version()
version_info = version_response.versions
print_success("Version information retrieved successfully!")
print_info("")
print_info("Supported API versions:")
if len(version_info) == 0:
print_info(" (No versions reported)")
else:
for version in version_info:
print_info(f" - {version}")
# =========================================================================
# Summary
# =========================================================================
print_header("Summary")
print_info("This example demonstrated:")
print_info(" 1. version() - Retrieves KMD server version information")
print_info("")
print_info("Key fields in version response:")
print_info(" - versions: Array of supported API version strings")
print_info("")
print_info("The KMD (Key Management Daemon) is responsible for:")
print_info(" - Managing wallets and their keys")
print_info(" - Signing transactions securely")
print_info(" - Storing keys in encrypted wallet files")
except Exception as e:
print_error(f"Failed to get version information: {e}")
print_info("")
print_info("Troubleshooting:")
print_info(" - Ensure LocalNet is running: algokit localnet start")
print_info(" - Check that KMD is accessible on port 4002")
print_info(" - Verify the KMD token is correct")
sys.exit(1)
if __name__ == "__main__":
main()