> ## Documentation Index
> Fetch the complete documentation index at: https://hedera-0c6e0218-add-json-rpc-release-notes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update an account

A transaction that updates the properties of an existing account. The network will store the latest updates on the account. If you would like to retrieve the state of an account in the past, you can query a mirror node.

**Account Properties**

<Card title="Account Properties" href="/hedera/core-concepts/accounts/account-properties" />

**Transaction Fees**

* The sender pays for the token association fee and the rent for the first auto-renewal period.
* Please see the transaction and query [fees](/hedera/networks/mainnet/fees#transaction-and-query-fees) table for the base transaction fee.
* Please use the [Hedera fee estimator](https://hedera.com/fees) to estimate the cost of your transaction fee.

**Transaction Signing Requirements**

* The account key(s) are required to sign the transaction.
* If you are updating the keys on the account, the OLD KEY and NEW KEY must sign.
  * If either is a key list, the key list keys are all required to sign.
  * If either is a threshold key, the threshold value is required to sign.
* If you do not have the required signatures, the network will throw an `INVALID_SIGNATURE` error.

<Info>
  **Account Hooks ([HIP-1195](https://hips.hedera.com/hip/hip-1195))**

  You can add or remove [Hiero Hooks](/hedera/core-concepts/accounts/hiero-hooks) on an existing account using `addHookToCreate()` and `addHookToDelete()`. Deletions are processed before creations, enabling atomic hook replacement within a single transaction. A hook can only be deleted when it has zero storage slots. See [Create and Manage Hooks](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks) for full details.
</Info>

#### Maximum Auto-Associations and Fees

Accounts have a property, `maxAutoAssociations`, and the property's value determines the maximum number of automatic token associations allowed.

| Property Value | Description                                                                                                                                                                                                                                                                                                                                                                                                                      |
| :------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|       `0`      | Automatic token associations or token airdrops are not allowed, and the account must be manually associated with a token. This also applies if the value is less than or equal to `usedAutoAssociations`.                                                                                                                                                                                                                        |
|      `-1`      | Unlimited automatic token associations are allowed, and this is the default for accounts created via [auto account creation](../../../core-concepts/accounts/auto-account-creation) and for accounts that began as hollow accounts and are now complete. Accounts with `-1` can receive new tokens without manually associating them. The sender still pays the `maxAutoAssociations` fee and initial rent for each association. |
|      `> 0`     | If the value is a positive number (number greater than 0), the number of automatic token associations an account can have is limited to that number.                                                                                                                                                                                                                                                                             |

<Info>
  The sender pays the `maxAutoAssociations` fee and the rent for the first auto-renewal period for the association. This is in addition to the typical transfer fees. This ensures the receiver can receive tokens without association and makes it a smoother transfer process.
</Info>

Reference: [HIP-904](https://hips.hedera.com/hip/hip-904)

### Methods

| Method                                            | Type                                                                                               | Requirement |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ----------- |
| `setAccountId(<accountId>)`                       | AccountId                                                                                          | Required    |
| `setKey(<key>)`                                   | Key                                                                                                | Optional    |
| `setReceiverSignatureRequired(<boolean>)`         | Boolean                                                                                            | Optional    |
| `setMaxAutomaticTokenAssociations(<amount>)`      | int                                                                                                | Optional    |
| `setAccountMemo(<memo>)`                          | String                                                                                             | Optional    |
| `setAutoRenewPeriod(<duration>)`                  | Duration                                                                                           | Optional    |
| `setStakedAccountId(<stakedAccountId>)`           | AccountId                                                                                          | Optional    |
| `setStakedNodeId(<stakedNodeId>)`                 | long                                                                                               | Optional    |
| `setDeclineStakingReward(<declineStakingReward>)` | boolean                                                                                            | Optional    |
| `setExpirationTime(<expirationTime>)`             | Instant                                                                                            | Disabled    |
| `addHookToCreate(<hook>)`                         | [HookCreationDetails](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks)        | Optional    |
| `setHooksToCreate(<hooks>)`                       | list\<[HookCreationDetails](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks)> | Optional    |
| `addHookToDelete(<hookId>)`                       | long                                                                                               | Optional    |
| `setHooksToDelete(<hookIds>)`                     | list\<long>                                                                                        | Optional    |

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction to update the key on the account
  AccountUpdateTransaction transaction = new AccountUpdateTransaction()
      .setAccountId(accountId)
      .setKey(updateKey);

  //Sign the transaction with the old key and new key, submit to a Hedera network   
  TransactionResponse txResponse = transaction.freezeWith(client).sign(oldKey).sign(newKey).execute(client);

  //Request the receipt of the transaction
  TransactionReceipt receipt = txResponse.getReceipt(client);

  //Get the transaction consensus status
  Status transactionStatus = receipt.status;

  System.out.println("The transaction consensus status is " +transactionStatus);

  //Version 2.0.0
  ```

  ```javascript JavaScript theme={null}
  //Create the transaction to update the key on the account
  const transaction = await new AccountUpdateTransaction()
      .setAccountId(accountId)
      .setKey(updateKey)
      .freezeWith(client);

  //Sign the transaction with the old key and new key
  const signTx = await (await transaction.sign(oldKey)).sign(newKey);

  //SIgn the transaction with the client operator private key and submit to a Hedera network
  const txResponse = await signTx.execute(client);

  //Request the receipt of the transaction
  const receipt = await txResponse.getReceipt(client);

  //Get the transaction consensus status
  const transactionStatus = receipt.status;

  console.log("The transaction consensus status is " +transactionStatus.toString());

  //v2.0.5
  ```

  ```go Go theme={null}
  //Create the transaction to update the key on the account
  transaction, err := hedera.NewAccountUpdateTransaction().
          SetAccountID(newAccountId).
          SetKey(updateKey.PublicKey()).
          FreezeWith(client)

  if err != nil {
      panic(err)
  }

  //Sign the transaction with the old key and new key, submit to a Hedera network   
  txResponse, err := transaction.Sign(newKey).Sign(updateKey).Execute(client)

  //Request the receipt of the transaction
  receipt, err := txResponse.GetReceipt(client)
  if err != nil {
      panic(err)
  }

  //Get the transaction consensus status
  transactionStatus := receipt.Status

  println("The transaction consensus status is ", transactionStatus)

  //Version 2.0.0
  ```

  ```rust Rust theme={null}
  // Create the transaction to update the key on the account
  let transaction = AccountUpdateTransaction::new()
      .account_id(account_id)
      .key(update_key);

  // Sign the transaction with the old key and new key
  let tx_response = transaction
      .freeze_with(&client)?
      .sign(old_key)
      .sign(new_key)
      .execute(&client).await?;

  // Request the receipt of the transaction
  let receipt = tx_response.get_receipt(&client).await?;

  // Get the transaction consensus status
  let status = receipt.status;

  println!("The transaction consensus status is {:?}", status);

  // v0.34.0
  ```
</CodeGroup>

#### Add hooks to an existing account

This example adds two [account allowance hooks](/hedera/core-concepts/accounts/hiero-hooks) to an existing account. The hook contract must be deployed first via `ContractCreateTransaction`.

<CodeGroup>
  ```java Java theme={null}
  // Create hook details
  HookCreationDetails hook1 = new HookCreationDetails(
      HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      1L,
      new EvmHook(contractId),
      adminKey.getPublicKey()
  );

  HookCreationDetails hook2 = new HookCreationDetails(
      HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      2L,
      new EvmHook(contractId),
      adminKey.getPublicKey()
  );

  // Add hooks to the account
  TransactionResponse txResponse = new AccountUpdateTransaction()
      .setAccountId(accountId)
      .addHookToCreate(hook1)
      .addHookToCreate(hook2)
      .setMaxTransactionFee(new Hbar(10))
      .freezeWith(client)
      .sign(accountKey)
      .execute(client);

  TransactionReceipt receipt = txResponse.getReceipt(client);
  System.out.println("Hooks added: " + receipt.status);
  ```

  ```javascript JavaScript theme={null}
  import {
      AccountUpdateTransaction,
      HookCreationDetails,
      EvmHook,
      HookExtensionPoint,
      Long,
      Hbar,
  } from "@hiero-ledger/sdk";

  // Create hook details
  const hook1 = new HookCreationDetails({
      extensionPoint: HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      hookId: Long.fromInt(1),
      evmHook: new EvmHook({ contractId }),
      adminKey: adminKey.publicKey,
  });

  const hook2 = new HookCreationDetails({
      extensionPoint: HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      hookId: Long.fromInt(2),
      evmHook: new EvmHook({ contractId }),
      adminKey: adminKey.publicKey,
  });

  // Add hooks to the account
  const txResponse = await (
      await (
          await new AccountUpdateTransaction()
              .setAccountId(accountId)
              .addHookToCreate(hook1)
              .addHookToCreate(hook2)
              .setMaxTransactionFee(new Hbar(10))
              .freezeWith(client)
              .sign(accountKey)
      ).execute(client)
  ).getReceipt(client);

  console.log("Hooks added: " + txResponse.status);
  ```

  ```go Go theme={null}
  // Create hook details
  hook1 := hedera.NewHookCreationDetails().
      SetExtensionPoint(hedera.ACCOUNT_ALLOWANCE_HOOK).
      SetHookId(1).
      SetEvmHook(*hedera.NewEvmHook().SetContractId(&contractId)).
      SetAdminKey(adminKey.PublicKey())

  hook2 := hedera.NewHookCreationDetails().
      SetExtensionPoint(hedera.ACCOUNT_ALLOWANCE_HOOK).
      SetHookId(2).
      SetEvmHook(*hedera.NewEvmHook().SetContractId(&contractId)).
      SetAdminKey(adminKey.PublicKey())

  // Add hooks to the account
  txResponse, err := hedera.NewAccountUpdateTransaction().
      SetAccountID(accountID).
      AddHookToCreate(hook1).
      AddHookToCreate(hook2).
      SetMaxTransactionFee(hedera.NewHbar(10)).
      FreezeWith(client).
      Sign(accountKey).
      Execute(client)

  receipt, err := txResponse.GetReceipt(client)
  fmt.Printf("Hooks added: %v\n", receipt.Status)
  ```
</CodeGroup>

#### Delete hooks from an existing account

This example removes hooks by their IDs. A hook must have zero storage slots before it can be deleted — clear storage first using [`HookStoreTransaction`](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-a-hookstore-transaction).

<CodeGroup>
  ```java Java theme={null}
  TransactionResponse txResponse = new AccountUpdateTransaction()
      .setAccountId(accountId)
      .addHookToDelete(1L)
      .addHookToDelete(2L)
      .setMaxTransactionFee(new Hbar(10))
      .freezeWith(client)
      .sign(accountKey)
      .execute(client);

  TransactionReceipt receipt = txResponse.getReceipt(client);
  System.out.println("Hooks deleted: " + receipt.status);
  ```

  ```javascript JavaScript theme={null}
  import { AccountUpdateTransaction, Long, Hbar } from "@hiero-ledger/sdk";

  const txResponse = await (
      await (
          await new AccountUpdateTransaction()
              .setAccountId(accountId)
              .addHookToDelete(Long.fromNumber(1))
              .addHookToDelete(Long.fromNumber(2))
              .setMaxTransactionFee(new Hbar(10))
              .freezeWith(client)
              .sign(accountKey)
      ).execute(client)
  ).getReceipt(client);

  console.log("Hooks deleted: " + txResponse.status);
  ```

  ```go Go theme={null}
  txResponse, err := hedera.NewAccountUpdateTransaction().
      SetAccountID(accountID).
      AddHookToDelete(1).
      AddHookToDelete(2).
      SetMaxTransactionFee(hedera.NewHbar(10)).
      FreezeWith(client).
      Sign(accountKey).
      Execute(client)

  receipt, err := txResponse.GetReceipt(client)
  fmt.Printf("Hooks deleted: %v\n", receipt.Status)
  ```
</CodeGroup>

## Get transaction values

Return the properties of an account create transaction.

| Method                           | Type                       | Description                                               |
| -------------------------------- | -------------------------- | --------------------------------------------------------- |
| `getKey()`                       | Key                        | Returns the public key on the account                     |
| `getInitialBalance()`            | Hbar                       | Returns the initial balance of the account                |
| `getReceiverSignatureRequired()` | boolean                    | Returns whether the receiver signature is required or not |
| `getExpirationTime()`            | Instant                    | Returns the expiration time                               |
| `getAccountMemo()`               | String                     | Returns the account memo                                  |
| `getDeclineStakingReward()`      | boolean                    | Returns whether or not the account is declining rewards   |
| `getStakedNodeId()`              | long                       | Returns the node ID the account is staked to              |
| `getStakedAccountId()`           | AccountId                  | Returns the account ID the node is staked to              |
| `getAutoRenewPeriod()`           | Duration                   | Returns the auto renew period on the account              |
| `getHooksToCreate()`             | list\<HookCreationDetails> | Returns the hooks to be created on the account            |
| `getHooksToDelete()`             | list\<long>                | Returns the hook IDs to be deleted from the account       |

<CodeGroup>
  ```java Java theme={null}
  //Create a transaction
  AccountUpdateTransaction transaction = new AccountUpdateTransaction()
      .setAccountId(accountId)
      .setKey(newKeyUpdate);

  //Get the key on the account
  Key accountKey = transaction.getKey();

  //v2.0.0
  ```

  ```javascript JavaScript theme={null}
  //Create a transaction
  const transaction = new AccountUpdateTransaction()
      .setAccountId(accountId)
      .setKey(newKeyUpdate);

  //Get the key of an account
  const accountKey = transaction.getKey();

  //v2.0.0
  ```

  ```go Go theme={null}
  //Create the transaction 
  transaction, err := hedera.NewAccountUpdateTransaction().
          SetAccountID(newAccountId).
          SetKey(updateKey.PublicKey())

  //Get the key of an account
  accountKey := transaction.GetKey()

  //v2.0.0
  ```
</CodeGroup>
