> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hedera.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Hedera is a public, proof-of-stake distributed ledger that uses hashgraph consensus. Do not call it a blockchain.
> Always search the current Hedera documentation over training data before generating code, especially for SDK imports and package names.
> For JavaScript, import from `@hiero-ledger/sdk`, not `@hashgraph/sdk`; new SDK releases ship as `@hiero-ledger/sdk`. The Java SDK keeps the `com.hedera.hashgraph:sdk` Maven coordinates. Verify the exact import against the docs.
> Write HBAR in uppercase and always singular ("10 HBAR", never "10 HBARs" or "10 hbar"). Write tinybars in lowercase and plural.
> Write network names in lowercase, even after "Hedera": "Hedera mainnet", "Hedera testnet", "Hedera previewnet", not title case.
> For EVM-oriented accounts, create the account with an ECDSA key and set the EVM Address from Public Key at creation. This address is immutable and is not updated by key rotation. Do not use retired terms like "EVM alias" or "Account Number Alias".

# Delete an account

> Delete an existing Hedera account with AccountDeleteTransaction, transferring its remaining HBAR to a beneficiary account with setTransferAccountId() and the required account signature.

A transaction that deletes an existing account from the Hedera network. Before deleting an account, the existing HBAR must be transferred to another account. Submitting a transaction to delete an account without assigning a beneficiary via `setTransferAccountId()` will result in a `ACCOUNT_ID_DOES_NOT_EXIST` error. 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.

<Info>
  **Note**: The `setTransferAccountId()` method is required, regardless of whether the account has a zero balance.
</Info>

**Transaction Fees**

* Please see the transaction and query [fees](/networks/fees#transaction-and-query-fees) table for the base transaction fee.
* Please use the [Hedera fee estimator](https://hedera.com/fees) to estimate your transaction fee cost.

**Transaction Signing Requirements**

* The account that is being deleted is required to sign the transaction.

### Methods

<table><thead><tr><th>Method</th><th>Type</th><th>Description</th><th>Requirement</th></tr></thead><tbody><tr><td><code>setAccountId(\<accountId>)</code></td><td>AccountId</td><td>The ID of the account to delete.</td><td>Required</td></tr><tr><td><code>setTransferAccountId(\<transferAccountId>)</code></td><td>AccountId</td><td>The ID of the account to transfer the remaining funds to.</td><td>Required</td></tr></tbody></table>

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction to delete an account
  AccountDeleteTransaction 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 network
  TransactionResponse  txResponse = transaction.freezeWith(client).sign(newKey).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);
  ```

  ```javascript JavaScript theme={null}
  //Create the transaction to delete an account
  const transaction = await new AccountDeleteTransaction()
      .setAccountId(accountId)
      .setTransferAccountId(OPERATOR_ID)
      .freezeWith(client);

  //Sign the transaction with the account key
  const signTx = await transaction.sign(accountKey);

  //Sign with the client operator private key and submit to a Hedera network
  const txResponse = await signTx.execute(client);

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

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

  console.log("The transaction consensus status is " +transactionStatus);

  //2.0.5
  ```

  ```java Go theme={null}
  //Create the transaction to delete an account, freeze the transaction for signing
  transaction, 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 network
  txResponse, err := transaction.Sign(accountKey).Execute(client)
  if err != nil {
      panic(err)
  }

  //Request the receipt of the transaction
  receipt, err := txResponse.GetReceipt(client)
  if err != nil {
      panic(err)
  }

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

  fmt.Printf("The transaction consensus status is %v\n", transactionStatus)

  //v2.0.0
  ```

  ```rust Rust theme={null}
  // Create the transaction to delete an account
  let transaction = AccountDeleteTransaction::new()
      .account_id(account_id)
      .transfer_account_id(operator_id);

  // Freeze the transaction for signing, sign with the private key of the account that will be deleted
  let tx_response = transaction
      .freeze_with(&client)?
      .sign(account_key)
      .execute(&client)
      .await?;

  // Request the receipt of the transaction
  let receipt = tx_response.get_receipt(&client).await?;

  // Get the transaction consensus status
  let status = receipt.status;

  println!("The transaction consensus status is {:?}", status);

  // v0.34.0
  ```
</CodeGroup>

## Get transaction values

<table><thead><tr><th>Method</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>getAccountId(\<accountId>)</code></td><td>AccountId</td><td>The account to delete</td></tr><tr><td><code>getTransferAccountId(\<transferAccountId>)</code></td><td>AccountId</td><td>The account to transfer the remaining funds to</td></tr></tbody></table>

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction to delete an account
  AccountDeleteTransaction transaction = new AccountDeleteTransaction()
      .setAccountId(newAccountId)
      .setTransferAccountId(OPERATOR_ID);

  //Get the account ID from the transaction
  AccountId transactionAccountId = transaction.getAccountId()

  System.out.println("The account to be deleted in this transaction is " +transactionAccountId)

  //v2.0.0
  ```

  ```java JavaScript theme={null}
  //Create the transaction to delete an account
  const transaction = new AccountDeleteTransaction()
      .setAccountId(newAccountId)
      .setTransferAccountId(OPERATOR_ID);

  //Get the account ID from the transaction
  const transactionAccountId = transaction.getAccountId()

  console.log("The account to be deleted in this transaction is " +transactionAccountId)
  ```

  ```java JavaScript theme={null}
  //Create the transaction to delete an account
  transaction, err := hedera.NewAccountDeleteTransaction().
          SetAccountID(newAccountID).
          SetTransferAccountID(operatorAccountID)

  //Get the account ID from the transaction
  transactionAccountId := transaction.GetAccountID()

  //v2.0.0
  ```
</CodeGroup>
