java.lang.Object
com.hedera.hashgraph.sdk.Executable<FileAppendTransaction,Transaction,TransactionResponse,TransactionResponse>
com.hedera.hashgraph.sdk.Transaction<FileAppendTransaction>
com.hedera.hashgraph.sdk.ChunkedTransaction<FileAppendTransaction>
com.hedera.hashgraph.sdk.FileAppendTransaction
A transaction body for an `appendContent` transaction.
This transaction body provides a mechanism to append content to a "file" in network state. Hedera transactions are limited in size, but there are many uses for in-state byte arrays (e.g. smart contract bytecode) which require more than may fit within a single transaction. The `appendFile` transaction exists to support these requirements. The typical pattern is to create a file, append more data until the full content is stored, verify the file is correct, then update the file entry with any final metadata changes (e.g. adding threshold keys and removing the initial upload key). Each append transaction MUST remain within the total transaction size limit for the network (typically 6144 bytes).
The total size of a file MUST remain within the maximum file size limit for the network (typically 1048576 bytes). #### Signature Requirements Append transactions MUST have signatures from _all_ keys in the `KeyList` assigned to the `keys` field of the file.
See the [File Service](#FileService) specification for a detailed explanation of the signature requirements for all file transactions. ### Block Stream Effects None
This transaction body provides a mechanism to append content to a "file" in network state. Hedera transactions are limited in size, but there are many uses for in-state byte arrays (e.g. smart contract bytecode) which require more than may fit within a single transaction. The `appendFile` transaction exists to support these requirements. The typical pattern is to create a file, append more data until the full content is stored, verify the file is correct, then update the file entry with any final metadata changes (e.g. adding threshold keys and removing the initial upload key). Each append transaction MUST remain within the total transaction size limit for the network (typically 6144 bytes).
The total size of a file MUST remain within the maximum file size limit for the network (typically 1048576 bytes). #### Signature Requirements Append transactions MUST have signatures from _all_ keys in the `KeyList` assigned to the `keys` field of the file.
See the [File Service](#FileService) specification for a detailed explanation of the signature requirements for all file transactions. ### Block Stream Effects None
-
Nested Class Summary
Nested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Transaction
Transaction.SignableNodeTransactionBodyBytesNested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Executable
Executable.GrpcRequest -
Field Summary
FieldsFields inherited from class com.hedera.hashgraph.sdk.ChunkedTransaction
dataFields inherited from class com.hedera.hashgraph.sdk.Transaction
customFeeLimits, DEFAULT_AUTO_RENEW_PERIOD, defaultMaxTransactionFee, DUMMY_ACCOUNT_ID, DUMMY_TRANSACTION_ID, frozenBodyBuilder, innerSignedTransactions, outerTransactions, publicKeys, regenerateTransactionId, signers, sigPairLists, sourceTransactionBody, transactionIdsFields inherited from class com.hedera.hashgraph.sdk.Executable
attemptedAllNodes, blockingUnaryCall, grpcDeadline, logger, maxAttempts, maxBackoff, minBackoff, nodeAccountIds, nodes, random, RST_STREAM -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.FileAppendTransaction(TransactionBody txBody) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) FileAppendTransactionBody.Builderbuild()Build the transaction body.com.google.protobuf.ByteStringExtract the byte string representing the file.Extract the file id.(package private) io.grpc.MethodDescriptor<Transaction, TransactionResponse> Called to direct the invocation of the query to the appropriate gRPC service.(package private) voidInitialize from the transaction body.(package private) voidonFreeze(TransactionBody.Builder bodyBuilder) Called inTransaction.freezeWith(Client)just before the transaction body is built.(package private) voidonFreezeChunk(TransactionBody.Builder body, TransactionID initialTransactionId, int startIndex, int endIndex, int chunk, int total) A common base for file and topic message transactions.(package private) voidonScheduled(SchedulableTransactionBody.Builder scheduled) Called inTransaction.schedule()when converting transaction into a scheduled version.setContents(byte[] contents) An array of bytes to append.setContents(com.google.protobuf.ByteString contents) Set the contents to append to the file as identified bysetFileId(FileId).setContents(String text) Encode the givenStringas UTF-8 and append it to file as identified bysetFileId(FileId).A file identifier.
This identifies the file to which the `contents` will be appended.(package private) booleanShould the receipt be retrieved?(package private) voidvalidateChecksums(Client client) Methods inherited from class com.hedera.hashgraph.sdk.ChunkedTransaction
addSignature, bodySizeAllChunks, execute, executeAll, executeAll, executeAllAsync, executeAllAsync, executeAllAsync, executeAllAsync, executeAllAsync, executeAllAsync, executeAsync, getAllSignatures, getAllTransactionHashesPerNode, getChunkSize, getData, getMaxChunks, getRequiredChunks, getSignatures, getTransactionHash, getTransactionHashPerNode, schedule, setChunkSize, setData, setData, setData, setMaxChunks, wipeTransactionListsMethods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, batchify, buildAllTransactions, buildTransaction, doSchedule, estimateFee, freeze, freezeWith, fromBytes, fromScheduledTransaction, generateTransactionIds, getBatchKey, getDefaultMaxTransactionFee, getExecutionState, getHighVolume, getMaxTransactionFee, getRegenerateTransactionId, getSignableNodeBodyBytesList, getSignaturesAtOffset, getTransactionBodySize, getTransactionId, getTransactionIdInternal, getTransactionMemo, getTransactionSize, getTransactionValidDuration, hash, isBatchedAndNotBatchTransaction, isFrozen, keyAlreadySigned, makeRequest, mapResponse, mapResponseStatus, onExecute, onExecuteAsync, regenerateTransactionId, requireNotFrozen, requireOneNodeAccountId, setBatchKey, setHighVolume, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signTransaction, signWith, signWithOperator, spawnBodyBuilder, toBytes, toStringMethods inherited from class com.hedera.hashgraph.sdk.Executable
advanceRequest, checkNodeAccountIds, execute, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, getGrpcRequest, getMaxAttempts, getMaxBackoff, getMaxRetry, getMinBackoff, getNodeAccountIds, getNodeForExecute, grpcDeadline, logTransaction, mergeFromClient, setGrpcDeadline, setLogger, setMaxAttempts, setMaxBackoff, setMaxRetry, setMinBackoff, setNodesFromNodeAccountIds, setRequestListener, setResponseListener, shouldRetryExceptionally
-
Field Details
-
DEFAULT_CHUNK_SIZE
static int DEFAULT_CHUNK_SIZE
-
-
Constructor Details
-
FileAppendTransaction
public FileAppendTransaction()Constructor. -
FileAppendTransaction
FileAppendTransaction(LinkedHashMap<TransactionId, LinkedHashMap<AccountId, throws com.google.protobuf.InvalidProtocolBufferExceptionTransaction>> txs) Constructor.- Parameters:
txs- Compound list of transaction id's list of (AccountId, Transaction) records- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
FileAppendTransaction
FileAppendTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
-
Method Details
-
getFileId
Extract the file id.- Returns:
- the file id
-
setFileId
A file identifier.
This identifies the file to which the `contents` will be appended.This field is REQUIRED.
The identified file MUST exist.
The identified file MUST NOT be larger than the current maximum file size limit.
The identified file MUST NOT be deleted.
The identified file MUST NOT be immutable.- Parameters:
fileId- the ID of the file to append to.- Returns:
this
-
getContents
@Nullable public com.google.protobuf.ByteString getContents()Extract the byte string representing the file.- Returns:
- the byte string representing the file
-
setContents
An array of bytes to append.
This content SHALL be appended to the identified file if this transaction succeeds.
This field is REQUIRED.
This field MUST NOT be empty.- Parameters:
contents- the contents to append to the file.- Returns:
this- See Also:
-
setContents
Set the contents to append to the file as identified by
setFileId(FileId).- Parameters:
contents- the contents to append to the file.- Returns:
this- See Also:
-
setContents
Encode the given
Stringas UTF-8 and append it to file as identified bysetFileId(FileId).If the whole file is UTF-8 encoded, the string can later be recovered from
Executable.execute(Client)viaString(byte[], java.nio.charset.Charset)usingStandardCharsets.UTF_8.- Parameters:
text- The String to be set as the contents of the file- Returns:
this- See Also:
-
validateChecksums
- Specified by:
validateChecksumsin classTransaction<FileAppendTransaction>- Throws:
BadEntityIdException
-
getMethodDescriptor
io.grpc.MethodDescriptor<Transaction,TransactionResponse> getMethodDescriptor()Description copied from class:ExecutableCalled to direct the invocation of the query to the appropriate gRPC service.- Specified by:
getMethodDescriptorin classExecutable<FileAppendTransaction,Transaction, TransactionResponse, TransactionResponse>
-
initFromTransactionBody
void initFromTransactionBody()Initialize from the transaction body. -
build
Build the transaction body.- Returns:
builder
-
onFreezeChunk
void onFreezeChunk(TransactionBody.Builder body, @Nullable TransactionID initialTransactionId, int startIndex, int endIndex, int chunk, int total) Description copied from class:ChunkedTransactionA common base for file and topic message transactions.- Specified by:
onFreezeChunkin classChunkedTransaction<FileAppendTransaction>
-
shouldGetReceipt
boolean shouldGetReceipt()Description copied from class:ChunkedTransactionShould the receipt be retrieved?- Overrides:
shouldGetReceiptin classChunkedTransaction<FileAppendTransaction>- Returns:
- by default do not get a receipt
-
onFreeze
Description copied from class:TransactionCalled inTransaction.freezeWith(Client)just before the transaction body is built. The intent is for the derived class to assign their data variant to the transaction body.- Specified by:
onFreezein classTransaction<FileAppendTransaction>
-
onScheduled
Description copied from class:TransactionCalled inTransaction.schedule()when converting transaction into a scheduled version.- Specified by:
onScheduledin classTransaction<FileAppendTransaction>
-