Skip to content

Commit 3fa6ef8

Browse files
authored
fix(readme): correct account balance example to use valid SDK APIs (#1253)
Signed-off-by: Parv <[email protected]>
1 parent 524f0d0 commit 3fa6ef8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
111111

112112
### Fixed
113113

114+
- Fixed the README account balance example to use correct SDK APIs and provide a runnable testnet setup. (#1250)
114115
- Fix token association verification in `token_airdrop_transaction.py` to correctly check if tokens are associated by using `token_id in token_balances` instead of incorrectly displaying zero balances which was misleading (#[815])
115116
- Fixed inactivity bot workflow not checking out repository before running (#964)
116117
- Fixed the topic_message_query integarion test

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A Python SDK for interacting with the Hedera Hashgraph platform.
1414
```bash
1515
pip install --upgrade pip
1616
pip install hiero-sdk-python
17+
pip install python-dotenv
1718
```
1819

1920
### Environment Configuration
@@ -30,14 +31,22 @@ A sample file is provided: [.env.example](.env.example)
3031
### Basic Usage
3132

3233
```python
33-
from hiero_sdk_python import Client, AccountBalanceQuery
34+
import os
35+
from dotenv import load_dotenv
36+
from hiero_sdk_python import Network, Client, CryptoGetAccountBalanceQuery, AccountId, PrivateKey
3437

3538
# Connect to testnet
36-
client = Client.for_testnet()
37-
client.set_operator(account_id, private_key)
39+
load_dotenv()
40+
network = Network("testnet")
41+
client = Client(network)
42+
43+
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID",""))
44+
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY",""))
45+
46+
client.set_operator(operator_id, operator_key)
3847

3948
# Query account balance
40-
balance = AccountBalanceQuery(account_id=account_id).execute(client)
49+
balance = CryptoGetAccountBalanceQuery(account_id=operator_id).execute(client)
4150
print(f"Balance: {balance.hbars} HBAR")
4251
```
4352

0 commit comments

Comments
 (0)