Freezing assets
Authorized by: Asset Freeze Address
Freezing or unfreezing an asset for an account requires a transaction that is signed by the freeze account. The code below illustrates the freeze transaction.
sp = algod_client.suggested_params()# Create freeze transaction to freeze the asset in acct2 balancefreeze_txn = transaction.AssetFreezeTxn( sender=acct1.address, sp=sp, index=created_asset, target=acct2.address, new_freeze_state=True,)signed_freeze_txn = freeze_txn.sign(acct1.private_key)txid = algod_client.send_transaction(signed_freeze_txn)print(f"Sent freeze transaction with txid: {txid}")
results = transaction.wait_for_confirmation(algod_client, txid, 4)print(f"Result confirmed in round: {results['confirmed-round']}")
const freezeTxn = algosdk.makeAssetFreezeTxnWithSuggestedParamsFromObject({ from: manager.addr, suggestedParams, assetIndex, // freezeState: false would unfreeze the account's asset holding freezeState: true, // freezeTarget is the account that is being frozen or unfrozen freezeTarget: receiver.addr,});
const signedFreezeTxn = freezeTxn.signTxn(manager.privateKey);await algodClient.sendRawTransaction(signedFreezeTxn).do();await algosdk.waitForConfirmation( algodClient, freezeTxn.txID().toString(), 3);
goal asset freeze --freezer <asset-freeze-account> --freeze=true --account <account-to-freeze> --creator <asset-creator> --asset <asset-name> -d data
See also