Class ContractUpdateTransaction


public final class ContractUpdateTransaction extends Transaction<ContractUpdateTransaction>
Modify a smart contract instance to have the given parameter values.

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.

  • Constructor Details

    • ContractUpdateTransaction

      public ContractUpdateTransaction()
      Contract.
    • ContractUpdateTransaction

      ContractUpdateTransaction(LinkedHashMap<TransactionId,LinkedHashMap<AccountId,Transaction>> txs) throws com.google.protobuf.InvalidProtocolBufferException
      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

      @Nullable public ContractId getContractId()
      Extract the contract id.
      Returns:
      the contract id
    • setContractId

      public ContractUpdateTransaction setContractId(ContractId contractId)
      Sets the Contract ID instance to update.
      Parameters:
      contractId - The ContractId to be set
      Returns:
      this
    • getExpirationTime

      @Nullable public Instant getExpirationTime()
      Extract the contract expiration time.
      Returns:
      the contract expiration time
    • setExpirationTime

      public ContractUpdateTransaction 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. 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

      public ContractUpdateTransaction setExpirationTime(Duration expirationTime)
    • getAdminKey

      @Nullable public Key getAdminKey()
      Extract the administrator key.
      Returns:
      the administrator key
    • setAdminKey

      public ContractUpdateTransaction setAdminKey(Key adminKey)
      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

      @Nullable public AccountId getProxyAccountId()
      Extract the proxy account id.
      Returns:
      the proxy account id
    • setProxyAccountId

      public ContractUpdateTransaction setProxyAccountId(AccountId proxyAccountId)
      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

      @Nullable public Integer 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

      @Nullable public Duration getAutoRenewPeriod()
      Extract the duration for the auto renew period.
      Returns:
      the duration for auto-renew
    • setAutoRenewPeriod

      public ContractUpdateTransaction setAutoRenewPeriod(Duration autoRenewPeriod)
      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

      @Nullable @Deprecated public FileId getBytecodeFileId()
      Deprecated.
      with no replacement
      Returns:
      the bytecodeFileId
    • setBytecodeFileId

      @Deprecated public ContractUpdateTransaction setBytecodeFileId(FileId bytecodeFileId)
      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

      @Nullable public String getContractMemo()
      Extract the contents of the memo.
      Returns:
      the contents of the memo
    • setContractMemo

      public ContractUpdateTransaction setContractMemo(String memo)
      Sets the memo associated with the contract (max: 100 bytes).
      Parameters:
      memo - The memo to be set
      Returns:
      this
    • clearMemo

      public ContractUpdateTransaction clearMemo()
      Remove the memo contents.
      Returns:
      this
    • getStakedAccountId

      @Nullable public AccountId getStakedAccountId()
      ID of the account to which this contract will stake
      Returns:
      ID of the account to which this contract will stake.
    • setStakedAccountId

      public ContractUpdateTransaction setStakedAccountId(@Nullable AccountId stakedAccountId)
      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

      public ContractUpdateTransaction clearStakedAccountId()
      Clear the staked account ID
      Returns:
      this
    • getStakedNodeId

      @Nullable public Long getStakedNodeId()
      The node to which this contract will stake
      Returns:
      ID of the node this contract will be staked to.
    • setStakedNodeId

      public ContractUpdateTransaction setStakedNodeId(@Nullable Long stakedNodeId)
      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

      public ContractUpdateTransaction clearStakedNodeId()
      clear the staked node account ID
      Returns:
      this
    • getDeclineStakingReward

      @Nullable public Boolean 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

      public ContractUpdateTransaction 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.

      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

      public ContractUpdateTransaction clearDeclineStakingReward()
      Clear decline staking reward
      Returns:
      this
    • getAutoRenewAccountId

      @Nullable public AccountId getAutoRenewAccountId()
      Get the auto renew accountId.
      Returns:
      the auto renew accountId
    • setAutoRenewAccountId

      public ContractUpdateTransaction 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.

      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

      public ContractUpdateTransaction clearAutoRenewAccountId()
      Clears the auto-renew account ID
      Returns:
      this
    • addHookToCreate

      public ContractUpdateTransaction addHookToCreate(HookCreationDetails hookDetails)
      Add a hook to be created for the contract.
      Parameters:
      hookDetails - the hook creation details to add
      Returns:
      this
    • setHooksToCreate

      public ContractUpdateTransaction setHooksToCreate(List<HookCreationDetails> hookDetails)
      Set hooks to be created with the contract.
      Parameters:
      hookDetails - list of hook creation details
      Returns:
      this
    • addHookToDelete

      public ContractUpdateTransaction addHookToDelete(Long hookId)
      Mark a hook for deletion from the contract.
      Parameters:
      hookId - the hook id to delete
      Returns:
      this
    • setHooksToDelete

      public ContractUpdateTransaction setHooksToDelete(List<Long> hookIds)
      Mark hooks for deletion from the contract.
      Parameters:
      hookIds - list of hook ids to delete
      Returns:
      this
    • getHooksToCreate

      public List<HookCreationDetails> getHooksToCreate()
      Get the list of hooks to be created.
      Returns:
      a copy of the hook creation details list
    • getHooksToDelete

      public List<Long> 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

      void validateChecksums(Client client) throws BadEntityIdException
      Specified by:
      validateChecksums in class Transaction<ContractUpdateTransaction>
      Throws:
      BadEntityIdException
    • getMethodDescriptor

      io.grpc.MethodDescriptor<Transaction,TransactionResponse> getMethodDescriptor()
      Description copied from class: Executable
      Called to direct the invocation of the query to the appropriate gRPC service.
      Specified by:
      getMethodDescriptor in class Executable<ContractUpdateTransaction,Transaction,TransactionResponse,TransactionResponse>
    • onFreeze

      void onFreeze(TransactionBody.Builder bodyBuilder)
      Description copied from class: Transaction
      Called in Transaction.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:
      onFreeze in class Transaction<ContractUpdateTransaction>
    • onScheduled

      void onScheduled(SchedulableTransactionBody.Builder scheduled)
      Description copied from class: Transaction
      Called in Transaction.schedule() when converting transaction into a scheduled version.
      Specified by:
      onScheduled in class Transaction<ContractUpdateTransaction>