-
Notifications
You must be signed in to change notification settings - Fork 86
feat: Convert fractional fee example to end-to-end transaction (#678) #695
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
feat: Convert fractional fee example to end-to-end transaction (#678) #695
Conversation
…-ledger#678) Signed-off-by: Rishabh Ranjan Singh <rishabhrsingh19@gmail.com>
|
Hello! I have completed the end-to-end conversion for Issue #678. I ensured the new example follows the requested modular pattern and successfully verifies the fractional fee object after token creation. The history is clean and ready for review/testing! Please mention any changes required |
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.
Hi @Rishabh1925
This example does not work
Please only submit an example that is working, there is README.md that epxlains how to connect to testnet so you have credentials and can verify this works.
If you get stuck and can't make it work, ask on discord!
The reasons why this does not work is a lot of the content is hallucinated - its not actually correct, its not how we do things in this sdk
for example, some of your import paths are wrong and you are calling methods that do not exist
It can take a few minutes to generate but it can take me 20 minutes to review something that clearly will not work
What I would recommend is
- set up your testnet
- try running your script - it will fail
- work on it step by step. Comment out most of it, and try to just run set up client. Work on the code by reviewing examples INSIDE the SDK and not via AI to see examples that are working and just use that.
- As soon as you have one working bit, add another working bit.
Good luck!
| from hiero_sdk_python.response_code import ResponseCode | ||
| from hiero_sdk_python.private_key import PrivateKey | ||
|
|
||
| # --- UTILITY FUNCTIONS (ASSUMED TO BE COPIED FROM OTHER EXAMPLES) --- |
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.
remove
--- UTILITY FUNCTIONS (ASSUMED TO BE COPIED FROM OTHER EXAMPLES) ---
what purpose does this serve the user ?
|
|
||
| # --- UTILITY FUNCTIONS (ASSUMED TO BE COPIED FROM OTHER EXAMPLES) --- | ||
|
|
||
| def setup_client() -> 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.
this will not work, because you need an account too
it does not look like you reviewed other examples, because all other examples have a longer set up process
eg at least
def setup_client():
"""Initialize and set up the client with operator account"""
network = Network(os.getenv('NETWORK'))
client = Client(network)
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
client.set_operator(operator_id, operator_key)
return client
| token_name = f"FractionalTest{int(time.time())}" | ||
|
|
||
| response = ( | ||
| TokenCreateTransaction() |
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.
extract out the token create into a separate function
| if __name__ == "__main__": | ||
| custom_fractional_fee() | ||
| # Ensure you set the NETWORK and OPERATOR_KEY environment variables | ||
| if not os.getenv('NETWORK') or not os.getenv('OPERATOR_KEY'): |
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 should be inside set up client
if not os.getenv('NETWORK') or not os.getenv('OPERATOR_KEY'):
print("FATAL: Please set NETWORK and OPERATOR_KEY environment variables.")
| from hiero_sdk_python.tokens.fee_assessment_method import FeeAssessmentMethod | ||
| from hiero_sdk_python.account.account_id import AccountId | ||
| from hiero_sdk_python.response_code import ResponseCode | ||
| from hiero_sdk_python.private_key import PrivateKey |
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.
Traceback (most recent call last):
File "/Users/sophiebulloch/hiero/hedera_sdk_python/examples/custom_fee_fractional.py", line 14, in
from hiero_sdk_python.private_key import PrivateKey
ModuleNotFoundError: No module named 'hiero_sdk_python.private_key'
please see other examples and see how they do it
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.
I think @exploreriii its gonna be like yesterday, so I think I should not do this issue, because I think its hard for me to solve it. I'll just again and again make commits and you will again and again have to ask me to make changes on it. Which will just take a lot out of both of us.
So, with no remorse, please de-assign me for this issue
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.
No, the issue is not at all like yesterday's, which you solved really well and have demonstrated in two PRs you've got it. Your skills have developed compared to yesterday!
This is a new issue. This is the skill of breaking down a problem into the smallest chunks, which is easier to solve. Then, when you are confident that is working, add in a new later.
Why don't you try just running this script and then add small sections to it please? (Create a file examples/test_file.py and paste in... then run it "uv run test_file.py" once you have set up your hedera portal account and filled in your env. with the information required)
import os
import sys
from dotenv import load_dotenv
from hiero_sdk_python import (
Client,
AccountId,
PrivateKey,
Network,
)
def setup_client(network_env_var: str = "NETWORK"):
"""Set up and return a configured Hedera client."""
load_dotenv()
network_name = os.getenv(network_env_var, "testnet")
print(f"Connecting to Hedera {network_name}...")
try:
network = Network(os.getenv("NETWORK", "testnet"))
client = Client(network)
operator_id_str = os.getenv("OPERATOR_ID")
operator_key_str = os.getenv("OPERATOR_KEY")
if not operator_id_str or not operator_key_str:
print("❌ Missing OPERATOR_ID or OPERATOR_KEY in .env file.")
sys.exit(1)
operator_id = AccountId.from_string(operator_id_str)
operator_key = PrivateKey.from_string(operator_key_str)
client.set_operator(operator_id, operator_key)
print("\n🚀 Hedera Client Setup Complete:")
print(f" Hedera Network: {client.network.network}")
print(f" Operating account: {client.operator_account_id}")
print()
return client, operator_id, operator_key
except Exception as e:
print(f"❌ Error setting up Hedera client: {e}")
sys.exit(1)
if name == "main":
setup_client()
This is an example of setting up a client.
It was inspired from other examples, I just added more logging to help you understand the logic:
def setup_client():
"""Set up network and operator client."""
load_dotenv()
print("Connecting to Hedera testnet...")
network = Network(os.getenv('NETWORK'))
client = Client(network)
try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
print(f"Using operator account: {operator_id}")
return client, operator_id, operator_key
except (TypeError, ValueError):
print("Error: Please check OPERATOR_ID and OPERATOR_KEY in your .env file.")
sys.exit(1)
Once you do that, is the next piece to create a token?
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.
I will try as much as I can understand and work upon @exploreriii
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.
plz schedule a call rather than a review, if there is something you don't understand or want help with
Closes #678
This Pull Request converts the conceptual script
examples/custom_fee_fractional.pyinto a fully functional end-to-end (E2E) demonstration that connects to the Hedera Testnet.Implementation Details:
setup_client()function.create_new_account,create_token_with_fractional_fee,verify_token_fee) which mirror the standard structure of other examples.CustomFractionalFeeis correctly applied and visible on the token using aTokenInfoQuery.feat:entry toCHANGELOG.mdunder### Added.