-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e753b5
commit fb96aad
Showing
6 changed files
with
653 additions
and
6 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import sys | ||
from dotenv import load_dotenv | ||
|
||
from hedera_sdk_python.client.client import Client | ||
from hedera_sdk_python.account.account_id import AccountId | ||
from hedera_sdk_python.consensus.topic_id import TopicId | ||
from hedera_sdk_python.crypto.private_key import PrivateKey | ||
from hedera_sdk_python.client.network import Network | ||
from hedera_sdk_python.consensus.topic_delete_transaction import TopicDeleteTransaction | ||
|
||
load_dotenv() | ||
|
||
def delete_topic(): | ||
network = Network(network='testnet') | ||
client = Client(network) | ||
|
||
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID')) | ||
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY')) | ||
topic_id = TopicId.from_string(os.getenv('TOPIC_ID')) | ||
|
||
client.set_operator(operator_id, operator_key) | ||
|
||
transaction = ( | ||
TopicDeleteTransaction(topic_id=topic_id) | ||
.freeze_with(client) | ||
.sign(operator_key) | ||
) | ||
|
||
try: | ||
receipt = transaction.execute(client) | ||
print(f"Topic {topic_id} deleted successfully.") | ||
except Exception as e: | ||
print(f"Topic deletion failed: {str(e)}") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
delete_topic() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import sys | ||
from dotenv import load_dotenv | ||
|
||
from hedera_sdk_python.client.client import Client | ||
from hedera_sdk_python.account.account_id import AccountId | ||
from hedera_sdk_python.consensus.topic_id import TopicId | ||
from hedera_sdk_python.crypto.private_key import PrivateKey | ||
from hedera_sdk_python.client.network import Network | ||
from hedera_sdk_python.consensus.topic_message_submit_transaction import TopicMessageSubmitTransaction | ||
|
||
load_dotenv() | ||
|
||
def submit_message(message): | ||
network = Network(network='testnet') | ||
client = Client(network) | ||
|
||
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID')) | ||
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY')) | ||
topic_id = TopicId.from_string(os.getenv('TOPIC_ID')) | ||
|
||
client.set_operator(operator_id, operator_key) | ||
|
||
transaction = ( | ||
TopicMessageSubmitTransaction(topic_id=topic_id, message=message) | ||
.freeze_with(client) | ||
.sign(operator_key) | ||
) | ||
|
||
try: | ||
receipt = transaction.execute(client) | ||
print(f"Message submitted to topic {topic_id}: {message}") | ||
except Exception as e: | ||
print(f"Message submission failed: {str(e)}") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
submit_message("Hello, Hedera!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
import sys | ||
from dotenv import load_dotenv | ||
|
||
from hedera_sdk_python.client.client import Client | ||
from hedera_sdk_python.account.account_id import AccountId | ||
from hedera_sdk_python.consensus.topic_id import TopicId | ||
from hedera_sdk_python.crypto.private_key import PrivateKey | ||
from hedera_sdk_python.client.network import Network | ||
from hedera_sdk_python.consensus.topic_update_transaction import TopicUpdateTransaction | ||
|
||
load_dotenv() | ||
|
||
def update_topic(new_memo): | ||
network = Network(network='testnet') | ||
client = Client(network) | ||
|
||
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID')) | ||
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY')) | ||
topic_id = TopicId.from_string(os.getenv('TOPIC_ID')) | ||
|
||
client.set_operator(operator_id, operator_key) | ||
|
||
transaction = ( | ||
TopicUpdateTransaction(topic_id=topic_id, memo=new_memo) | ||
.freeze_with(client) | ||
.sign(operator_key) | ||
) | ||
|
||
try: | ||
receipt = transaction.execute(client) | ||
print(f"Topic {topic_id} updated with new memo: {new_memo}") | ||
except Exception as e: | ||
print(f"Topic update failed: {str(e)}") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
update_topic("Updated topic memo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.