11import os
22import sys
3+ from dotenv import load_dotenv
34from src .client .network import Network
45from src .client .client import Client
56from src .account .account_id import AccountId
67from src .account .account_create_transaction import AccountCreateTransaction
78from src .crypto .private_key import PrivateKey
89from src .tokens .token_create_transaction import TokenCreateTransaction
910from src .tokens .token_associate_transaction import TokenAssociateTransaction
11+ from src .tokens .token_id import TokenId
1012from src .transaction .transfer_transaction import TransferTransaction
1113from src .response_code import ResponseCode
1214
15+ load_dotenv ()
1316
1417def load_operator_credentials ():
1518 """Load operator credentials from environment variables."""
@@ -54,6 +57,7 @@ def create_new_account(client, initial_balance=100000000):
5457
5558def create_token (client , operator_id ):
5659 """Create a new token and return its TokenId instance."""
60+
5761 transaction = (
5862 TokenCreateTransaction ()
5963 .set_token_name ("ExampleToken" )
@@ -63,6 +67,7 @@ def create_token(client, operator_id):
6367 .set_treasury_account_id (operator_id )
6468 .freeze_with (client )
6569 )
70+
6671 transaction .sign (client .operator_private_key )
6772
6873 try :
@@ -89,7 +94,7 @@ def associate_token(client, recipient_id, recipient_private_key, token_id):
8994 .freeze_with (client )
9095 )
9196 transaction .sign (client .operator_private_key ) # sign with operator's key (payer)
92- transaction .sign (recipient_private_key ) # sign with newly created accounts key (recipient)
97+ transaction .sign (recipient_private_key ) # sign with newly created account's key (recipient)
9398
9499 try :
95100 receipt = transaction .execute (client )
@@ -124,7 +129,9 @@ def transfer_token(client, recipient_id, token_id):
124129def main ():
125130 operator_id , operator_key = load_operator_credentials ()
126131
127- network = Network (node_address = 'localhost:50211' , node_account_id = AccountId (0 , 0 , 3 ))
132+ network_type = os .getenv ('NETWORK' )
133+ network = Network (network = network_type )
134+
128135 client = Client (network )
129136 client .set_operator (operator_id , operator_key )
130137
@@ -134,4 +141,4 @@ def main():
134141 transfer_token (client , recipient_id , token_id )
135142
136143if __name__ == "__main__" :
137- main ()
144+ main ()
0 commit comments