def deploy_token1_token2(): print( f"Deploying tokens {TOKEN1_ASSET_NAME} ({TOKEN1_UNIT_NAME}) and {TOKEN2_ASSET_NAME} ({TOKEN2_UNIT_NAME})..." ) txn_1 = transaction.AssetConfigTxn( sender=DEVELOPER_ACCOUNT_ADDRESS, sp=algod_client.suggested_params(), total=TOKEN1_AMOUNT, default_frozen=False, unit_name=TOKEN1_UNIT_NAME, asset_name=TOKEN1_ASSET_NAME, manager=DEVELOPER_ACCOUNT_ADDRESS, reserve=DEVELOPER_ACCOUNT_ADDRESS, freeze=DEVELOPER_ACCOUNT_ADDRESS, clawback=DEVELOPER_ACCOUNT_ADDRESS, url=f"https://algoswap.io/{TOKEN1_UNIT_NAME}", decimals=TOKEN1_DECIMALS).sign(DEVELOPER_ACCOUNT_PRIVATE_KEY) txn_2 = transaction.AssetConfigTxn( sender=DEVELOPER_ACCOUNT_ADDRESS, sp=algod_client.suggested_params(), total=TOKEN2_AMOUNT, default_frozen=False, unit_name=TOKEN2_UNIT_NAME, asset_name=TOKEN2_ASSET_NAME, manager=DEVELOPER_ACCOUNT_ADDRESS, reserve=DEVELOPER_ACCOUNT_ADDRESS, freeze=DEVELOPER_ACCOUNT_ADDRESS, clawback=DEVELOPER_ACCOUNT_ADDRESS, url=f"https://algoswap.io/{TOKEN2_UNIT_NAME}", decimals=TOKEN2_DECIMALS).sign(DEVELOPER_ACCOUNT_PRIVATE_KEY) tx_id_1 = algod_client.send_transaction(txn_1) tx_id_2 = algod_client.send_transaction(txn_2) token_1_asset_id = wait_for_transaction(tx_id_1)['created-asset-index'] token_2_asset_id = wait_for_transaction(tx_id_2)['created-asset-index'] print( f"Deployed {TOKEN1_ASSET_NAME} ({TOKEN1_UNIT_NAME}) with Asset ID: {token_1_asset_id} | Tx ID: https://testnet.algoexplorer.io/tx/{tx_id_1}" ) print( f"Deployed {TOKEN2_ASSET_NAME} ({TOKEN2_UNIT_NAME}) with Asset ID: {token_2_asset_id} | Tx ID: https://testnet.algoexplorer.io/tx/{tx_id_2}" ) print() return token_1_asset_id, token_2_asset_id
def default_frozen_asset_creation_txn(context, total): context.total = int(total) params = context.acl.suggested_params_as_object() context.last_round = params.first context.pk = context.accounts[0] asset_name = "asset" unit_name = "unit" params.fee = 1 context.txn = transaction.AssetConfigTxn(context.pk, params, total=context.total, default_frozen=True, unit_name=unit_name, asset_name=asset_name, manager=context.pk, reserve=context.pk, freeze=context.pk, clawback=context.pk) context.expected_asset_info = { "defaultfrozen": False, "unitname": "unit", "assetname": "asset", "managerkey": context.pk, "reserveaddr": context.pk, "freezeaddr": context.pk, "clawbackaddr": context.pk, "creator": context.pk, "total": context.total, "decimals": 0, "metadatahash": None, "url": "" }
def create_asset( client, sender, sender_priv_key, suggested_params, total, decimals, ): txn = transaction.AssetConfigTxn( sender, sp=suggested_params, total=total, default_frozen=False, unit_name='TESTASA', asset_name='testasa', manager=sender, reserve=sender, freeze=sender, clawback=sender, url='', decimals=decimals, ) signed_txn = txn.sign(sender_priv_key) tx_id = client.send_transactions([signed_txn]) return tx_id
def acfg(self, sender, send=None, **kwargs): params = self.algod.suggested_params() tx = txn.AssetConfigTxn(sender, params, **kwargs, strict_empty_address_check=False) return self.finish(tx, send)
def deploy_liquidity_pair_token(): print( f"Deploying token {LIQUIDITY_TOKEN_ASSET_NAME} ({LIQUIDITY_TOKEN_UNIT_NAME})..." ) txn = transaction.AssetConfigTxn( sender=DEVELOPER_ACCOUNT_ADDRESS, sp=algod_client.suggested_params(), total=LIQUIDITY_TOKEN_AMOUNT, default_frozen=False, unit_name=LIQUIDITY_TOKEN_UNIT_NAME, asset_name=LIQUIDITY_TOKEN_ASSET_NAME, manager=DEVELOPER_ACCOUNT_ADDRESS, reserve=DEVELOPER_ACCOUNT_ADDRESS, freeze=DEVELOPER_ACCOUNT_ADDRESS, clawback=DEVELOPER_ACCOUNT_ADDRESS, url=f"https://algoswap.io/{LIQUIDITY_TOKEN_UNIT_NAME}", decimals=LIQUIDITY_TOKEN_DECIMALS).sign(DEVELOPER_ACCOUNT_PRIVATE_KEY) tx_id = algod_client.send_transaction(txn) liquidity_token_asset_id = int( wait_for_transaction(tx_id)['created-asset-index']) print( f"Deployed {LIQUIDITY_TOKEN_ASSET_NAME} ({LIQUIDITY_TOKEN_UNIT_NAME}) with Asset ID: {liquidity_token_asset_id} | Tx ID: https://testnet.algoexplorer.io/tx/{tx_id}" ) print() return liquidity_token_asset_id
def no_manager_txn(context): context.txn = transaction.AssetConfigTxn( context.pk, context.acl.suggested_params_as_object(), index=context.asset_index, reserve=context.pk, clawback=context.pk, freeze=context.pk, strict_empty_address_check=False) context.expected_asset_info["managerkey"] = ""
def create_asset_destroy_txn(context): context.txn = transaction.AssetConfigTxn( context.pk, context.acl.suggested_params_as_object(), index=context.asset_index, strict_empty_address_check=False)
) # this transaction must be sent from the manager's account _, new_freeze = account.generate_account( ) # account that can freeze other accounts for this asset _, new_manager = account.generate_account( ) # account able to update asset configuration _, new_clawback = account.generate_account( ) # account allowed to take this asset from any other account _, new_reserve = account.generate_account( ) # account that holds reserves for this asset fee_per_byte = 10 first_valid_round = 1000 last_valid_round = 2000 genesis_hash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=" index = 1234 # identifying index of the asset # create the asset config transaction sp = transaction.SuggestedParams(fee_per_byte, first_valid_round, last_valid_round, genesis_hash) txn = transaction.AssetConfigTxn(manager_address, sp, manager=new_manager, reserve=new_reserve, freeze=new_freeze, clawback=new_clawback, index=index) # sign the transaction signed_txn = txn.sign(manager_private_key)
# Example: destroying an asset from algosdk import account from algosdk.future import transaction # this transaction must be sent from the creator's account creator_private_key, creator_address = account.generate_account() fee_per_byte = 10 first_valid_round = 1000 last_valid_round = 2000 genesis_hash = "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=" index = 1234 # identifying index of the asset # create the asset destroy transaction sp = transaction.SuggestedParams(fee_per_byte, first_valid_round, last_valid_round, genesis_hash) txn = transaction.AssetConfigTxn(creator_address, sp, index=index, strict_empty_address_check=False) # sign the transaction signed_txn = txn.sign(creator_private_key)
print("ESCROW_ADDRESS:", ESCROW_ADDRESS) print( f"Escrow logicsig currently uses {len(base64.b64decode(compile_response['result']))} of 1000 bytes" ) token1_name, token2_name = "USDt", "USDC" # TODO create_asset_transaction = transaction.AssetConfigTxn( sender=DEVELOPER_ACCOUNT_ADDRESS, sp=algod_client.suggested_params(), strict_empty_address_check=False, total=1000, default_frozen=False, unit_name=f'ALGOSWAP', asset_name=f'AlgoSwap {token1_name}-{token2_name} Liquidity', manager= DEVELOPER_ACCOUNT_ADDRESS, # TODO: change this to zero address (note that that change will break something in sig validation) reserve=ESCROW_ADDRESS, freeze= DEVELOPER_ACCOUNT_ADDRESS, # TODO: change this to zero address (note that that change will break something in sig validation) clawback= DEVELOPER_ACCOUNT_ADDRESS, # TODO: change this to zero address (note that that change will break something in sig validation) url="https://git.io/JU232", metadata_hash=b"12345678901234567890123456789012", decimals=8, ).sign(DEVELOPER_ACCOUNT_PRIVATE_KEY) print(create_asset_transaction.dictify()) transaction_id = algod_client.send_transaction(create_asset_transaction) print(wait_for_transaction(transaction_id)) liquidity_asset_id = wait_for_transaction(transaction_id) print( f"Asset \"AlgoSwap {token1_name}-{token2_name} Liquidity\" deployed with asset ID {liquidity_asset_id} (transaction: {transaction_id})"