Skip to content

Commit 6973136

Browse files
authored
chore: update specific to general keys in examples (#329)
* chore: update to general key types in examples Signed-off-by: exploreriii <[email protected]> * chore: changelog update Signed-off-by: exploreriii <[email protected]> * chore: run instructions for example files Signed-off-by: exploreriii <[email protected]> * feat: add examples guide to sdk devs Signed-off-by: exploreriii <[email protected]> * chore: rename examples guide in sdk users Signed-off-by: exploreriii <[email protected]> * chore: changelog update Signed-off-by: exploreriii <[email protected]> * chore: more docstrings Signed-off-by: exploreriii <[email protected]> * chore: replace deprecated methods in examples Signed-off-by: exploreriii <[email protected]> * chore: changelog update Signed-off-by: exploreriii <[email protected]> * chore: some tidy Signed-off-by: exploreriii <[email protected]> * chore: add python run command Signed-off-by: exploreriii <[email protected]> * chore: add python run instructions Signed-off-by: exploreriii <[email protected]> * chore: update examples.md Signed-off-by: exploreriii <[email protected]> * chore: pull in new examples Signed-off-by: exploreriii <[email protected]> * chore: remove duplicate examples Signed-off-by: exploreriii <[email protected]> * chore: revert to running examples for clarity Signed-off-by: exploreriii <[email protected]> --------- Signed-off-by: exploreriii <[email protected]>
1 parent 1d41316 commit 6973136

File tree

71 files changed

+343
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+343
-37
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
4040
- Update protobuf dependency from 5.28.1 to 5.29.1
4141
- Update grpcio dependency from 1.68.1 to 1.71.2
4242
- Updated `rebasing.md` with clarification on using `git reset --soft HEAD~<n>` where `<n>` specifies the number of commits to rewind.
43+
- Calls in examples for PrivateKey.from_string_ed25519(os.getenv('OPERATOR_KEY')) to PrivateKey.from_string(os.getenv('OPERATOR_KEY')) to enable general key types
4344

4445
### Fixed
4546
- Unit test compatibility issues when running with UV package manager
@@ -49,6 +50,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
4950
- Invalid DRE Hex representation in examples/keys_private_ecdsa.py
5051
- Windows malformed path using uv run generate_proto.py using as_posix()
5152
- Changed README MIT license to Apache
53+
- deprecated CamelCase instances in /examples such as TokenId and totalSupply to snake_case
5254

5355
### Removed
5456
- Removed the old `/documentation` folder.

docs/sdk_developers/examples.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Hiero Python SDK – Running Examples
2+
3+
This guide shows you how to run the example scripts included in the SDK.
4+
5+
---
6+
7+
## Running Examples
8+
9+
From the project root, you can run any example file directly:
10+
11+
```bash
12+
uv run examples/name_of_file.py
13+
```
14+
15+
If they must be run as a module, use:
16+
17+
```bash
18+
uv run -m examples.name_of_module
19+
```
20+
21+
If you are using your own venv, you can also use:
22+
```bash
23+
python examples/name_of_file.py
24+
python -m examples.name_of_module
25+
```
26+
27+
You'll need your environment variables and uv set up as outlined in /README.md [README](https://github.com/hiero-ledger/hiero-sdk-python/blob/main/README.md)
28+
29+
30+

docs/sdk_users/running_examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1706,4 +1706,4 @@ print(f"Transaction Fee: {record.transaction_fee}")
17061706
print(f"Transaction Hash: {record.transaction_hash}")
17071707
print(f"Transaction Memo: {record.transaction_memo}")
17081708
print(f"Transaction Account ID: {record.receipt.account_id}")
1709-
```
1709+
```

examples/account_create.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Run:
3+
uv run examples/account_create.py
4+
python examples/account_create.py
5+
"""
16
import os
27
import sys
38
from dotenv import load_dotenv
@@ -18,7 +23,7 @@ def create_new_account():
1823
client = Client(network)
1924

2025
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
21-
operator_key = PrivateKey.from_string_ed25519(os.getenv('OPERATOR_KEY'))
26+
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
2227
client.set_operator(operator_id, operator_key)
2328

2429
new_account_private_key = PrivateKey.generate("ed25519")

examples/account_delete.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""
22
Example demonstrating account delete functionality.
3-
"""
3+
Run:
4+
uv run examples/account_delete.py
5+
python examples/account_delete.py
46
7+
"""
58
import os
69
import sys
710

examples/account_update.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""
22
Example demonstrating account update functionality.
3+
run with:
4+
uv run examples/account_update.py
5+
python examples/account_update.py
36
"""
47

58
import datetime

examples/contract_create.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# from the project root directory
1212
1313
# Run from the project root directory
14+
uv run -m examples.contract_create
1415
python -m examples.contract_create
15-
1616
"""
1717

1818
import os

examples/contract_create_constructor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
# Run from the project root directory
1414
python -m examples.contract_create_constructor
15+
uv run -m examples.contract_create_constructor
1516
1617
"""
1718

examples/contract_create_with_bytecode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# from the project root directory
1111
1212
# Run from the project root directory
13+
uv run -m examples.contract_create_with_bytecode
1314
python -m examples.contract_create_with_bytecode
1415
1516
"""

examples/contract_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# from the project root directory
1616
1717
# Run from the project root directory
18+
uv run -m examples.contract_delete
1819
python -m examples.contract_delete
19-
2020
"""
2121

2222
import os

0 commit comments

Comments
 (0)