> ## 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 a file

> Delete a file from the Hedera network with FileDeleteTransaction, which truncates its contents to zero length and blocks further updates, appends, and expiration extensions.

A transaction that deletes a file from a Hedera network. When deleted, a file's contents are truncated to zero length and it can no longer be updated or appended to, or its expiration time extended. When you request the contents or info of a deleted file, the network will return FILE\_DELETED.

**Transaction Signing Requirements**

* The key(s) on the file are required to sign the transaction
* If you do not sign with the key(s) on the file, you will receive an INVALID\_SIGNATURE network error

**Transaction Fees**

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

| Constructor | Description |
| - | - |
| `new FileDeleteTransaction()` | Initializes the FileDeleteTransaction object |

```java theme={null}
new FileDeleteTransaction()
```

### Methods

| Method | Type | Description |
| - | - | - |
| `setFileId(<fileId>)` | FileId | The ID of the file to delete in x.y.z format |

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction
  FileDeleteTransaction transaction = new FileDeleteTransaction()
      .setFileId(newFileId);

  //Modify the default max transaction fee to from 1 to 2 hbars
  FileDeleteTransaction modifyMaxTransactionFee = transaction.setMaxTransactionFee(new Hbar(2));

  //Prepare transaction for signing, sign with the key on the file, sign with the client operator key and submit to a Hedera network
  TransactionResponse txResponse = modifyMaxTransactionFee.freezeWith(client).sign(key).execute(client);

  //Request the receipt
  TransactionReceipt receipt = txResponse.getReceipt(client);

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

  System.out.println("The transaction consensus status is " + transactionStatus);

  //v2.0.0
  ```

  ```javascript JavaScript theme={null}
  //Create the transaction
  const transaction = await new FileDeleteTransaction()
      .setFileId(fileId)
      .setMaxTransactionFee(new Hbar(2))
      .freezeWith(client);

  //Sign with the file private key
  const signTx = await transaction.sign(fileKey);

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

  //Request the receipt
  const receipt = await submitTx.getReceipt(client);

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

  console.log("The transaction consensus status " +transactionStatus3.toString());

  //v2.0.5
  ```

  ```java Go theme={null}
  //Create the transaction
  transaction := hedera.NewFileDeleteTransaction().
  	  SetFileID(fileId)

  //Modify the default max transaction fee to from 1 to 2 hbars
  modifyMaxTransactionFee := transaction.SetMaxTransactionFee(hedera.HbarFrom(2, hedera.HbarUnits.Hbar))

  //Prepare the transaction for signing
  freezeTransaction, err := modifyMaxTransactionFee.FreezeWith(client)
  if err != nil {
  		panic(err)
  }

  //Sign with the key on the file, sign with the client operator key and submit to a Hedera network
  txResponse, err := freezeTransaction.Sign(fileKey).Execute(client)
  if err != nil {
  		panic(err)
  }

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

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

  fmt.Println("The transaction consensus status is ", transactionStatus)

  //v2.0.0
  ```

  ```rust Rust theme={null}
  // Create the transaction
  let transaction = FileDeleteTransaction::new()
      .file_id(file_id)
      .max_transaction_fee(Hbar::new(2));

  // Sign with the file key and submit to a Hedera network
  let tx_response = transaction
      .freeze_with(&client)?
      .sign(file_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

| Method | Type | Description |
| - | - | - |
| `getFileId(<fileId>)` | FileId | The ID of the file to delete (x.z.y) |

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction
  FileDeleteTransaction transaction = new FileDeleteTransaction()
      .setFileId(newFileId);

  //Get the file ID
  FileId getFileId = transaction.getFileId();
  ```

  ```javascript JavaScript theme={null}
  //Create the transaction
  const transaction = new FileDeleteTransaction()
      .setFileId(newFileId);
      
  //Get the file ID
  FileId getFileId = transaction.getFileId();
  ```

  ```java Go theme={null}
  //Create the transaction
  transaction := hedera.NewFileDeleteTransaction().
  	  SetFileID(fileId)
  	
  //Get the file ID
  getFileId := transaction.GetFileID()
  ```

  ```rust Rust theme={null}
  // Create the transaction
  let transaction = FileDeleteTransaction::new()
      .file_id(file_id);

  // Get the file ID
  let file_id = transaction.get_file_id();

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