A transaction that transfers hbars and tokens between Hedera accounts. You can enter multiple transfers in a single
transaction. The net value of hbars between the sending accounts and receiving accounts must equal zero.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Transaction
Transaction.SignableNodeTransactionBodyBytesNested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Executable
Executable.GrpcRequest -
Field Summary
Fields inherited from class com.hedera.hashgraph.sdk.AbstractTokenTransferTransaction
nftTransfers, tokenTransfersFields inherited from class com.hedera.hashgraph.sdk.Transaction
customFeeLimits, DEFAULT_AUTO_RENEW_PERIOD, defaultMaxTransactionFee, DUMMY_ACCOUNT_ID, DUMMY_TRANSACTION_ID, frozenBodyBuilder, innerSignedTransactions, outerTransactions, publicKeys, regenerateTransactionId, signers, sigPairLists, sourceTransactionBody, transactionIdsFields inherited from class com.hedera.hashgraph.sdk.Executable
attemptedAllNodes, blockingUnaryCall, grpcDeadline, logger, maxAttempts, maxBackoff, minBackoff, nodeAccountIds, nodes, random, RST_STREAM -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.TransferTransaction(TransactionBody txBody) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddApprovedHbarTransfer(AccountId accountId, Hbar value) Add an approved hbar transfer.addHbarTransfer(AccountId accountId, Hbar value) Add a non approved hbar transfer.addHbarTransfer(EvmAddress evmAddress, Hbar value) Add a non approved hbar transfer to an EVM address.addHbarTransferWithHook(AccountId accountId, Hbar amount, FungibleHookCall hookCall) Add an HBAR transfer with a fungible hook.addNftTransferWithHook(NftId nftId, AccountId senderAccountId, AccountId receiverAccountId, NftHookCall senderHookCall, NftHookCall receiverHookCall) Add an NFT transfer with optional sender/receiver allowance hooks.addTokenTransferWithHook(TokenId tokenId, AccountId accountId, long value, FungibleHookCall hookCall) Add an token transfer with allowance hook.(package private) CryptoTransferTransactionBody.Builderbuild()Build the transaction body.Extract the of hbar transfers.(package private) io.grpc.MethodDescriptor<Transaction, TransactionResponse> Called to direct the invocation of the query to the appropriate gRPC service.(package private) voidInitialize from the transaction body.(package private) voidonFreeze(TransactionBody.Builder bodyBuilder) Called inTransaction.freezeWith(Client)just before the transaction body is built.(package private) voidonScheduled(SchedulableTransactionBody.Builder scheduled) Called inTransaction.schedule()when converting transaction into a scheduled version.setHbarTransferApproval(AccountId accountId, boolean isApproved) Deprecated.(package private) static FungibleHookCalltoFungibleHook(HookCall proto, FungibleHookType type) (package private) static NftHookCalltoNftHook(HookCall proto, NftHookType type) (package private) voidvalidateChecksums(Client client) Methods inherited from class com.hedera.hashgraph.sdk.AbstractTokenTransferTransaction
addApprovedNftTransfer, addApprovedTokenTransfer, addApprovedTokenTransferWithDecimals, addNftTransfer, addTokenTransfer, addTokenTransferWithDecimals, doAddNftTransfer, doAddTokenTransfer, getTokenIdDecimals, getTokenNftTransfers, getTokenTransfers, setNftTransferApproval, setTokenTransferApproval, sortTransfersAndBuildMethods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, addSignature, batchify, buildAllTransactions, buildTransaction, doSchedule, estimateFee, freeze, freezeWith, fromBytes, fromScheduledTransaction, generateTransactionIds, getBatchKey, getDefaultMaxTransactionFee, getExecutionState, getHighVolume, getMaxTransactionFee, getRegenerateTransactionId, getRequiredChunks, getSignableNodeBodyBytesList, getSignatures, getSignaturesAtOffset, getTransactionBodySize, getTransactionHash, getTransactionHashPerNode, getTransactionId, getTransactionIdInternal, getTransactionMemo, getTransactionSize, getTransactionValidDuration, hash, isBatchedAndNotBatchTransaction, isFrozen, keyAlreadySigned, makeRequest, mapResponse, mapResponseStatus, onExecute, onExecuteAsync, regenerateTransactionId, requireNotFrozen, requireOneNodeAccountId, schedule, setBatchKey, setHighVolume, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signTransaction, signWith, signWithOperator, spawnBodyBuilder, toBytes, toString, wipeTransactionListsMethods inherited from class com.hedera.hashgraph.sdk.Executable
advanceRequest, checkNodeAccountIds, execute, execute, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, getGrpcRequest, getMaxAttempts, getMaxBackoff, getMaxRetry, getMinBackoff, getNodeAccountIds, getNodeForExecute, grpcDeadline, logTransaction, mergeFromClient, setGrpcDeadline, setLogger, setMaxAttempts, setMaxBackoff, setMaxRetry, setMinBackoff, setNodesFromNodeAccountIds, setRequestListener, setResponseListener, shouldRetryExceptionally
-
Constructor Details
-
TransferTransaction
public TransferTransaction()Constructor. -
TransferTransaction
TransferTransaction(LinkedHashMap<TransactionId, LinkedHashMap<AccountId, throws com.google.protobuf.InvalidProtocolBufferExceptionTransaction>> txs) Constructor.- Parameters:
txs- Compound list of transaction id's list of (AccountId, Transaction) records- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
TransferTransaction
TransferTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
-
Method Details
-
getHbarTransfers
Extract the of hbar transfers.- Returns:
- list of hbar transfers
-
addHbarTransfer
Add a non approved hbar transfer to an EVM address.- Parameters:
evmAddress- the EVM addressvalue- the value- Returns:
- the updated transaction
-
addHbarTransfer
Add a non approved hbar transfer.- Parameters:
accountId- the account idvalue- the value- Returns:
- the updated transaction
-
addApprovedHbarTransfer
Add an approved hbar transfer.- Parameters:
accountId- the account idvalue- the value- Returns:
- the updated transaction
-
addTokenTransferWithHook
public TransferTransaction addTokenTransferWithHook(TokenId tokenId, AccountId accountId, long value, FungibleHookCall hookCall) Add an token transfer with allowance hook.- Parameters:
tokenId- the tokenIdaccountId- the accountIdvalue- the amounthookCall- the hook- Returns:
- the updated transaction
-
addNftTransferWithHook
public TransferTransaction addNftTransferWithHook(NftId nftId, AccountId senderAccountId, AccountId receiverAccountId, NftHookCall senderHookCall, NftHookCall receiverHookCall) Add an NFT transfer with optional sender/receiver allowance hooks.- Parameters:
nftId- the NFT idsenderAccountId- the senderreceiverAccountId- the receiversenderHookCall- optional sender hook callreceiverHookCall- optional receiver hook call- Returns:
- the updated transaction
-
addHbarTransferWithHook
public TransferTransaction addHbarTransferWithHook(AccountId accountId, Hbar amount, FungibleHookCall hookCall) Add an HBAR transfer with a fungible hook.- Parameters:
accountId- the account idamount- the amount to transferhookCall- the fungible hook call to execute- Returns:
- the updated transaction
- Throws:
IllegalArgumentException- if hookCall is null
-
setHbarTransferApproval
@Deprecated public TransferTransaction setHbarTransferApproval(AccountId accountId, boolean isApproved) Deprecated.- UseaddApprovedHbarTransfer(AccountId, Hbar)instead- Parameters:
accountId- the account idisApproved- whether the transfer is approved- Returns:
this
-
build
Build the transaction body.- Returns:
CryptoTransferTransactionBody
-
validateChecksums
- Overrides:
validateChecksumsin classAbstractTokenTransferTransaction<TransferTransaction>- Throws:
BadEntityIdException
-
getMethodDescriptor
io.grpc.MethodDescriptor<Transaction,TransactionResponse> getMethodDescriptor()Description copied from class:ExecutableCalled to direct the invocation of the query to the appropriate gRPC service.- Specified by:
getMethodDescriptorin classExecutable<TransferTransaction,Transaction, TransactionResponse, TransactionResponse>
-
onFreeze
Description copied from class:TransactionCalled inTransaction.freezeWith(Client)just before the transaction body is built. The intent is for the derived class to assign their data variant to the transaction body.- Specified by:
onFreezein classTransaction<TransferTransaction>
-
onScheduled
Description copied from class:TransactionCalled inTransaction.schedule()when converting transaction into a scheduled version.- Specified by:
onScheduledin classTransaction<TransferTransaction>
-
initFromTransactionBody
void initFromTransactionBody()Initialize from the transaction body. -
toFungibleHook
-
toNftHook
-
addApprovedHbarTransfer(AccountId, Hbar)instead