Skip to main content
A transaction that updates the state of an existing file on a Hedera network. Once the transaction has been processed, the network will be updated with the new field values of the file. If you need to access a previous state of the file, you can query a mirror node. Transaction Signing Requirements
  • The key or keys on the file are required to sign this transaction to modify the file properties
  • If you are updating the keys on the file, you must sign with the old key and the new key
  • 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 table for base transaction fee
  • Please use the Hedera fee estimator to estimate your transaction fee cost

File Properties

FieldDescription
Key(s)Update the keys which must sign any transactions modifying this file. All keys must sign to modify the file’s contents or keys. No key is required to sign for extending the expiration time (except the one for the operator account paying for the transaction). The network currently requires a file to have at least one key (or key list or threshold key) but this requirement may be lifted in the future.
ContentsThe content to update the files with.
Expiration TimeIf set, update the expiration time of the file. Must be in the future (may only be used to extend the expiration). To make a file inaccessible use FileDeleteTransaction.
MemoShort publicly visible memo about the file. No guarantee of uniqueness. (100 characters max)
ConstructorDescription
new FileUpdateTransaction()Initializes the FileUpdateTransaction object
new FileUpdateTransaction()

Methods

Note: The total size for a given transaction is limited to 6KiB. If you exceed this value you will need to submit a FileUpdateTransaction that is less than 6KiB and then submit a FileAppendTransaction to add the remaining content to the file.
MethodTypeRequirement
setFileId(<fileId>)FileIdRequired
setKey(<keys>)KeyOptional
setContents(<bytes>)byte [ ]Optional
setContents(<text>)StringOptional
setExpirationTime(<expiration>)InstantOptional
setFileMemo(<memo>)StringOptional
//Create the transaction
FileUpdateTransaction transaction = new FileUpdateTransaction()
    .setFileId(fileId)
    .setKeys(newKey);

//Modify the max transaction fee
FileUpdateTransaction txFee = transaction.setMaxTransactionFee(new Hbar(3));

//Freeze the transaction, sign with the original key, sign with the new key, sign with the client operator key and submit the transaction to a Hedera network
TransactionResponse txResponse = txFee.freezeWith(client).sign(fileKey).sign(newKey).execute(client);

//Get 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);

//v2.0.0

Get transaction values

MethodTypeRequirement
getFileId()FileIdOptional
getKey()KeyOptional
setContents()ByteStringOptional
getExpirationTime()InstantOptional
getFileMemo()StringOptional
//Create the transaction
FileUpdateTransaction transaction = new FileUpdateTransaction()
    .setFileId(fileId)
    .setKeys(newKey);

//Get the contents of a file
Key getKey = transaction.getKey();

//v2.0.0