Transferring assets
Authorized by: The account that holds the asset to be transferred.
Assets can be transferred between accounts that have opted-in to receiving the asset. These are analogous to standard payment transactions but for Algorand Standard Assets.
sp = algod_client.suggested_params()# Create transfer transactionxfer_txn = transaction.AssetTransferTxn( sender=acct1.address, sp=sp, receiver=acct2.address, amt=1, index=created_asset,)signed_xfer_txn = xfer_txn.sign(acct1.private_key)txid = algod_client.send_transaction(signed_xfer_txn)print(f"Sent transfer transaction with txid: {txid}")
results = transaction.wait_for_confirmation(algod_client, txid, 4)print(f"Result confirmed in round: {results['confirmed-round']}")
const xferTxn = algosdk.makeAssetTransferTxnWithSuggestedParamsFromObject({ from: creator.addr, to: receiver.addr, suggestedParams, assetIndex, amount: 1,});
const signedXferTxn = xferTxn.signTxn(creator.privateKey);await algodClient.sendRawTransaction(signedXferTxn).do();await algosdk.waitForConfirmation(algodClient, xferTxn.txID().toString(), 3);
goal asset send -a <asset-amount> --asset <asset-name> -f <asset-sender> -t <asset-receiver> --creator <asset-creator> -d data
See also
Transfer
transferAsset
The key function to facilitate asset transfers is transferAsset(transfer, algod)
, which returns a SendTransactionResult
and takes a TransferAssetParams
:
- All properties in
SendTransactionParams
from: SendTransactionFrom
- The account that will send the assetto: SendTransactionFrom | string
- The account / account address that will receive the assetassetId: number
- The asset id that will be transferredamount: number | bigint
- The amount to send in the smallest divisible unittransactionParams?: SuggestedParams
- The optional transaction parametersclawbackFrom: SendTransactionFrom | string
- An optional address of a target account from which to perform a clawback operation. Please note, in such cases senderAccount must be equal to clawback field on ASA metadata.note?: TransactionNote
- The transaction notelease?: string | Uint8Array
: A lease to assign to the transaction to enforce a mutually exclusive transaction (useful to prevent double-posting and other scenarios)