Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/query_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
8 changes: 5 additions & 3 deletions examples/query_topic_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
6 changes: 3 additions & 3 deletions examples/query_topic_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
)

load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()
def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
8 changes: 5 additions & 3 deletions examples/token_airdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
6 changes: 3 additions & 3 deletions examples/token_associate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

# Load environment variables from .env file
load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()


def setup_client():
Expand All @@ -38,9 +39,8 @@ def setup_client():
Raises:
SystemExit: If operator credentials are invalid or missing
"""
print("Connecting to Hedera testnet...")
network = Network(os.getenv('NETWORK'))
client = Client(network)
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
Expand Down
8 changes: 5 additions & 3 deletions examples/token_cancel_airdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
# Load environment variables from .env file
load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize the Hedera client using environment variables."""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))

print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))


try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
Expand Down
9 changes: 5 additions & 4 deletions examples/token_create_fungible_infinite.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
def setup_client():
"""Set up network and operator client."""
load_dotenv()
print("Connecting to Hedera testnet...")
network = Network(os.getenv('NETWORK'))
client = Client(network)
network_name = os.getenv('NETWORK', 'testnet').lower()
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
9 changes: 5 additions & 4 deletions examples/token_create_nft_finite.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
def setup_client():
"""Set up network and operator client."""
load_dotenv()
print("Connecting to Hedera testnet...")
network = Network(os.getenv('NETWORK'))
client = Client(network)
network_name = os.getenv('NETWORK', 'testnet').lower()
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
7 changes: 3 additions & 4 deletions examples/token_create_nft_infinite.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
1. Network and Operator Setup
"""
def net_op_setup():
print("Connecting to Hedera testnet...")
network = Network(os.getenv('NETWORK'))
client = Client(network)

network_name = os.getenv('NETWORK', 'testnet').lower()
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))
try:
operator_id = AccountId.from_string(os.getenv("OPERATOR_ID"))
operator_key = PrivateKey.from_string(os.getenv("OPERATOR_KEY"))
Expand Down
5 changes: 3 additions & 2 deletions examples/token_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
# Load environment variables from .env file
load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()

def create_and_delete_token():
"""
A full example that creates a token and then immediately deletes it.
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

# Get the operator account from the .env file
try:
Expand Down
6 changes: 3 additions & 3 deletions examples/token_dissociate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
# Load environment variables from .env file
load_dotenv()


network_name = os.getenv('NETWORK', 'testnet').lower()
def token_dissociate():
"""
A full example that creates an account, two tokens, associates them,
and finally dissociates them.
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
5 changes: 3 additions & 2 deletions examples/token_freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Load environment variables from .env file
load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()

def freeze_token():
"""
Expand All @@ -28,8 +29,8 @@ def freeze_token():
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
8 changes: 5 additions & 3 deletions examples/token_mint_fungible.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# Load environment variables from .env file
load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()


def token_mint_fungible():
Expand All @@ -26,10 +27,11 @@ def token_mint_fungible():
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
5 changes: 3 additions & 2 deletions examples/token_mint_non_fungible.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
# Load environment variables from .env file
load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()

def token_mint_non_fungible():
"""
Creates an NFT collection and then mints new NFTs with metadata.
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
8 changes: 5 additions & 3 deletions examples/token_unfreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# Load environment variables from .env file
load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()

def token_unfreeze():
"""
Expand All @@ -28,10 +29,11 @@ def token_unfreeze():
"""
# 1. Setup Client
# =================================================================
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
5 changes: 3 additions & 2 deletions examples/topic_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()


def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id_str = os.getenv('OPERATOR_ID')
Expand Down
9 changes: 5 additions & 4 deletions examples/topic_message_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
)

load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()
def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
operator_key = PrivateKey.from_string(os.getenv('OPERATOR_KEY'))
client.set_operator(operator_id, operator_key)
Expand Down
5 changes: 3 additions & 2 deletions examples/topic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
6 changes: 3 additions & 3 deletions examples/transfer_hbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
)

load_dotenv()

network_name = os.getenv('NETWORK', 'testnet').lower()
def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
5 changes: 3 additions & 2 deletions examples/transfer_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
)

load_dotenv()
network_name = os.getenv('NETWORK', 'testnet').lower()

def setup_client():
"""Initialize and set up the client with operator account"""
print("Connecting to Hedera testnet...")
client = Client(Network(os.getenv('NETWORK')))
print(f"🌐 Connecting to Hedera {network_name}...")
client = Client(Network(network_name))

try:
operator_id = AccountId.from_string(os.getenv('OPERATOR_ID'))
Expand Down
Loading