-
Notifications
You must be signed in to change notification settings - Fork 92
feat: added transaction lifecycle guide to documentation #870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Cynthia Fotso <cynthiafotso8@gmail.com>
Signed-off-by: Cynthia Fotso <cynthiafotso8@gmail.com>
exploreriii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow ! excellent work!
we have one issue - we don't yet have a get receipt method in the python sdk
currently executing it will also get you a receipt
| Fetch and verify the transaction receipt to confirm processing. | ||
|
|
||
| ```python | ||
| receipt = response.get_receipt(client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so right now as raised in issue
#398
we don't have a separate receipt step in the python sdk
i.e. this will currently get you a receipt
response = transaction.execute(client)
which is why you see
receipt = transaction.execute(client)
if receipt.status != ResponseCode.SUCCESS:
print(f"Transaction failed: {ResponseCode(receipt.status).name}")
else:
print("Transaction successful!")
| print("Transaction successful!") | ||
| ``` | ||
|
|
||
| - **Why check?** Receipts provide the final status and any generated IDs (e.g., new account ID). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is really important to emphasise -
you must check the receipt for SUCCESS to know if hedera processed the transaction as you wanted
sometimes it can throw up errors (list some.. they are written at src/hiero_sdk_python/response_code.py
but will still process the transaction with that failure
ie your python code won't catch on to any errors unless you check the receipt
| .freeze_with(client) # Lock fields | ||
| .sign(account_private_key) # Authorize | ||
| .execute(client) # Submit to Hedera | ||
| .get_receipt(client) # Fetch result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete line 111 - not yet part of the python sdk
| ### Correct | ||
| ```python | ||
| transaction = TokenAssociateTransaction().set_account_id(account_id).freeze_with(client).sign(key).execute(client) | ||
| receipt = response.get_receipt(client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember we do not use get receipt currently
execute will return a receipt for us
(see examples)
receipt = response.get_receipt(client) <- no
|
Hi @CynthiaFotso please rebase to pull in main's changes, we applied a fix that was blocking our tests. |
|
Hi @CynthiaFotso please do let us know if we can be of assistance |
Description
This PR adds a beginner-friendly documentation page explaining the transaction lifecycle in the Python SDK.
Linked Issue
Fixes #864: Create docs/sdk_developers/training/transaction_lifecycle.md
Checklist
Created docs/sdk_developers/training/transaction_lifecycle.md
Overview of the transaction flow (construct → freeze → sign → execute → check receipt)
Detailed explanation of each step, including why the order matters
Code examples using both Pythonic and method chaining syntax
A simple flow diagram
Common pitfalls and best practices
Referenced existing examples like examples/token_grant_kyc.py and examples/token_associate.py