-
Notifications
You must be signed in to change notification settings - Fork 229
feat: Add optional receipt waiting to Transaction.execute() #1769
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
Merged
exploreriii
merged 19 commits into
hiero-ledger:main
from
manishdait:feat/remove-get-receipt
Mar 3, 2026
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1f45c39
feat: added conditional execution for get_receipt
manishdait efb59fc
feat: added additional helper method to tx response
manishdait 565da36
chore: added docs
manishdait ef8db44
chore: added test for the changes
manishdait 10fc2b0
chore: updated changelog.md
manishdait 980d3ce
chore: added an example
manishdait 237313b
chore: fix rebase
manishdait e0aeda4
chore: fix rebase
manishdait 82120d7
chore: fix imports
manishdait 6fb2fb4
chore: improve example
manishdait 4e40235
chore: remove typehint from example
manishdait 7490ecb
--gpg-sign
manishdait 3065767
--gpg-sign
manishdait 64518e7
chore: fix some typos as comments
manishdait 99d661c
feat: added support for chuck tx
manishdait ea2f459
chore: fix typos
manishdait 004e0e0
chore: make topic to delete when test complete
manishdait 15c2c8b
chore: make execute to reutrn non null
manishdait 0c6c063
chore: added overload to improve type hinting
manishdait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
examples/transaction/transaction_without_wait_for_receipt.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """ | ||
| Demonstrate creating, executing, and retrieving an account creation transaction | ||
| without immediately waiting for the receipt. | ||
|
|
||
| uv run examples/transaction/transaction_without_wait_for_receipt.py | ||
| python examples/transaction/transaction_without_wait_for_receipt.py | ||
| """ | ||
|
|
||
| import sys | ||
|
|
||
| from hiero_sdk_python import ( | ||
| Client, | ||
| AccountCreateTransaction, | ||
| PrivateKey, | ||
| ResponseCode | ||
| ) | ||
|
|
||
|
|
||
| def build_transaction(): | ||
| """ | ||
| Build a new AccountCreateTransaction with a generated private key | ||
| and a minimal initial balance. | ||
| """ | ||
| key = PrivateKey.generate() | ||
| return AccountCreateTransaction().set_key_without_alias(key).set_initial_balance(1) | ||
Dosik13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def print_transaction_record(record): | ||
| """Print the transaction record.""" | ||
| print(f"Transaction ID: {record.transaction_id}") | ||
| print(f"Transaction Fee: {record.transaction_fee}") | ||
| print(f"Transaction Hash: {record.transaction_hash.hex()}") | ||
| print(f"Transaction Memo: {record.transaction_memo}") | ||
| print(f"Transaction Account ID: {record.receipt.account_id}") | ||
|
|
||
|
|
||
| def print_transaction_receipt(receipt): | ||
| """Print the transaction receipt.""" | ||
| if receipt.status != ResponseCode.SUCCESS: | ||
| raise RuntimeError(f"Receipt Query failed with status: {ResponseCode(receipt.status).name}") | ||
|
|
||
| print(f"Transaction Receipt Status: {ResponseCode(receipt.status).name}") | ||
| print(f"Transaction Account ID: {receipt.account_id}") | ||
|
|
||
|
|
||
| def main(): | ||
| """ | ||
| 1. Initialize a client from environment variables (operator required in env). | ||
| 2. Build an AccountCreateTransaction. | ||
| 3. Execute the transaction (without waiting for receipt). | ||
| 4. Retrieve the receipt and record after execution. | ||
| """ | ||
| try: | ||
| client = Client.from_env() | ||
| tx = build_transaction() | ||
|
|
||
| print("Executing transaction...") | ||
| # Execute the transaction without waiting for receipt immediately | ||
| response = tx.execute(client, wait_for_receipt=False) | ||
|
|
||
| print("Transaction executed successfully!") | ||
| print(f"Transaction submitted with ID: {response.transaction_id}") | ||
|
|
||
| # Retrieve receipt and record after submission | ||
| print("\n1. Getting Transaction Receipt using Transaction Response...") | ||
| receipt = response.get_receipt(client) | ||
| print_transaction_receipt(receipt) | ||
|
|
||
|
|
||
| print("\n2. Getting Transaction Record using Transaction Response...") | ||
| record = response.get_record(client) | ||
| print_transaction_record(record) | ||
|
|
||
| except Exception as err: | ||
| print(f"Error during transaction: {err}") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.