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.
Transaction Signing Requirements
The account sending the tokens is required to sign the transaction.
Constructor | Description |
| Initializes the TransferTransaction object |
new TransferTransaction()
Method | Type | Description |
| AccountID, Hbar | The account the transfer is being debited from. The sending account must sign the transaction. The sender and recipient values must net zero. |
| TokenId, AccountId, long | The ID of the token, the account ID to transfer the tokens from, value of the token to transfer. The sender and recipient values must net zero. |
Java// Create a transaction to transfer 100 hbarsTransferTransaction transaction1 = new TransferTransaction().addHbarTransfer(OPERATOR_ID, new Hbar(-10)).addHbarTransfer(newAccountId, new Hbar(10));​//Submit the transaction to a Hedera networkTransactionResponse txResponse = transaction.execute(client);​//Request the receipt of the transactionTransactionReceipt receipt = txResponse.getReceipt(client);​//Get the transaction consensus statusStatus transactionStatus = receipt.status;​System.out.println("The transaction consensus status is " +transactionStatus);​//Version 2.0.0
JavaScript// Create a transaction to transfer 100 hbarsconst transaction = new TransferTransaction().addHbarTransfer(OPERATOR_ID, new Hbar(-100)).addHbarTransfer(newAccountId, new Hbar(100));//Submit the transaction to a Hedera networkconst txResponse = await transaction.execute(client);​//Request the receipt of the transactionconst receipt = await txResponse.getReceipt(client);​//Get the transaction consensus statusconst transactionStatus = receipt.status;​console.log("The transaction consensus status is " +transactionStatus.toString());​//v2.0.5
Go// Create a transaction to transfer 100 hbarstransaction := hedera.NewTransferTransaction().AddHbarTransfer(client.GetOperatorAccountID(), hedera.NewHbar(-1)).AddHbarTransfer(hedera.AccountID{Account: 3}, hedera.NewHbar(1))​//Submit the transaction to a Hedera networktxResponse, err := transaction.Execute(client)​if err != nil {panic(err)}​//Request the receipt of the transactionreceipt, err := txResponse.GetReceipt(client)​if err != nil {panic(err)}​//Get the transaction consensus statustransactionStatus := receipt.Status​fmt.Printf("The transaction consensus status is %v\n", transactionReceipt.Status)​//Version 2.0.0
Constructor | Description |
| Initializes the TransferTransaction object |
new TransferTransaction()
Method | Type | Description |
| AccountId, Hbar/long | The account the transfer is being debited from. The sending account must sign the transaction. The sender and recipient values must net zero. |
| TokenId, AccountId, long | The ID of the token, the account ID to transfer the tokens from, value of the token to transfer. The sender and recipient values must net zero. |
Java//Create the transfer transactionTransferTransaction transaction1 = new TransferTransaction().addHbarTransfer(OPERATOR_ID, new Hbar(-10)).addHbarTransfer(newAccountId, new Hbar(10));​//Sign with the client operator key and submit the transaction to a Hedera networkTransactionId txId = transaction.execute(client);//Request the receipt of the transactionTransactionReceipt receipt = txId.getReceipt(client);​//Get the transaction consensus statusStatus transactionStatus = receipt.status;​System.out.println("The transaction consensus status is " +transactionStatus);​//v1.3.2
JavaScript//Create the transfer transactionconst transaction = new TransferTransaction().addHbarTransfer(OPERATOR_ID, new Hbar(-10)).addHbarTransfer(newAccountId, new Hbar(10));​//Sign with the client operator key and submit the transaction to a Hedera networkconst txId = await transaction.execute(client);//Request the receipt of the transactionconst receipt = await txId.getReceipt(client);​//Get the transaction consensus statusconst transactionStatus = receipt.status;​console.log("The transaction consensus status is " +transactionStatus);​//v1.4.4
​
Method | Type | Description |
| Map<AccountId, Hbar> | Returns a list of the hbar transfers in this transaction |
| Map<TokenId, Map<AccountId, long>> | Returns the list of token transfers in the transaction |
Java// Create a transactionCryptoTransferTransaction transaction = new CryptoTransferTransaction().addSender(OPERATOR_ID, new Hbar(10)).addRecipient(newAccountId, new Hbar(10));​//Get transfersList<Transfer> transfers = transaction.getTransfers();​//v2.0.0
JavaScript// Create a transactionconst transaction = new CryptoTransferTransaction().addSender(OPERATOR_ID, new Hbar(10)).addRecipient(newAccountId, new Hbar(10));​//Get transfersconst transfers = transaction.getTransfers();​//v2.0.0
Go// Create a transactiontransaction := hedera.NewTransferTransaction().AddHbarTransfer(client.GetOperatorAccountID(), hedera.NewHbar(-1)).AddHbarTransfer(hedera.AccountID{Account: 3}, hedera.NewHbar(1))//Get transferstransfers := transaction.GetTransfers()​//v2.0.0