Skip to content

Commit 8ebd3ba

Browse files
anushka7426exploreriiimanishdait
authored
refactor: use Client.from_env() in file_create_transaction example (hiero-ledger#1790)
Signed-off-by: anushka7426 <anushkaditharam@gmail.com> Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com> Co-authored-by: exploreriii <133720349+exploreriii@users.noreply.github.com> Co-authored-by: Manish Dait <90558243+manishdait@users.noreply.github.com>
1 parent 702890c commit 8ebd3ba

2 files changed

Lines changed: 6 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
1616
-
1717

1818
### Examples
19+
- Refactor `examples/file/file_create_transaction.py` to remove `os`,`dotenv`,`AccountId`,`PrivateKey`,`Network` imports that are no longer needed and updated setup-client() (#1610)
1920

2021
- Refactored contract_delete_transaction example to use Client.from_env. (#1823)
2122

@@ -302,6 +303,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
302303
- chore: clarify wording in the bot-assignment-check.sh (#1748)
303304
- Refactored SDK dependencies to use version ranges, moved build-only deps out of runtime, removed unused core deps and added optional extras.
304305

306+
305307
### Fixed
306308
- Added a fork guard condition to prevent Codecov upload failures on fork PRs due to missing token. (`#1485`)
307309
- Corrected broken documentation links in SDK developer training files.(#1707)

examples/file/file_create_transaction.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
python examples/file_create_transaction.py
88
99
"""
10-
import os
10+
1111
import sys
12+
import os
1213

1314
from dotenv import load_dotenv
1415

@@ -21,20 +22,10 @@
2122
from hiero_sdk_python.file.file_create_transaction import FileCreateTransaction
2223
from hiero_sdk_python.response_code import ResponseCode
2324

24-
load_dotenv()
25-
26-
network_name = os.getenv("NETWORK", "testnet").lower()
27-
28-
2925
def setup_client():
3026
"""Initialize and set up the client with operator account."""
31-
network = Network(network_name)
32-
print(f"Connecting to Hedera {network_name} network!")
33-
client = Client(network)
34-
35-
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID", ""))
36-
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY", ""))
37-
client.set_operator(operator_id, operator_key)
27+
client = Client.from_env()
28+
print(f"Network: {client.network.network}")
3829
print(f"Client set up with operator id {client.operator_account_id}")
3930

4031
return client

0 commit comments

Comments
 (0)