A transaction that deletes an existing account from the Hedera network. Before deleting an account, the existing hbars must be transferred to another account. If you fail to transfer the hbars, you will receive an error message "setTransferAccountId() required." Transfers cannot be made into a deleted account. A record of the deleted account will remain in the ledger until it expires.The expiration of a deleted account can be extended. The account that is being deleted is required to sign the transaction.
Transaction Signing Requirements
The account the is being deleted is required to sign the transaction
Constructor | Description |
| Initializes the AccountDeleteTransaction object |
new AccountDeleteTransaction()
Method | Type | Description | Requirement |
| AccountId | The ID of the account to delete. | Required |
| AccountId | The ID of the account to transfer the remaining funds to. | Optional |
Java//Create the transaction to delete an accountAccountDeleteTransaction transaction = new AccountDeleteTransaction().setAccountId(accountId).setTransferAccountId(OPERATOR_ID);​//Freeze the transaction for signing, sign with the private key of the account that will be deleted, sign with the operator key and submit to a Hedera networkTransactionResponse txResponse = transaction.freezeWith(client).sign(newKey).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);
JavaScript//Create the transaction to delete an accountconst transaction = await new AccountDeleteTransaction().setAccountId(accountId).setTransferAccountId(OPERATOR_ID).freezeWith(client);​//Sign the transaction with the account keyconst signTx = await transaction.sign(accountKey);//Sign with the client operator private key and submit to a Hedera networkconst txResponse = await signTx.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);​//2.0.5
Go//Create the transaction to delete an account, freeze the transaction for signingtransaction, err := hedera.NewAccountDeleteTransaction().SetAccountID(newAccountID).SetTransferAccountID(operatorAccountID).FreezeWith(client)if err != nil {panic(err)}​//Sign with the private key of the account that will be deleted, sign with the operator key and submit to a Hedera networktxResponse, err := transaction.Sign(accountKey).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", transactionStatus)​//v2.0.0
Method | Type | Description | Requirement |
| AccountId | The ID of the account to delete. | Required |
| AccountId | The ID of the account to transfer the remaining funds to. | Optional |
Java//Create the transactionAccountDeleteTransaction transaction = new AccountDeleteTransaction().setDeleteAccountId(accountId).setTransferAccountId(OPERATOR_ID);​//Build the unsigned transaction, sign with account key, sign with the client operator account private key and submit to a Hedera networkTransactionId txId = transaction.build(client).sign(newKey).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 transactionconst transaction = await new AccountDeleteTransaction().setDeleteAccountId(accountId).setTransferAccountId(OPERATOR_ID).builc(client);​//Sign the transaction with the account keyconst signTx = await transaction.sign(accountKey);//Sign with the client operator private key and submit to a Hedera networkconst txId = await signTx.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);
Method | Type | Description |
| AccountId | The account to delete |
| AccountId | The account to transfer the remaining funds to |
Java//Create the transaction to delete an accountAccountDeleteTransaction transaction = new AccountDeleteTransaction().setAccountId(newAccountId).setTransferAccountId(OPERATOR_ID);//Get the account ID from the transactionAccountId transactionAccountId = transaction.getAccountId()​System.out.println("The account to be deleted in this transaction is " +transactionAccountId)​//v2.0.0
JavaScript//Create the transaction to delete an accountconst transaction = new AccountDeleteTransaction().setAccountId(newAccountId).setTransferAccountId(OPERATOR_ID);//Get the account ID from the transactionconst transactionAccountId = transaction.getAccountId()​console.log("The account to be deleted in this transaction is " +transactionAccountId)
Go//Create the transaction to delete an accounttransaction, err := hedera.NewAccountDeleteTransaction().SetAccountID(newAccountID).SetTransferAccountID(operatorAccountID)//Get the account ID from the transactiontransactionAccountId := transaction.GetAccountID()​//v2.0.0