def transfer(passphrase=None) -> None: """ Creates an unsigned transfer transaction that is then sent off for signing and submission to the blockchain via the `sign_and_send` function. The transaction is submitted for the specified asset_id, to the specified address, for the specified amount. :param passphrase -> ``str``: the senders passphrase (used to sign the transaction) :return -> ``None``: """ amount = 100 transfer_data = { "sender": creator_address, "receiver": receiver_address, "amt": amount, "index": asset_id, "flat_fee": True } data = add_network_params(client, transfer_data) transaction = AssetTransferTxn(**data) if passphrase: transaction_info = sign_and_send(transaction, passphrase, client) formatted_amount = balance_formatter(amount, asset_id, client) print("Transferred {} from {} to {}".format(formatted_amount, creator_address, receiver_address)) print("Transaction ID Confirmation: {}".format( transaction_info.get("tx"))) else: write_to_file([transaction], "transfer.txn")
def create(passphrase=None): """ Returns an unsigned txn object and writes the unsigned transaction object to a file for offline signing. Uses current network params. """ print(headers) data = add_network_params(asset_details, client) txn = AssetConfigTxn(**data) if passphrase: txinfo = sign_and_send(txn, passphrase, client) print("Create asset confirmation, txid: {}".format(txinfo.get('tx'))) asset_id = txinfo['txresults'].get('createdasset') print("Asset ID: {}".format(asset_id)) else: write_to_file([txn], "create_coin.txn")
def create(passphrase: str = None) -> None: """ creates the asset that is defined in `config.py`, signs it, and sends it to the algorand network if the senders passphrase is supplied. Otherwise, the transaction is written to a file. :param passphrase -> ``str``: the user passphrase. :return -> `None`: """ transaction_data = add_network_params(client, asset_details) transaction = AssetConfigTxn(**transaction_data) if passphrase: transaction_info = sign_and_send(transaction, passphrase, client) print(f"Create asset confirmation, transaction ID: {transaction}") asset_id = transaction_info['txresults'].get('createdasset') print(f"Asset ID: {asset_id}") else: write_to_file([transaction], "create_coin.txn")
def optin(passphrase=None): """ Creates an unsigned opt-in transaction for the specified asset id and address. Uses current network params. """ optin_data = { "sender": receiver_address, "receiver": receiver_address, "amt": 0, "index": asset_id } data = add_network_params(optin_data, client) txn = AssetTransferTxn(**data) if passphrase: txinfo = sign_and_send(txn, passphrase, client) print("Opted in to asset ID: {}".format(asset_id)) print("Transaction ID Confirmation: {}".format(txinfo.get("tx"))) else: write_to_file([txn], "optin.txn")
def transfer(passphrase=None): """ Creates an unsigned transfer transaction for the specified asset id, to the specified address, for the specified amount. """ amount = 6000 transfer_data = { "sender": creator_address, "receiver": receiver_address, "amt": amount, "index": asset_id } data = add_network_params(transfer_data, client) txn = AssetTransferTxn(**data) if passphrase: txinfo = sign_and_send(txn, passphrase, client) formatted_amount = balance_formatter(amount, asset_id, client) print("Transferred {} from {} to {}".format(formatted_amount, creator_address, receiver_address)) print("Transaction ID Confirmation: {}".format(txinfo.get("tx"))) else: write_to_file([txn], "transfer.txn")
def opt_in(passphrase: str = None) -> None: """ Creates, signs, and sends an opt-in transaction for the specified asset_id. If the passphrase is not supplied, writes the unsigned transaction to a file. :param passphrase -> ``str``: the user passphrase. :return -> `None`: """ opt_in_data = { "sender": creator_address, "receiver": receiver_address, "amt": 10, "index": asset_id } transaction_data = add_network_params(client, opt_in_data) transaction = AssetTransferTxn(**transaction_data) if passphrase: txinfo = sign_and_send(transaction, passphrase, client) created_asset_id = txinfo['txresults'].get('createdasset') print("Opted in to asset ID: {}".format(created_asset_id)) print("Transaction ID Confirmation: {}".format(txinfo.get("tx"))) else: write_to_file([transaction], "optin.txn")