Skip to content

Commit d005f0d

Browse files
committed
transfer out
1 parent 673dd75 commit d005f0d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

test.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from hedera_sdk_python.consensus.topic_create_transaction import TopicCreateTransaction
1616
from hedera_sdk_python.tokens.token_delete_transaction import TokenDeleteTransaction
1717
from cryptography.hazmat.primitives import serialization
18-
1918
load_dotenv()
2019

2120
def load_operator_credentials():
@@ -132,15 +131,15 @@ def dissociate_token(client, recipient_id, recipient_private_key, token_id):
132131
print(f"Token dissociation failed: {str(e)}")
133132
sys.exit(1)
134133

135-
def transfer_token(client, recipient_id, token_id):
134+
def transfer_token(client, source_id, source_private_key, recipient_id, token_id):
136135
"""Transfer the specified token to the recipient account."""
137136
transaction = (
138137
TransferTransaction()
139-
.add_token_transfer(token_id, client.operator_account_id, -1)
138+
.add_token_transfer(token_id, source_id, -1)
140139
.add_token_transfer(token_id, recipient_id, 1)
141140
.freeze_with(client)
142141
)
143-
transaction.sign(client.operator_private_key)
142+
transaction.sign(source_private_key)
144143

145144
try:
146145
receipt = transaction.execute(client)
@@ -217,8 +216,10 @@ def main():
217216

218217
associate_token(client, recipient_id, recipient_private_key, token_id)
219218
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.")
222223
dissociate_token(client, recipient_id, recipient_private_key, token_id)
223224
print(f"Token {token_id} successfully dissociated.")
224225
associate_token(client, recipient_id, recipient_private_key, token_id)

0 commit comments

Comments
 (0)