Any null field is ignored (left unchanged).
If only the contractInstanceExpirationTime is being modified, then no signature is needed on this transaction other than for the account paying for the transaction itself.
But if any of the other fields are being modified, then it must be signed by the adminKey.
The use of adminKey is not currently supported in this API, but in the future will be implemented to allow these fields to be modified, and also to make modifications to the state of the instance.
If the contract is created with no admin key, then none of the fields can be changed that need an admin signature, and therefore no admin key can ever be added. So if there is no admin key, then things like the bytecode are immutable. But if there is an admin key, then they can be changed. For example, the admin key might be a threshold key, which requires 3 of 5 binding arbitration judges to agree before the bytecode can be changed. This can be used to add flexibility to the management of smart contract behavior. But this is optional. If the smart contract is created without an admin key, then such a key can never be added, and its bytecode will be immutable.
-
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
ConstructorsConstructorDescriptionContract.Constructor.Contract. -
Method Summary
Modifier and TypeMethodDescriptionaddHookToCreate(HookCreationDetails hookDetails) Add a hook to be created for the contract.addHookToDelete(Long hookId) Mark a hook for deletion from the contract.(package private) ContractUpdateTransactionBody.Builderbuild()Build the correct transaction body.Clears the auto-renew account IDClear decline staking rewardRemove the memo contents.Clear the staked account IDclear the staked node account IDExtract the administrator key.Get the auto renew accountId.Extract the duration for the auto renew period.Deprecated.with no replacementExtract the contract id.Extract the contents of the memo.If true, the contract declines receiving a staking reward.Extract the contract expiration time.Get the list of hooks to be created.Get the list of hook IDs to be deleted.Extract the auto renew period.(package private) io.grpc.MethodDescriptor<Transaction, TransactionResponse> Called to direct the invocation of the query to the appropriate gRPC service.Extract the proxy account id.ID of the account to which this contract will stakeThe node to which this contract will stake(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) voidonScheduled(SchedulableTransactionBody.Builder scheduled) Called inTransaction.schedule()when converting transaction into a scheduled version.setAdminKey(Key adminKey) If set, modify the key that authorizes updates to the contract.setAutoRenewAccountId(AccountId autoRenewAccountId) If set, modify the account, in the same shard and realm as this smart contract, that has agreed to allow the network to use its balance, when needed, to automatically extend this contract's expiration time.setAutoRenewPeriod(Duration autoRenewPeriod) If set, modify the duration added to expiration time by each auto-renewal to this value.setBytecodeFileId(FileId bytecodeFileId) Deprecated.with no replacement Sets the file ID of file containing the smart contract byte code.setContractId(ContractId contractId) Sets the Contract ID instance to update.setContractMemo(String memo) Sets the memo associated with the contract (max: 100 bytes).setDeclineStakingReward(boolean declineStakingReward) A flag indicating if staking rewards are declined.
If set, modify the flag indicating if this contract declines to accept rewards for staking its HBAR to secure the network.setExpirationTime(Duration expirationTime) setExpirationTime(Instant expirationTime) If set, modify the time at which this contract will expire.
An expired contract requires a rent payment to "renew" the contract.setHooksToCreate(List<HookCreationDetails> hookDetails) Set hooks to be created with the contract.setHooksToDelete(List<Long> hookIds) Mark hooks for deletion from the contract.setMaxAutomaticTokenAssociations(int maxAutomaticTokenAssociations) If set, modify the maximum number of tokens that can be auto-associated with the contract.setProxyAccountId(AccountId proxyAccountId) Sets the ID of the account to which this account is proxy staked.setStakedAccountId(AccountId stakedAccountId) An account identifier.
A staked account acts as a proxy, and this contract effectively nominates the same node as the identified account.setStakedNodeId(Long stakedNodeId) A node identifier.
A staked node identifier indicates the consensus node that this account nominates for staking.(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
-
ContractUpdateTransaction
public ContractUpdateTransaction()Contract. -
ContractUpdateTransaction
ContractUpdateTransaction(LinkedHashMap<TransactionId, LinkedHashMap<AccountId, throws com.google.protobuf.InvalidProtocolBufferExceptionTransaction>> txs) Contract.- Parameters:
txs- Compound list of transaction id's list of (AccountId, Transaction) record- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
ContractUpdateTransaction
ContractUpdateTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
-
Method Details
-
getContractId
Extract the contract id.- Returns:
- the contract id
-
setContractId
Sets the Contract ID instance to update.- Parameters:
contractId- The ContractId to be set- Returns:
this
-
getExpirationTime
Extract the contract expiration time.- Returns:
- the contract expiration time
-
setExpirationTime
If set, modify the time at which this contract will expire.
An expired contract requires a rent payment to "renew" the contract. A transaction to update this field is how that rent payment is made.This value MUST NOT be less than the current `expirationTime` of the contract. If this value is earlier than the current value, the transaction SHALL fail with response code `EXPIRATION_REDUCTION_NOT_ALLOWED`.
- Parameters:
expirationTime- The Instant to be set for expiration time- Returns:
this
-
setExpirationTime
-
getAdminKey
Extract the administrator key.- Returns:
- the administrator key
-
setAdminKey
If set, modify the key that authorizes updates to the contract.If this field is set to a valid Key, this key and the previously set key MUST both sign this transaction.
If this value is an empty `KeyList`, the prior key MUST sign this transaction, and the smart contract SHALL be immutable after this transaction completes, except for expiration and renewal.
If this value is not an empty `KeyList`, but does not contain any cryptographic keys, or is otherwise malformed, this transaction SHALL fail with response code `INVALID_ADMIN_KEY`.- Parameters:
adminKey- The Key to be set- Returns:
this
-
getProxyAccountId
Extract the proxy account id.- Returns:
- the proxy account id
-
setProxyAccountId
Sets the ID of the account to which this account is proxy staked.If proxyAccountID is null, or is an invalid account, or is an account that isn't a node, then this account is automatically proxy staked to a node chosen by the network, but without earning payments.
If the proxyAccountID account refuses to accept proxy staking, or if it is not currently running a node, then it will behave as if proxyAccountID was null.
- Parameters:
proxyAccountId- The AccountId to be set- Returns:
this
-
getMaxAutomaticTokenAssociations
Extract the auto renew period.- Returns:
- the auto renew period
-
setMaxAutomaticTokenAssociations
public ContractUpdateTransaction setMaxAutomaticTokenAssociations(int maxAutomaticTokenAssociations) If set, modify the maximum number of tokens that can be auto-associated with the contract.If this is set and less than or equal to `used_auto_associations`, or 0, then this contract MUST manually associate with a token before transacting in that token.
This value MAY also be `-1` to indicate no limit.
This value MUST NOT be less than `-1`.- Parameters:
maxAutomaticTokenAssociations- The maximum automatic token associations- Returns:
this
-
getAutoRenewPeriod
Extract the duration for the auto renew period.- Returns:
- the duration for auto-renew
-
setAutoRenewPeriod
If set, modify the duration added to expiration time by each auto-renewal to this value.- Parameters:
autoRenewPeriod- The Duration to be set for auto-renewal- Returns:
this
-
getBytecodeFileId
Deprecated.with no replacement- Returns:
- the bytecodeFileId
-
setBytecodeFileId
Deprecated.with no replacement Sets the file ID of file containing the smart contract byte code.A copy will be made and held by the contract instance, and have the same expiration time as the instance.
- Parameters:
bytecodeFileId- The FileId to be set- Returns:
this
-
getContractMemo
Extract the contents of the memo.- Returns:
- the contents of the memo
-
setContractMemo
Sets the memo associated with the contract (max: 100 bytes).- Parameters:
memo- The memo to be set- Returns:
this
-
clearMemo
Remove the memo contents.- Returns:
this
-
getStakedAccountId
ID of the account to which this contract will stake- Returns:
- ID of the account to which this contract will stake.
-
setStakedAccountId
An account identifier.
A staked account acts as a proxy, and this contract effectively nominates the same node as the identified account.If set, modify this smart contract such that it SHALL stake its HBAR to the same node as the identified account.
If this field is set to a default AccountID value (`0.0.0`), any pre-existing `staked_account_id` value SHALL be removed on success.- Parameters:
stakedAccountId- ID of the account to which this contract will stake.- Returns:
this
-
clearStakedAccountId
Clear the staked account ID- Returns:
this
-
getStakedNodeId
The node to which this contract will stake- Returns:
- ID of the node this contract will be staked to.
-
setStakedNodeId
A node identifier.
A staked node identifier indicates the consensus node that this account nominates for staking.If set, modify this smart contract such that it SHALL stake its HBAR to this node. If set to the value `-1` any pre-existing `staked_node_id` value SHALL be removed on success.
Note: node IDs do fluctuate as node operators change. Most contracts are immutable, and a contract staking to an invalid node ID SHALL NOT participate in staking. Immutable contracts may find it more reliable to use a proxy account for staking (via `staked_account_id`) to enable updating the _effective_ staking node ID when necessary through updating the proxy account.
- Parameters:
stakedNodeId- ID of the node this contract will be staked to.- Returns:
this
-
clearStakedNodeId
clear the staked node account ID- Returns:
this
-
getDeclineStakingReward
If true, the contract declines receiving a staking reward. The default value is false.- Returns:
- If true, the contract declines receiving a staking reward. The default value is false.
-
setDeclineStakingReward
A flag indicating if staking rewards are declined.
If set, modify the flag indicating if this contract declines to accept rewards for staking its HBAR to secure the network.If set to true, this smart contract SHALL NOT receive any reward for staking its HBAR balance to help secure the network, regardless of staking configuration, but MAY stake HBAR to support the network without reward.
- Parameters:
declineStakingReward- - If true, the contract declines receiving a staking reward. The default value is false.- Returns:
this
-
clearDeclineStakingReward
Clear decline staking reward- Returns:
this
-
getAutoRenewAccountId
Get the auto renew accountId.- Returns:
- the auto renew accountId
-
setAutoRenewAccountId
If set, modify the account, in the same shard and realm as this smart contract, that has agreed to allow the network to use its balance, when needed, to automatically extend this contract's expiration time.If this field is set to a non-default value, that Account MUST sign this transaction.
If this field is set to a default AccountID value (`0.0.0`), any pre-existing `auto_renew_account_id` value SHALL be removed on success.- Parameters:
autoRenewAccountId- The AccountId to be set for auto-renewal- Returns:
this
-
clearAutoRenewAccountId
Clears the auto-renew account ID- Returns:
this
-
addHookToCreate
Add a hook to be created for the contract.- Parameters:
hookDetails- the hook creation details to add- Returns:
this
-
setHooksToCreate
Set hooks to be created with the contract.- Parameters:
hookDetails- list of hook creation details- Returns:
this
-
addHookToDelete
Mark a hook for deletion from the contract.- Parameters:
hookId- the hook id to delete- Returns:
this
-
setHooksToDelete
Mark hooks for deletion from the contract.- Parameters:
hookIds- list of hook ids to delete- Returns:
this
-
getHooksToCreate
Get the list of hooks to be created.- Returns:
- a copy of the hook creation details list
-
getHooksToDelete
Get the list of hook IDs to be deleted.- Returns:
- a copy of the hook IDs list
-
initFromTransactionBody
void initFromTransactionBody()Initialize from the transaction body. -
build
Build the correct transaction body.- Returns:
builder
-
validateChecksums
- Specified by:
validateChecksumsin classTransaction<ContractUpdateTransaction>- 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<ContractUpdateTransaction,Transaction, TransactionResponse, TransactionResponse>
-
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<ContractUpdateTransaction>
-
onScheduled
Description copied from class:TransactionCalled inTransaction.schedule()when converting transaction into a scheduled version.- Specified by:
onScheduledin classTransaction<ContractUpdateTransaction>
-