Append to a file

A transaction that appends new file content to the end of an existing file. The contents of the file can be viewed by submitting a FileContentsQuery request.

Transaction Signing Requirements

  • The key on the file is required to sign the transaction if different than the client operator account key

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

new FileAppendTransaction()

The default max transaction fee (1 hbar) is not enough to create a file. Use setMaxTransactionFee()to change the default max transaction fee from 1 hbar to 2 hbars. The default chunk size is 2,048 bytes.

Methods

//Create the transaction
FileAppendTransaction transaction = new FileAppendTransaction()
    .setFileId(newFileId)
    .setContents("The appended contents");

//Change the default max transaction fee to 2 hbars
FileCreateTransaction 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

Get transaction values

//Create the transaction
FileAppendTransaction transaction = new FileAppendTransaction()
    .setFileId(newFileId)
    .setContents("The appended contents");

//Get the contents
ByteString getContents = transaction.getContents();

//v2.0.0

Last updated