2323from dotenv import load_dotenv
2424
2525from hiero_sdk_python import AccountId , Client , Network , PrivateKey
26+ from hiero_sdk_python .account .account_create_transaction import AccountCreateTransaction
2627from hiero_sdk_python .address_book .endpoint import Endpoint
2728from hiero_sdk_python .nodes .node_create_transaction import NodeCreateTransaction
2829from hiero_sdk_python .nodes .node_update_transaction import NodeUpdateTransaction
@@ -60,12 +61,8 @@ def setup_client():
6061 return client
6162
6263
63- def create_node (client ):
64+ def create_node (client , account_id ):
6465 """Create a node on the network and return its ID and admin key."""
65- # Node account ID - this should be an existing account
66- # that will be associated with the node
67- account_id = AccountId .from_string ("0.0.4" )
68-
6966 # Node description
7067 description = "Example node"
7168
@@ -108,11 +105,8 @@ def create_node(client):
108105 return receipt .node_id , admin_key
109106
110107
111- def update_node (client , node_id , admin_key ):
108+ def update_node (client , account_id , node_account_key , node_id , admin_key ):
112109 """Update an existing node with new parameters."""
113- # Node account ID
114- account_id = AccountId .from_string ("0.0.4" )
115-
116110 # Updated node description
117111 updated_description = "Updated example node"
118112
@@ -139,7 +133,8 @@ def update_node(client, node_id, admin_key):
139133 .set_grpc_web_proxy_endpoint (updated_grpc_proxy_endpoint )
140134 .set_decline_reward (False )
141135 .freeze_with (client )
142- .sign (admin_key ) # Sign with the admin key
136+ .sign (admin_key )
137+ .sign (node_account_key )
143138 .execute (client )
144139 )
145140
@@ -163,11 +158,20 @@ def node_update():
163158 # Set up client with operator account
164159 client = setup_client ()
165160
161+ node_account_private_key = PrivateKey .generate_ecdsa ()
162+ node_account_id = (
163+ AccountCreateTransaction ()
164+ .set_key_without_alias (node_account_private_key )
165+ .freeze_with (client )
166+ .execute (client )
167+ .account_id
168+ )
169+
166170 # Create a new node and get its ID and admin key
167- node_id , admin_key = create_node (client )
171+ node_id , admin_key = create_node (client , node_account_id )
168172
169173 # Update the newly created node with modified parameters
170- update_node (client , node_id , admin_key )
174+ update_node (client , node_account_id , node_account_private_key , node_id , admin_key )
171175
172176 print ("\n Node creation and update example completed successfully!" )
173177
0 commit comments