|
15 | 15 | from hedera_sdk_python.consensus.topic_create_transaction import TopicCreateTransaction |
16 | 16 | from hedera_sdk_python.tokens.token_delete_transaction import TokenDeleteTransaction |
17 | 17 | from cryptography.hazmat.primitives import serialization |
18 | | - |
19 | 18 | load_dotenv() |
20 | 19 |
|
21 | 20 | def load_operator_credentials(): |
@@ -132,15 +131,15 @@ def dissociate_token(client, recipient_id, recipient_private_key, token_id): |
132 | 131 | print(f"Token dissociation failed: {str(e)}") |
133 | 132 | sys.exit(1) |
134 | 133 |
|
135 | | -def transfer_token(client, recipient_id, token_id): |
| 134 | +def transfer_token(client, source_id, source_private_key, recipient_id, token_id): |
136 | 135 | """Transfer the specified token to the recipient account.""" |
137 | 136 | transaction = ( |
138 | 137 | TransferTransaction() |
139 | | - .add_token_transfer(token_id, client.operator_account_id, -1) |
| 138 | + .add_token_transfer(token_id, source_id, -1) |
140 | 139 | .add_token_transfer(token_id, recipient_id, 1) |
141 | 140 | .freeze_with(client) |
142 | 141 | ) |
143 | | - transaction.sign(client.operator_private_key) |
| 142 | + transaction.sign(source_private_key) |
144 | 143 |
|
145 | 144 | try: |
146 | 145 | receipt = transaction.execute(client) |
@@ -217,8 +216,10 @@ def main(): |
217 | 216 |
|
218 | 217 | associate_token(client, recipient_id, recipient_private_key, token_id) |
219 | 218 | print(f"Token {token_id} successfully associated.") |
220 | | - transfer_token(client, recipient_id, token_id) |
221 | | - print(f"Token {token_id} successfully transferred.") |
| 219 | + transfer_token(client, client.operator_id, client.operator_private_key, recipient_id, token_id) |
| 220 | + print(f"Token {token_id} successfully transferred in.") |
| 221 | + transfer_token(client, recipient_id, recipient_private_key, client.operator_id, token_id) |
| 222 | + print(f"Token {token_id} successfully transferred out.") |
222 | 223 | dissociate_token(client, recipient_id, recipient_private_key, token_id) |
223 | 224 | print(f"Token {token_id} successfully dissociated.") |
224 | 225 | associate_token(client, recipient_id, recipient_private_key, token_id) |
|
0 commit comments