Skip to main content
A transaction that allows a token owner to delegate a token spender to spend the specified token amount on behalf of the token owner. A Hedera account owner can provide an allowance for HBAR, non-fungible, and fungible tokens. The owner is the Hedera account that owns the tokens and grants the token allowance to the spender. The spender is the account that spends tokens, authorized by the owner, from the owner’s account. The spender pays for the transaction fees when transferring tokens from the owner’s account to another recipient. This means that the transaction fee payer for the TransferTransaction is required to set the spender account ID as the transaction fee payer. If the spender account ID is not set as the transaction fee payer, the system will error with SPENDER_DOES_NOT_HAVE_ALLOWANCE. The maximum number of token approvals for the AccountAllowanceApproveTransaction cannot exceed 20. Note that each NFT serial number counts as a single approval. An AccountAllowanceApproveTransaction granting 20 NFT serial numbers to a spender will use all of the approvals permitted for the transaction. A single NFT serial number can only be granted to one spender at a time. If an approval assigns a previously approved NFT serial number to a new user, the old user will have their approval removed. Each owner account is limited to granting 100 allowances. This limit spans HBAR, fungible token allowances, and non-fungible token approved_for_all grants. No limit exists on the number of NFT serial number approvals an owner may grant. The number of allowances set on an account will increase the auto-renewal fee for the account. Conversely, removing allowances will decrease the auto-renewal fee for the account. To decrease the allowance for a given spender, you must set the amount to the value you would like to authorize the account for. If the spender account was authorized to spend 25 HBAR and the owner wants to modify their allowance to 5 HBAR, the owner would submit the AccountAllowanceApproveTransaction for 5 HBAR. Only when a spender is set on an explicit NFT ID of a token, do we return the spender ID in TokenNftInfoQuery for the respective NFT. If approveTokenNftAllowanceAllSerials is used to approve all NFTs for a given token class, and no NFT ID is specified; we will not return a spender ID for all the serial numbers of that token. Transaction Fees
  • Please see the transaction and query fees table for the base transaction fee
  • Please use the Hedera fee estimator to estimate your transaction fee cost
Transaction Signing Requirements
  • Must be signed by the owner’s account
  • Must be signed by the transaction fee payer if different then the owner account
  • If the owner and transaction fee payer key are the same only one signature is required
Reference: HIP-336

Constructor

ConstructorDescription
new AccountAllowanceApproveTransaction()Initializes the AccountAllowanceApproveTransaction object

Transaction Properties

MethodTypeRequirement
approveHbarAllowance(<ownerAccountId, spenderAccountId, amount>)AccountId, AccountId, HbarOptional
approveTokenAllowance(<tokenId, ownerAccountId, spenderAccountId, amount>)TokenId, AccountId, AccountId, longOptional
approveTokenNftAllowance(<nftId, ownerAccountId, spenderAccountId>)NftId, AccountId, AccountIdOptional
approveTokenNftAllowanceAllSerials(<tokenId, ownerAccountId, spenderAccountId>)TokenId, AccountId, AccountIdOptional
setHighVolume(<highVolume>)booleanOptional

Get Transaction Values

MethodTypeDescription
getHbarApprovals()List<HbarAllowance>Returns the HBAR allowances
getTokenApprovals()List<TokenAllowance>Returns the fungible token allowances
getTokenNftApprovals()List<TokenNftAllowance>Returns the NFT allowances
getHighVolume()booleanReturns whether this transaction uses high-volume throttles
This transaction supports high-volume entity creation (HIP-1313). Setting setHighVolume(true) routes the transaction through dedicated high-volume throttle capacity with variable-rate pricing. Always pair this with setMaxTransactionFee() to cap your costs.
//Create the transaction
AccountAllowanceApproveTransaction transaction = new AccountAllowanceApproveTransaction()
    .approveHbarAllowance(ownerAccount, spenderAccountId, Hbar.from(1));

//Sign the transaction with the owner account key and the transaction fee payer key (client)  
TransactionResponse txResponse = transaction.freezeWith(client).sign(ownerAccountKey).execute(client);

//Request the receipt of the transaction
TransactionReceipt receipt = txResponse.getReceipt(client);

//Get the transaction consensus status
Status transactionStatus = receipt.status;

System.out.println("The transaction consensus status is " +transactionStatus);

//v2.12.0+