Skip to content

Commit a5fab62

Browse files
committed
Updated transaction_lifecycle.md to reflect maintainers comments
Signed-off-by: Cynthia Fotso <cynthiafotso8@gmail.com>
1 parent c001970 commit a5fab62

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

docs/sdk_developers/training/transaction_lifecycle.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ transaction.sign(account_private_key)
6868
Submit the transaction to the Hedera network. This returns a `TransactionResponse` indicating the network received it.
6969

7070
```python
71-
response = transaction.execute(client)
71+
receipt = transaction.execute(client)
7272
```
7373

7474
- **Does this guarantee success?** No! It only confirms receipt. The network processes it asynchronously.
@@ -79,16 +79,41 @@ response = transaction.execute(client)
7979
Fetch and verify the transaction receipt to confirm processing.
8080

8181
```python
82-
receipt = response.get_receipt(client)
82+
# In this SDK `execute(client)` returns the receipt directly:
83+
receipt = transaction.execute(client)
8384

8485
if receipt.status != ResponseCode.SUCCESS:
8586
print(f"Transaction failed: {ResponseCode(receipt.status).name}")
8687
else:
8788
print("Transaction successful!")
8889
```
8990

90-
- **Why check?** Receipts provide the final status and any generated IDs (e.g., new account ID).
91-
- **Common statuses:** `SUCCESS`, `INSUFFICIENT_ACCOUNT_BALANCE`, `INVALID_SIGNATURE`.
91+
- **Why check?** Always inspect `receipt.status` returned by `execute(client)`. The `execute` call confirms the network received your transaction; the receipt contains the final processing result. Your Python code will not automatically raise for Hedera-level failures — you must check the receipt to detect them.
92+
93+
- **Common failure examples (from `src/hiero_sdk_python/response_code.py`):**
94+
- `INSUFFICIENT_ACCOUNT_BALANCE` — payer/account lacks sufficient funds
95+
- `INSUFFICIENT_TX_FEE` — submitted fee was too low to cover processing
96+
- `INVALID_SIGNATURE` — missing or incorrect cryptographic signature
97+
- `INVALID_PAYER_SIGNATURE` — payer's signature is invalid
98+
- `TRANSACTION_EXPIRED` — transaction timestamp/duration expired
99+
- `INVALID_TOKEN_ID` — supplied token ID does not exist
100+
- `TOKEN_NOT_ASSOCIATED_TO_ACCOUNT` — attempted token operation on an unassociated account
101+
- `TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT` — duplicate association attempt
102+
- `FAIL_BALANCE`, `FAIL_FEE` — generic failure categories
103+
104+
- **Important:** These are examples only — many other ResponseCodes exist. Always consult `src/hiero_sdk_python/response_code.py` for the full list and handle codes relevant to your workflow.
105+
106+
```python
107+
# Example: check and handle failure explicitly
108+
receipt = transaction.execute(client)
109+
110+
if receipt.status != ResponseCode.SUCCESS:
111+
# react to failure: log, retry, or surface to caller
112+
print(f"Transaction processed with failure: {ResponseCode(receipt.status).name}")
113+
# e.g. inspect receipt fields for more info, then handle appropriately
114+
else:
115+
print("Transaction successful!")
116+
```
92117

93118
## Complete Example
94119

@@ -108,7 +133,6 @@ def associate_token_with_account(client, account_id, account_private_key, token_
108133
.freeze_with(client) # Lock fields
109134
.sign(account_private_key) # Authorize
110135
.execute(client) # Submit to Hedera
111-
.get_receipt(client) # Fetch result
112136
)
113137

114138
if receipt.status != ResponseCode.SUCCESS:
@@ -125,7 +149,6 @@ For more examples, see `examples/token_grant_kyc.py` or `examples/token_associat
125149
### Correct
126150
```python
127151
transaction = TokenAssociateTransaction().set_account_id(account_id).freeze_with(client).sign(key).execute(client)
128-
receipt = response.get_receipt(client)
129152
```
130153

131154
### Incorrect (Signing before freezing)

0 commit comments

Comments
 (0)