Repository navigation
Open
Labels
approvedIssue has been approved by team memberIssue has been approved by team memberpythonPull requests that update python codePull requests that update python codescope: DLTinvolves engineering for distributed ledger technologyinvolves engineering for distributed ledger technologyskill: intermediaterequires some knowledge of the codebase with some defined steps to implement or examplesrequires some knowledge of the codebase with some defined steps to implement or examples
Description
🐞 Problem Description
Rejecting tokens with the Python SDK takes two transactions:
- A
TokenRejectTransactionthat sends the fungible tokens and/or NFTs back to the treasury. - A
TokenDissociateTransactionthat removes the now-empty token relationships from the owner account.
Users have to build, sign and execute both themselves, and work out which token IDs to dissociate (including the token IDs behind any rejected NFTs).
The Java and JS SDKs provide TokenRejectFlow, which does both steps in one call. The Python SDK has nothing equivalent, so this is a feature gap.
Note: #22 ("Add TokenRejectFlow") was closed as not planned in Nov 2024 with no description.
TokenRejectTransactionexists now, so the flow can be built on top of it.
💡 Expected Solution
Add a TokenRejectFlow class that runs reject → dissociate in a single execute(client) call, with the same builder-style API as the other SDKs.
receipt = (
TokenRejectFlow()
.set_owner_id(owner_id)
.add_token_id(fungible_token_id)
.add_nft_id(NftId(nft_token_id, 1))
.freeze_with(client)
.sign(owner_private_key)
.execute(client)
)🛠️ Implementation Notes
- Add
src/hiero_sdk_python/tokens/token_reject_flow.pywith these fields:owner_id: AccountId | None = None token_ids: list[TokenId] = [] nft_ids: list[NftId] = [] node_account_ids: list[AccountId] | None = None _freeze_with_client: Client | None = None _sign_private_key: PrivateKey | None = None _sign_public_key: PublicKey | None = None _transaction_signer: Signer | None = None
- Add setters that return
self:set_owner_id,set_token_ids,add_token_id,set_nft_ids,add_nft_id,set_node_account_ids. Lists should be copied, not stored by reference. - Add
freeze_with(client),sign(private_key),sign_with(public_key, signer)andsign_with_operator(client). They should store the client or signer, and setting one signing option should clear the others (same as the Java implementation and theContractCreateFlowdesign in Add ContractCreateFlow to simplify smart contract deployment #2776). - Add a private helper that applies
node_account_ids,freeze_withand the stored signer to a transaction. Use it for both inner transactions. - Add
execute(client):- Build and run a
TokenRejectTransaction(set_owner_id,set_token_ids,set_nft_ids) and wait for its receipt. - Build and run a
TokenDissociateTransactionforowner_id. Its token list istoken_idsplus thetoken_idof every entry innft_ids, de-duplicated with order kept. Wait for its receipt. - Return the result of the reject transaction. Python's
Transaction.executereturns aTransactionReceiptby default, so return the reject receipt. This matches Add ContractCreateFlow to simplify smart contract deployment #2776. - If either receipt has a status other than
SUCCESS, raise the SDK's existing receipt error. Don't swallow it.
- Build and run a
- Validate types and values in the setters and in
execute(for example,owner_idis required and at least one token or NFT must be given). - Export
TokenRejectFlowfromhiero_sdk_python/__init__.py. - Add an example at
examples/tokens/token_reject_flow.py.
Async execution is out of scope.
🧪 Testing
- Unit tests (
tests/unit/): setter chaining and validation, de-duplication of dissociate token IDs (fungible plus NFT from the same token), signer options overriding each other, and that both inner transactions get the node IDs, freeze client and signer. - Integration test (
tests/integration/): an account associated with a fungible token and an NFT collection rejects both. Check that the balances go back to the treasury and that the account is no longer associated with either token.
✅ Acceptance Criteria
-
TokenRejectFlowis importable fromhiero_sdk_python - One
execute(client)call rejects and dissociates - Unit and integration tests pass
- Example added under
examples/tokens/
📚 References
- Java: https://github.com/hiero-ledger/hiero-sdk-java/blob/main/sdk/src/main/java/com/hedera/hashgraph/sdk/TokenRejectFlow.java
- JS: https://github.com/hiero-ledger/hiero-sdk-js/blob/main/src/token/TokenRejectFlow.js
- Related: Add ContractCreateFlow to simplify smart contract deployment #2776 (
ContractCreateFlow, same flow pattern) - Python building blocks:
src/hiero_sdk_python/tokens/token_reject_transaction.py,src/hiero_sdk_python/tokens/token_dissociate_transaction.py
Metadata
Metadata
Assignees
Labels
approvedIssue has been approved by team memberIssue has been approved by team memberpythonPull requests that update python codePull requests that update python codescope: DLTinvolves engineering for distributed ledger technologyinvolves engineering for distributed ledger technologyskill: intermediaterequires some knowledge of the codebase with some defined steps to implement or examplesrequires some knowledge of the codebase with some defined steps to implement or examples
Activity
github-actions commentedon Nov 12, 2026
Thanks for your submission.
This issue is awaiting approval from @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
github-actions commentedon Nov 13, 2026
Approved by @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
github-actions commentedon Nov 13, 2026
Dhie-boop commentedon Nov 13, 2026
/assign
github-actions commentedon Nov 13, 2026
👋 Hi @Dhie-boop! Thanks for your interest in contributing 💡
Before taking on a Intermediate issue, we ask contributors to complete at least 3 Beginner issues first.
👉 Find one here
Once you've done that, come back — we'll be happy to assign this! 😊
achintya2k5 commentedon Nov 13, 2026
/assign
github-actions commentedon Nov 21, 2026
Hi @achintya2k5 👋
This issue has been assigned but no pull request has been created yet.
Are you still planning on working on it?
If you are, please create a draft PR linked to this issue or comment
/workingto let us know.If you're no longer able to work on this issue, you can comment
/unassignto release it.From the Python SDK Team
achintya2k5 commentedon Nov 21, 2026
/working