Skip to content

[Good First Issue]: Refactor topic_create_transaction.py to use Client.from_env()Β #1611

@rwalworth

Description

@rwalworth

πŸ†•πŸ₯ Newcomer Friendly

This Good First Issue is a guided, well-scoped task intended for new contributors to the Hiero Python SDK.

What you'll do

  • βœ… understand how the repository is structured
  • βœ… practice the standard contribution workflow
  • βœ… submit and merge a pull request

Support

A maintainer or mentor actively monitors this issue and will help guide it to completion.

Important

This issue does not require prior domain knowledge.

  • No Hiero or Hedera experience needed
  • No distributed ledger background required
  • Basic Python and Git are sufficient

Note

⏱️ Typical time to complete: 30–90 minutes (once setup is done)
🧩 Difficulty: Small, well-contained change
πŸŽ“ Best for: New contributors

🏁 Completion
When this issue is complete, you will have:

  • βœ… Solved a real issue
  • βœ… A merged pull request in the Hiero Python SDK
  • βœ… Your name in the project history
  • βœ… Confidence to take on larger issues next

πŸ‘Ύ Issue description

The example file examples/consensus/topic_create_transaction.py currently uses a verbose manual client setup pattern:

import os
import sys
from typing import Tuple
from dotenv import load_dotenv

from hiero_sdk_python import (
    Client,
    AccountId,
    PrivateKey,
    TopicCreateTransaction,
    Network,
)

load_dotenv()
network_name = os.getenv("NETWORK", "testnet").lower()

def setup_client() -> Tuple[Client, PrivateKey]:
    network = Network(network_name)
    print(f"Connecting to Hedera {network_name} network!")
    client = Client(network)

    operator_id_str = os.getenv("OPERATOR_ID")
    operator_key_str = os.getenv("OPERATOR_KEY")

    if not operator_id_str or not operator_key_str:
        print("Error: OPERATOR_ID or OPERATOR_KEY not found in environment.")
        sys.exit(1)

    try:
        operator_id = AccountId.from_string(operator_id_str)
        operator_key = PrivateKey.from_string(operator_key_str)
    except (TypeError, ValueError) as e:
        print(f"Error: Invalid OPERATOR_ID or OPERATOR_KEY format: {e}")
        sys.exit(1)

    client.set_operator(operator_id, operator_key)
    return client, operator_key

The SDK provides a simpler method: Client.from_env() which handles all of this automatically. This makes examples easier to read and more consistent across the codebase.


πŸ’‘ Proposed Solution

Replace the manual client setup with Client.from_env():

After (improved):

from hiero_sdk_python import Client, TopicCreateTransaction

def setup_client():
    """Initialize and set up the client with operator account."""
    client = Client.from_env()
    print(f"Network: {client.network.network}")
    print(f"Client set up with operator id {client.operator_account_id}")
    return client, client.operator_private_key

πŸ› οΈ Implementation Steps

To complete this issue, follow these steps:

  • Open the file: examples/consensus/topic_create_transaction.py
  • Update imports: Change imports to:
    from hiero_sdk_python import Client, TopicCreateTransaction
    Remove: os, sys, Tuple from typing, dotenv, AccountId, PrivateKey, Network
  • Remove module-level setup code: Delete these lines:
    load_dotenv()
    network_name = os.getenv("NETWORK", "testnet").lower()
  • Update setup_client() function: Replace the entire function with:
    def setup_client():
        """
        Sets up and configures the Hiero client.
        Reads OPERATOR_ID and OPERATOR_KEY from environment variables via Client.from_env().
        """
        client = Client.from_env()
        print(f"Network: {client.network.network}")
        print(f"Client set up with operator id {client.operator_account_id}")
        return client, client.operator_private_key
  • Verify the example still works: Run the example to ensure it executes correctly:
    uv run examples/consensus/topic_create_transaction.py

πŸ“‹ Step-by-Step Setup Guide

Suggestions:

  • Visual Studio (VS) Code: Guide

  • GitHub Desktop: Guide

  • Hedera Testnet Account with root .env file: Guide

  • Create a GPG key linked to GitHub: Guide

Setup the Hiero Python SDK for development

  • Fork Create an online and local copy of the repository: Guide

  • Connect origin with upstream: Guide

  • Install Packages and protobufs: Guide (or Windows Setup Guide for Windows users)

  • Sync Main pull any recent upstream changes: Guide

You are set up! πŸŽ‰


πŸ“‹ Step-by-step contribution guide

βœ… Get ready

  • Claim the issue: comment /assign: Guide

  • Double check the Issue and AI plan: carefully re-read the issue description and the CodeRabbit AI plan

  • Ask questions early: ask on Discord, your @mentor (Python SDK help) and the @good_first_issue_support_team (setup and workflow help)

  • Sync with main: pull the latest upstream changes Guide

  • πŸ’‘ Tip: Before coding, leave a short comment describing what you plan to change. We'll confirm you're on the right track.

πŸ› οΈ Solve the Issue

  • Create a branch from main: Guide

  • Implement the solution: follow the implementation steps in the issue description.

  • Commit with DCO and GPG signing: commit changes using: git commit -S -s -m "chore: your message", Guide

  • Add a .CHANGELOG.md entry: under the appropriate [UNRELEASED] section and commit as git commit -S -s -m "chore: changelog entry" Guide

πŸš€ Create the pull request

  • Push your commits: push your branch to your fork git push origin your-branch-name

  • Open a pull request: here guide

  • Complete the PR description: briefly describe your changes, Guide

  • Link the Issue: link the issue the PR solves in the PR description, Guide

  • Submit the pull request: click **Create pull request** πŸŽ‰


βœ… Acceptance criteria

To be able to close this issue, the following criteria must be met:

  • The issue is solved: I've carefully read and implemented the issue requirements

  • I did not add extra changes: I did not modify anything beyond what is described in the issue

  • Behavior: The example runs successfully and produces the same functional result as before

  • Imports cleaned up: All unused imports have been removed

  • Checks and feedback: All checks pass and any requested changes have been made


🧭 Getting help if you're stuck

If questions come up, don't spend more than 20 minutes blocked.

Tip

  • Comment on this issue and tag @good_first_issue_support_team or @mentor_name
  • Ask for help in Discord

πŸ€” What to expect after submitting a PR

Once you open a pull request, here's what happens next.

πŸ€– 1. Automated checks
A small set of automated checks must pass before merging (signing, changelog, tests, examples, code quality).
Open any failed check to see details.


🀝 2. AI feedback (CodeRabbit)
CodeRabbit AI may suggest improvements or flag issues.
Feedback is advisory β€” use what's relevant and helpful.


😎 3. Team review
A Python SDK team member reviews your PR within 1–3 days.
You may be asked to make changes or your PR may be approved.
Approved PRs are usually merged within one day.

πŸ”„ Merge conflicts (sometimes)
Conflicts can happen and are normal as the SDK updates.
Changelog conflicts can be resolved online in the PR in the merge editor, accepting both entries
Others may require rebasing.


πŸ€– AI usage guidelines

You're welcome to use AI tools while working on this issue.

Many contributors do β€” especially for:

  • understanding unfamiliar code
  • drafting small refactors
  • sanity-checking approaches

Use AI responsibly:

  • review suggestions carefully
  • apply changes incrementally
  • test as you go

If in doubt, ask β€” maintainers are happy to help.


πŸ€” Additional Help

First Points of Contact:

  • Discord
  • Comment with @mentor_name (for Python SDK questions)
  • Comment with @hiero-ledger/hiero-sdk-good-first-issue-support (for setup and workflow questions)
    The more you ask, the more you learn and so do we!

Documentation:

Calls:

Metadata

Metadata

Labels

Good First IssueIssues which are ideal for a first time or new project contributor.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions