When the current consensus time exceeds the `expirationTime` value, the network SHALL expire the file, and MAY archive the state entry. #### Signature Requirements The HFS manages file authorization in a manner that can be confusing. The core element of file authorization is the `keys` field, which is a `KeyList`; a list of individual `Key` messages, each of which may represent a simple or complex key.
The file service transactions treat this list differently.
A `fileCreate`, `fileAppend`, or `fileUpdate` MUST have a valid signature from _each_ key in the list.
A `fileDelete` MUST have a valid signature from _at least one_ key in the list. This is different, and allows a file "owned" by many entities to be deleted by any one of those entities. A deleted file cannot be restored, so it is important to consider this when assigning keys for a file.
If any of the keys in a `KeyList` are complex, the full requirements of each complex key must be met to count as a "valid signature" for that key. A complex key structure (i.e. a `ThresholdKey`, or `KeyList`, possibly including additional `ThresholdKey` or `KeyList` descendants) may be assigned as the sole entry in a file `keys` field to ensure all transactions have the same signature requirements. If the `keys` field is an empty `KeyList`, then the file SHALL be immutable and the only transaction permitted to modify that file SHALL be a `fileUpdate` transaction with _only_ the `expirationTime` set. #### Shard and Realm The current API ignores shardID and realmID. All files are created in shard 0 and realm 0. Future versions of the API may support multiple realms and multiple shards. ### Block Stream Effects After the file is created, the FileID for it SHALL be returned in the transaction receipt, and SHALL be recorded in the transaction record.
-
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
Fields 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.FileCreateTransaction(TransactionBody txBody) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) FileCreateTransactionBody.Builderbuild()Build the transaction body.com.google.protobuf.ByteStringCreate the byte string.Extract the time.Extract the file's memo field.getKeys()Extract the of keys.(package private) io.grpc.MethodDescriptor<Transaction, TransactionResponse> Called to direct the invocation of the query to the appropriate gRPC service.(package private) voidInitialize from transaction body.(package private) voidonFreeze(TransactionBody.Builder bodyBuilder) Called inTransaction.freezeWith(Client)just before the transaction body is built.(package private) voidonScheduled(SchedulableTransactionBody.Builder scheduled) Called inTransaction.schedule()when converting transaction into a scheduled version.setContents(byte[] bytes) Set the given byte array as the file's contents.setContents(String text) Encode the givenStringas UTF-8 and set it as the file's contents.setExpirationTime(Duration expirationTime) setExpirationTime(Instant expirationTime) Set the instant at which this file will expire, after which its contents will no longer be available.setFileMemo(String memo) Assign a memo to the file (100 bytes max).Set the keys which must sign any transactions modifying this file.(package private) voidvalidateChecksums(Client client) Methods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, addSignature, batchify, buildAllTransactions, buildTransaction, doSchedule, estimateFee, freeze, freezeWith, fromBytes, fromScheduledTransaction, generateTransactionIds, getBatchKey, getDefaultMaxTransactionFee, getExecutionState, getHighVolume, getMaxTransactionFee, getRegenerateTransactionId, getRequiredChunks, getSignableNodeBodyBytesList, getSignatures, getSignaturesAtOffset, getTransactionBodySize, getTransactionHash, getTransactionHashPerNode, getTransactionId, getTransactionIdInternal, getTransactionMemo, getTransactionSize, getTransactionValidDuration, hash, isBatchedAndNotBatchTransaction, isFrozen, keyAlreadySigned, makeRequest, mapResponse, mapResponseStatus, onExecute, onExecuteAsync, regenerateTransactionId, requireNotFrozen, requireOneNodeAccountId, schedule, setBatchKey, setHighVolume, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signTransaction, signWith, signWithOperator, spawnBodyBuilder, toBytes, toString, wipeTransactionListsMethods inherited from class com.hedera.hashgraph.sdk.Executable
advanceRequest, checkNodeAccountIds, execute, execute, executeAsync, 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
-
Constructor Details
-
FileCreateTransaction
public FileCreateTransaction()Constructor. -
FileCreateTransaction
FileCreateTransaction(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
-
FileCreateTransaction
FileCreateTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
-
Method Details
-
getExpirationTime
Extract the time.- Returns:
- expiration time
-
setExpirationTime
Set the instant at which this file will expire, after which its contents will no longer be available.
Defaults to 1/4 of a Julian year from the instant
FileCreateTransaction()was invoked.May be extended using
FileUpdateTransaction.setExpirationTime(Instant).- Parameters:
expirationTime- theInstantat which this file should expire.- Returns:
this
-
setExpirationTime
-
getKeys
Extract the of keys.- Returns:
- list of keys
-
setKeys
Set the keys which must sign any transactions modifying this file. Required.
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). Only one key must sign to delete the file, however.
To require more than one key to sign to delete a file, add them to a
KeyListand pass that here.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.
- Parameters:
keys- The Key or Keys to be set- Returns:
this
-
getContents
public com.google.protobuf.ByteString getContents()Create the byte string.- Returns:
- byte string representation
-
setContents
Set the given byte array as the file's contents.
This may be omitted to create an empty file.
Note that total size for a given transaction is limited to 6KiB (as of March 2020) by the network; if you exceed this you may receive a
PrecheckStatusExceptionwithStatus.TRANSACTION_OVERSIZE.In this case, you can use
FileAppendTransaction, which automatically breaks the contents into chunks for you, to append contents of arbitrary size.- Parameters:
bytes- the contents of the file.- Returns:
this
-
setContents
Encode the given
Stringas UTF-8 and set it as the file's contents.This may be omitted to create an empty file.
The string can later be recovered from
Executable.execute(Client)viaString(byte[], java.nio.charset.Charset)usingStandardCharsets.UTF_8.Note that total size for a given transaction is limited to 6KiB (as of March 2020) by the network; if you exceed this you may receive a
PrecheckStatusExceptionwithStatus.TRANSACTION_OVERSIZE.In this case, you can use
FileAppendTransaction, which automatically breaks the contents into chunks for you, to append contents of arbitrary size.- Parameters:
text- the contents of the file.- Returns:
this
-
getFileMemo
Extract the file's memo field.- Returns:
- the file's memo field
-
setFileMemo
Assign a memo to the file (100 bytes max).- Parameters:
memo- memo string- Returns:
this
-
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<FileCreateTransaction,Transaction, TransactionResponse, TransactionResponse>
-
validateChecksums
- Specified by:
validateChecksumsin classTransaction<FileCreateTransaction>
-
initFromTransactionBody
void initFromTransactionBody()Initialize from transaction body. -
build
Build the transaction body.- Returns:
builder
-
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<FileCreateTransaction>
-
onScheduled
Description copied from class:TransactionCalled inTransaction.schedule()when converting transaction into a scheduled version.- Specified by:
onScheduledin classTransaction<FileCreateTransaction>
-