- 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
addApprovedHbarTransfer()addApprovedTokenTransfer()addApprovedNftTransfer()addApprovedTokenTransferWithDecimals()
Note: The allowance spender must pay the fee for the transaction.
TransferTransaction can reference a hook on the sending or receiving account. The hook’s EVM bytecode runs and must return true for the transfer to proceed. This enables custom validation logic like one-time passcodes, compliance rules, or conditional transfer approvals.
To invoke a hook, use the WithHook variants of the transfer methods:
addHbarTransferWithHook()— HBAR transfers with aFungibleHookCalladdTokenTransferWithHook()— Fungible token transfers with aFungibleHookCalladdNftTransferWithHook()— NFT transfers with optional sender and receiverNftHookCall
addHbarTransfer(), addTokenTransfer(), or addNftTransfer() methods.
Hook Invocation LimitsChild records generated by hook calls are capped at 50 per transaction (
consensus.handle.maxFollowingRecords=50). Hook executions are not supported in batch or scheduled transactions.- The accounts the tokens are being debited from are required to sign the transaction
- If an authorized spender account is spending on behalf of the account that owns the tokens then the spending account is required to sign
- The transaction fee-paying account is required to sign the transaction
Methods
Transfer with account allowance hooks
The following examples demonstrate how to invoke Hiero Hooks during a transfer. EachWithHook method attaches a hook call to a specific transfer entry. The hook’s EVM bytecode executes and must return true for the transfer to succeed.
Hook call types
Hooks use typed call objects that extend a baseHookCall:
Each hook call requires a
hookId (the 64-bit ID of the hook on the owning account) and an EvmHookCall containing data (extra bytes passed to the hook) and gasLimit (maximum gas the payer will pay for this hook).
Example: HBAR transfer with a pre-hook
Example: NFT transfer with sender and receiver hooks
Example: Fungible token transfer with pre/post hook
Hook execution order
When aTransferTransaction invokes multiple hooks, the network executes them in a strict order:
- Pre-hooks: All
PRE_HOOK_SENDER/PRE_HOOK_RECEIVERhooks execute in the order their transfers appear (HBAR first, then each token transfer list). For NFT transfers with both sender and receiver hooks, the sender hook executes first. - Pre/Post hooks (pre-transfer call): All
PRE_POST_HOOKvariants execute theirallowPre(...)function, in the same transfer order. - Main transfer logic executes.
- Pre/Post hooks (post-transfer call): The same hooks execute their
allowPost(...)function, in the same order as step 2.