# Send Transactions
Send transactions after meeting the prerequisites.
# Prerequisites
- Wallet: Set up a wallet via Keeper Wallet or WX Network.
NOTE: Ensure saving your wallet's seed phrase to send transactions.
- Tokens: Obtain WAVES tokens to cover each transaction's fee:
- For the Mainnet network: Get at least 0.001 WAVES via Available Market Options.
- For the Testnet network: Get at least 0.001 WAVES via Faucet.
- For the Stagenet network: Get at least 0.001 WAVES via Faucet.
# Tutorial
Follow the instructions for the transaction type you want to send:
- Issue.
- Reissue.
- Burn.
- Transfer.
- Mass Transfer.
- Exchange.
- Lease.
- Lease Cancel.
- Create Alias.
- Data.
- Set Script.
- Set Asset Script.
- Update Asset Info.
- Invoke Script.
- Sponsor Fee.
# Issue
In your project directory:
- Replace the
main.py
file code with the following snippet:- For creating a regular asset:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the asset parameters. asset_name = 'MyToken' # Name. asset_description = 'Asset description' # Description. total_tokens = 1000 # Quantity. decimals = 2 # Decimals. reissuable = True # Flag indicating whether the asset is reissuable. # Calculate the token quantity in minimal units. quantity = total_tokens * (10 ** decimals) # Create the Issue transaction. try: print("Issuing asset...") issue_tx = my_address.issueAsset( name=asset_name, description=asset_description, quantity=quantity, decimals=decimals, reissuable=reissuable ) except Exception as e: print(f"An error occurred while issuing the asset: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = issue_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- For creating a smart asset:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the smart asset parameters. asset_name = 'MySmartToken' # Name. asset_description = 'A smart asset test' # Description. total_tokens = 1000 # Quantity. decimals = 2 # Decimals. reissuable = True # Flag indicating whether the asset is reissuable. # Specify a Ride script of the smart asset. script_source = """ {-# STDLIB_VERSION 8 #-} {-# CONTENT_TYPE EXPRESSION #-} {-# SCRIPT_TYPE ASSET #-} true """ # Calculate the quantity in minimal units. quantity = total_tokens * (10 ** decimals) # Create the Issue transaction. try: print("Issuing smart asset...") issue_tx = my_address.issueSmartAsset( asset_name, asset_description, quantity, scriptSource=script_source, decimals=decimals, reissuable=reissuable ) except Exception as e: print(f"An error occurred while issuing the smart asset: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = issue_tx print("Smart asset successfully issued. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving the transaction details: {e}")
- For creating a regular asset:
- Run the
main.py
file:python main.py
# Reissue
NOTE: You can reissue only those asset that were issued by you with the reissuable flag set to
true
.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the asset ID of the token to reissue. asset_id = 'PASTE YOUR ASSET ID' # Create an asset object using the asset ID. my_token = pw.Asset(asset_id) # Define the reissue parameters. additional_tokens = 500 # Number of additional tokens to issue. decimals = 2 # Number of decimals the token uses. reissuable = True # Flag indicating whether the asset remains reissuable. # Calculate the token quantity in minimal units. quantity = additional_tokens * (10 ** decimals) # Create the Reissue transaction. try: print("Reissuing asset...") reissue_tx = my_address.reissueAsset( asset=my_token, quantity=quantity, reissuable=reissuable ) except Exception as e: print(f"An error occurred while reissuing the asset: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = reissue_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Burn
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the asset ID of the token to burn. asset_id = 'PASTE AN ASSET ID' # Create an asset object using the asset ID. my_token = pw.Asset(asset_id) # Define the burn parameters. tokens_to_burn = 100 # Number of tokens to burn. decimals = 2 # Number of decimals the token uses. # Calculate the token quantity in minimal units. quantity = tokens_to_burn * (10 ** decimals) # Create the Burn transaction. try: print("Burning asset...") burn_tx = my_address.burnAsset( asset=my_token, quantity=quantity ) except Exception as e: print(f"An error occurred while burning the asset: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = burn_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Transfer
In your project directory:
- Replace the
main.py
file code with the following snippet:- For custom asset transfers:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the asset ID of the token to transfer. asset_id = 'PASTE AN ASSET ID' # Create an asset object using the asset ID. my_token = pw.Asset(asset_id) # Specify the recipient address. recipient_address = 'PASTE A RECIPIENT ADDRESS' # Specify the amount to transfer in token units (not minimal units). amount = 10 # Number of decimals the token uses. decimals = 2 # Calculate the token amount in minimal units. amount_in_minimal_units = amount * (10 ** decimals) # Create the Transfer transaction. try: print("Performing asset transfer...") transfer_tx = my_address.sendAsset( recipient=pw.Address(address=recipient_address), asset=my_token, amount=amount_in_minimal_units ) except Exception as e: print(f"An error occurred while performing the asset transfer: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = transfer_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- For transfers in WAVES:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the recipient address. recipient_address = 'PASTE A RECIPIENT ADDRESS' # Specify the amount to transfer in WAVES. amount = 1.5 # Amount example. # Number of decimals WAVES uses. decimals = 8 # Decimals' example. # Calculate the WAVES amount in minimal units. amount_in_minimal_units = int(amount * (10 ** decimals)) # Create the Transfer transaction. try: print("Performing WAVES transfer...") transfer_tx = my_address.sendWaves( recipient=pw.Address(address=recipient_address), amount=amount_in_minimal_units ) except Exception as e: print(f"An error occurred while performing the WAVES transfer: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = transfer_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- For custom asset transfers:
- Run the
main.py
file:python main.py
# Mass Transfer
About Mass Transfer Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:- For custom asset transfers:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( node='https://nodes-testnet.wavesnodes.com', chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the asset ID of the token to transfer. asset_id = 'PASTE AN ASSET ID' # Create an asset object using the asset ID. my_token = pw.Asset(asset_id) # Define the transfer parameters. decimals = 2 # Number of decimals the token uses. # Define the list of recipients and amounts. # Each transfer is a dictionary with 'recipient' and 'amount' keys. # Amounts should be specified in token units (not minimal units). transfers = [ # Specify the first recipient address and the relevant transfer amount. {'recipient': 'PASTE THE FIRST RECIPIENT ADDRESS', 'amount': 10}, # Specify the second recipient address and the relevant transfer amount. {'recipient': 'PASTE THE SECOND RECIPIENT ADDRESS', 'amount': 20}, # Specify the third recipient address and the relevant transfer amount. {'recipient': 'PASTE THE THIRD RECIPIENT ADDRESS', 'amount': 30} # ... ] # Convert amounts to minimal units. for transfer in transfers: transfer['amount'] *= 10 ** decimals # Create the Mass Transfer transaction. try: print("Performing mass transfer of asset...") mass_transfer_tx = my_address.massTransferAssets( asset=my_token, transfers=transfers ) except Exception as e: print(f"An error occurred while performing the mass transfer: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = mass_transfer_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- For transfers in WAVES:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the transfer parameters. decimals = 8 # Number of decimals WAVES uses. # Define the list of recipients and amounts. # Each transfer is a dictionary with 'recipient' and 'amount' keys. # Amounts should be specified in WAVES units (not minimal units). transfers = [ # Specify the first recipient address and the relevant transfer amount. {'recipient': 'PASTE THE FIRST RECIPIENT ADDRESS', 'amount': 0.1}, # Specify the second recipient address and the relevant transfer amount. {'recipient': 'PASTE THE SECOND RECIPIENT ADDRESS', 'amount': 0.2}, # Specify the third recipient address and the relevant transfer amount. {'recipient': 'PASTE THE THIRD RECIPIENT ADDRESS', 'amount': 0.3} # ... ] # Convert amounts to minimal units. for transfer in transfers: transfer['amount'] = int(transfer['amount'] * (10 ** decimals)) # Create the Mass Transfer transaction without attachment. try: print("Performing mass transfer of WAVES...") mass_transfer_tx = my_address.massTransferWaves( transfers=transfers ) except Exception as e: print(f"An error occurred while performing the mass transfer: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = mass_transfer_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- For custom asset transfers:
- Run the
main.py
file:python main.py
# Exchange
Note: While the SDK does not support the Exchange transaction directly, it does provide separate support for creating buy and sell orders.
In your project directory:
- Replace the
main.py
file code with the following snippet:- For creating a buy order:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node="https://nodes-testnet.wavesnodes.com", # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain="T" ) # Set the matcher node for trades. pw.setMatcher("http://matcher-testnet.waves.exchange") # Address example. # Specify your wallet seed phrase. seed_phrase = "PASTE YOUR SEED PHRASE" # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the trading pair: asset you want to buy and asset to pay with. amount_asset = pw.Asset("PASTE AN ASSET ID") # Asset to buy. price_asset = pw.Asset("WAVES") # Native WAVES asset. # Create the asset pair object. asset_pair = pw.AssetPair(amount_asset, price_asset) # Define order parameters. amount = 0.001 # Amount of tokens to buy. price = 0.001 # Price per token in WAVES. # Convert to minimal units using asset decimals attributes. amount_min = int(amount * (10 ** amount_asset.decimals)) price_min = int(price * (10 ** price_asset.decimals)) # Define matcher fee and order lifetime. matcher_fee = pw.DEFAULT_MATCHER_FEE max_lifetime = 3600 # 1 hour # Create the Buy Order. try: print("Posting a buy order...") buy_order = my_address.buy( assetPair=asset_pair, amount=amount_min, price=price_min, matcherFee=matcher_fee, maxLifetime=max_lifetime ) print("Buy order successfully posted.") print("Order details:") print(json.dumps(buy_order, indent=4)) except Exception as e: print(f"An error occurred while posting the buy order: {e}") exit(1)
- For creating a sell order:
# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the desired network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node="https://nodes-testnet.wavesnodes.com", # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain="T" ) # Set the matcher node for trades. pw.setMatcher("https://matcher-testnet.waves.exchange") # Matcher address example. # Specify your wallet seed phrase. seed_phrase = "PASTE YOUR SEED PHRASE" # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the trading pair: asset you want to sell and asset to receive. amount_asset = pw.Asset("PASTE AN ASSET ID") # Asset to sell. price_asset = pw.Asset("WAVES") # Asset to receive. # Create the asset pair object. asset_pair = pw.AssetPair(amount_asset, price_asset) # Define order parameters. amount = 0.001 # Amount of tokens to sell. price = 0.001 # Price per token in WAVES. # Convert to minimal units using asset decimals attributes. amount_min = int(amount * (10 ** amount_asset.decimals)) price_min = int(price * (10 ** price_asset.decimals)) # Define matcher fee and order lifetime. matcher_fee = pw.DEFAULT_MATCHER_FEE max_lifetime = 3600 # 1 hour # Create the Sell Order. try: print("Posting a sell order...") sell_order = my_address.sell( assetPair=asset_pair, amount=amount_min, price=price_min, matcherFee=matcher_fee, maxLifetime=max_lifetime ) print("Sell order successfully posted.") print("Order details:") print(json.dumps(sell_order, indent=4)) except Exception as e: print(f"An error occurred while posting the sell order: {e}") exit(1)
- For creating a buy order:
- Run the
main.py
file:python main.py
# Lease
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the recipient address. recipient_address = 'PASTE A RECIPIENT ADDRESS' # Specify the amount to lease in WAVES. amount = 1.5 # Number of decimals WAVES uses. decimals = 8 # Calculate the WAVES amount in minimal units. amount_in_minimal_units = int(amount * (10 ** decimals)) # Create the Lease transaction. try: print("Performing WAVES lease...") lease_tx = my_address.lease( recipient=pw.Address(address=recipient_address), amount=amount_in_minimal_units ) except Exception as e: print(f"An error occurred while performing the WAVES lease: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = lease_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Lease Cancel
About Lease Cancel Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the lease transaction ID to cancel. lease_id = 'PASTE A LEASE TRANSACTION ID' # Create the Lease Cancel transaction. try: print("Cancelling lease transaction...") lease_cancel_tx = my_address.leaseCancel(leaseId=lease_id) except Exception as e: print(f"An error occurred while cancelling the lease: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = lease_cancel_tx print("Lease cancellation transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}") ```
- Run the
main.py
file:python main.py
# Create Alias
About Create Alias Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the alias to be created. alias = 'new_alias' # Alias example. # Create the Create Alias transaction. try: print("Creating alias...") alias_tx = my_address.createAlias(alias=alias) except Exception as e: print(f"An error occurred while creating the alias: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = alias_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Data
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the data to be stored. data = [ {'type': 'string', 'key': 'exampleKey', 'value': 'exampleValue'} ] # Create the Data transaction. try: print("Creating data transaction...") data_tx = my_address.dataTransaction(data=data) except Exception as e: print(f"An error occurred while creating the data transaction: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = data_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Set Script
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the script to be set. script = '{-# SCRIPT_TYPE ACCOUNT #-} true' # Script example. # Create the Set Script transaction. try: print("Setting script for the address...") set_script_tx = my_address.setScript(script) except Exception as e: print(f"An error occurred while setting the script: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = set_script_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Set Asset Script
About Set Asset Script Transaction.
NOTE: You can set an asset script only on those asset that were issued with a ride script attached.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Specify the asset ID of the smart asset. asset_id = 'PASTE AN ASSET ID' # Create an asset object. asset = pw.Asset(asset_id) # Define the new script to be set for the asset. script_source = '{-# SCRIPT_TYPE ACCOUNT #-} true' # Script example. # Set the new script for the asset. try: print("Setting new script for the asset...") set_asset_script_tx = my_address.setAssetScript(asset, script_source) except Exception as e: print(f"An error occurred while setting the asset script: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = set_asset_script_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Update Asset Info
About Update Asset Info Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the asset ID of the asset to be updated. asset_id = 'PASTE YOUR ASSET ID' # Define the new name and description for the asset. new_name = 'NewAssetName' # Name example. new_description = 'Updated description for the asset' # Description example. # Creating the Update Asset Info transaction. try: print("Generating Update Asset Info transaction...") update_asset_info_tx = my_address.updateAssetInfo( assetId=asset_id, name=new_name, description=new_description ) except Exception as e: print(f"An error occurred while generating the Update Asset Info transaction: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: print("Transaction successfully broadcasted. Details:") print(json.dumps(update_asset_info_tx, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Invoke Script
About Invoke Script Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the dApp address to be invoked. dapp_address = 'PASTE A DAPP ADDRESS' # Define the callable function name. function_name = 'PASTE A FUNCTION NAME' # Define the arguments to pass to the function. params = [ # Example arguments: # {'type': 'string', 'value': 'example'}, # {'type': 'integer', 'value': 123} # Add your function arguments here. ] # Define any payments to be sent with the invocation. payments = [ # Example payment: # {'amount': 1000000, 'assetId': 'WAVES'} # Add your payment details here. ] # Define the transaction fee (in WAVES' smallest unit). tx_fee = pw.DEFAULT_INVOKE_SCRIPT_FEE # Default fee is 500000 (0.005 WAVES) # Create the Invoke Script transaction. try: print("Creating Invoke Script transaction...") invoke_tx = my_address.invokeScript( dappAddress=dapp_address, functionName=function_name, params=params, payments=payments, txFee=tx_fee ) except Exception as e: print(f"An error occurred while creating the Invoke Script transaction: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = invoke_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py
# Sponsor Fee
About Sponsor Fee Transaction.
In your project directory:
- Replace the
main.py
file code with the following snippet:# Necessary imports. import pywaves as pw import time import json # Set the node link and chain ID. pw.setNode( # Specify the link for the network: # - Mainnet: 'https://nodes.wavesnodes.com/' # - Testnet: 'https://nodes-testnet.wavesnodes.com/' # - Stagenet: 'https://nodes-stagenet.wavesnodes.com/' node='https://nodes-testnet.wavesnodes.com', # Specify the network chain ID: # - Mainnet: 'M' # - Testnet: 'T' # - Stagenet: 'S' chain='T' ) # Specify your wallet seed phrase. seed_phrase = 'PASTE YOUR SEED PHRASE' # Create an address object from the seed phrase. my_address = pw.Address(seed=seed_phrase) # Define the asset ID to be sponsored. asset_id = 'PASTE ASSET ID' # Create the Sponsor Fee transaction. try: print("Creating Sponsor Asset transaction...") sponsor_tx = my_address.sponsorAsset(assetId=asset_id) except Exception as e: print(f"An error occurred while creating the Sponsor Asset transaction: {e}") exit(1) # Wait for the transaction to be processed. print("Waiting for the transaction to be confirmed...") time.sleep(5) # Retrieve and print the transaction details. try: tx_data = sponsor_tx print("Transaction successfully broadcasted. Details:") print(json.dumps(tx_data, indent=4)) except Exception as e: print(f"An error occurred while retrieving transaction details: {e}")
- Run the
main.py
file:python main.py