> ## 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.

# Create an account

### **Create an account using the account create API**

A transaction that creates a Hedera account. A Hedera account is required to interact with any of the Hedera network services as you need an account to pay for all associated transaction/query fees. You can visit the [Hedera Developer Portal](https://portal.hedera.com/register) to create a previewnet or testnet account. You can also use third-party wallets to generate free [mainnet accounts](/hedera/networks/mainnet/mainnet-access). To process an account create transaction, you will need an existing account to pay for the transaction fee. To obtain the new account ID, request the [receipt](/hedera/sdks-and-apis/sdks/transactions/get-a-transaction-receipt) of the transaction.

<Info>
  When creating a **new account** using the`AccountCreateTransaction()`API you will need an existing account to pay for the associated transaction fee.
</Info>

**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 your transaction fee cost.

**Transaction Signing Requirements**

* The account paying for the transaction fee is required to sign the transaction.

#### 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 |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ----------- |
| `setKey(<key>)`                                   | Key                                                                                                | Required    |
| `setAlias(<alias>)`                               | EvmAddress                                                                                         | Optional    |
| `setInitialBalance(<initialBalance>)`             | HBar                                                                                               | Optional    |
| `setReceiverSignatureRequired(<booleanValue>)`    | boolean                                                                                            | Optional    |
| `setMaxAutomaticTokenAssociations(<amount>)`      | int                                                                                                | Optional    |
| `setStakedAccountId(<stakedAccountId>)`           | AccountId                                                                                          | Optional    |
| `setStakedNodeId(<stakedNodeId>)`                 | long                                                                                               | Optional    |
| `setDeclineStakingReward(<declineStakingReward>)` | boolean                                                                                            | Optional    |
| `setAccountMemo(<memo>)`                          | String                                                                                             | Optional    |
| `setAutoRenewPeriod(<autoRenewPeriod>)`           | Duration                                                                                           | Disabled    |
| `addHook(<hook>)`                                 | [HookCreationDetails](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks)        | Optional    |
| `setHooks(<hooks>)`                               | list\<[HookCreationDetails](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks)> | Optional    |

<Warning>
  **Account Alias**

  If an alias is set during account creation, it becomes [immutable](/hedera/support-and-community/glossary#immutability), meaning it cannot be changed. If you plan to update or rotate keys in the future, do not set the alias at the time of initial account creation. The alias can be set after finalizing all key updates.
</Warning>

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

  You can attach [Hiero Hooks](/hedera/core-concepts/accounts/hiero-hooks) to an account at creation time using `addHook()`. Hooks are programmable EVM extension points that let you enforce custom validation logic on transfers involving this account. See [Create and Manage Hooks](/hedera/sdks-and-apis/sdks/accounts-and-hbar/create-and-manage-hooks) for full details and utility class reference.
</Info>

<CodeGroup>
  ```java Java theme={null}
  //Create the transaction
  AccountCreateTransaction transaction = new AccountCreateTransaction()
      .setKeyWithAlias(ecdsaPublicKey)
      // DO NOT set an alias with your key if you plan to update/rotate keys in the future, Use .setKeyWithoutAlias instead 
      // .setKeyWithoutAlias(ecdsaPublicKey)
      .setInitialBalance(new Hbar(1));

  //Submit the transaction to a Hedera network
  TransactionResponse txResponse = transaction.execute(client);

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

  //Get the account ID
  AccountId newAccountId = receipt.accountId;

  System.out.println("The new account ID is " +newAccountId);

  //Version 2.0.0
  ```

  ```javascript JavaScript theme={null}
  //Create new ECDSA key
  const ecdsaPublicKey = PrivateKey.generateECDSA().publicKey

  //Create the transaction
  const transaction = new AccountCreateTransaction()
      .setKeyWithAlias(ecdsaPublicKey)
      // DO NOT set an alias with your key if you plan to update/rotate keys in the future, Use .setKeyWithoutAlias instead 
      // .setKeyWithoutAlias(ecdsaPublicKey)
      .setInitialBalance(new Hbar(1));

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

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

  //Get the account ID
  const newAccountId = receipt.accountId;

  console.log("The new account ID is " +newAccountId);

  //v2.0.5
  ```

  ```go Go theme={null}
  //Create the transaction
  transaction := hedera.NewAccountCreateTransaction().
          SetKeyWithAlias(ecdsaPublicKey).
          //do not set if you need to rotate keys in the future
          // SetKeyWithoutAlias(ecdsaPublicKey).
          SetInitialBalance(hedera.NewHbar(1))

  //Sign the transaction with the client operator private key and submit to a Hedera network
  txResponse, err := AccountCreateTransaction.Execute(client)
  if err != nil {
      panic(err)
  }

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

  //Get the account ID
  newAccountId := *receipt.AccountID

  fmt.Printf("The new account ID is %v\n", newAccountId)

  //Version 2.0.0
  ```

  ```rust Rust theme={null}
  // Create new ECDSA key
  let ecdsa_public_key = PrivateKey::generate_ecdsa().public_key();

  // Create the transaction
  let transaction = AccountCreateTransaction::new()
      .key_with_alias(ecdsa_public_key)
      // DO NOT set an alias with your key if you plan to update/rotate keys in the future, Use .key_without_alias instead 
      // .key_without_alias(ecdsa_public_key)
      .initial_balance(Hbar::from(1));

  // Sign the transaction with the client operator private key and submit to a Hedera network
  let tx_response = transaction
      .execute(&client)
      .await?;

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

  // Get the account ID
  let new_account_id = receipt.account_id.unwrap();

  println!("The new account ID is {}", new_account_id);

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

#### Create an account with an EVM hook

This example creates a new account with an [account allowance hook](/hedera/core-concepts/accounts/hiero-hooks) attached. The hook contract must be deployed first via `ContractCreateTransaction`.

<CodeGroup>
  ```java Java theme={null}
  // Step 1: Deploy hook contract first (standard ContractCreateTransaction)
  ContractId contractId = /* ... your deployed hook contract ... */;

  // Step 2: Create the hook details
  HookCreationDetails hookDetails = new HookCreationDetails(
      HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      1002L,
      new EvmHook(contractId),
      adminKey.getPublicKey()
  );

  // Step 3: Create the account with the hook attached
  TransactionResponse txResponse = new AccountCreateTransaction()
      .setKey(accountKey.getPublicKey())
      .setInitialBalance(Hbar.from(1))
      .addHook(hookDetails)
      .setMaxTransactionFee(new Hbar(10))
      .freezeWith(client)
      .sign(accountKey)
      .execute(client);

  AccountId newAccountId = txResponse.getReceipt(client).accountId;
  System.out.println("Account created with hook: " + newAccountId);
  ```

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

  // Step 1: Deploy hook contract first (standard ContractCreateTransaction)
  const contractId = /* ... your deployed hook contract ... */;

  // Step 2: Create the hook details
  const hookDetails = new HookCreationDetails({
      extensionPoint: HookExtensionPoint.ACCOUNT_ALLOWANCE_HOOK,
      hookId: Long.fromInt(1002),
      evmHook: new EvmHook({ contractId }),
      adminKey: adminKey.publicKey,
  });

  // Step 3: Create the account with the hook attached
  const txResponse = await (
      await new AccountCreateTransaction()
          .setKeyWithoutAlias(accountKey.publicKey)
          .setInitialBalance(new Hbar(1))
          .addHook(hookDetails)
          .setMaxTransactionFee(new Hbar(10))
          .freezeWith(client)
          .sign(accountKey)
  ).execute(client);

  const { accountId } = await txResponse.getReceipt(client);
  console.log(`Account created with hook: ${accountId}`);
  ```

  ```go Go theme={null}
  // Step 1: Deploy hook contract first (standard ContractCreateTransaction)
  // contractId := ... your deployed hook contract ...

  // Step 2: Create the hook details
  hookDetails := hedera.NewHookCreationDetails().
      SetExtensionPoint(hedera.ACCOUNT_ALLOWANCE_HOOK).
      SetHookId(1002).
      SetEvmHook(*hedera.NewEvmHook().SetContractId(&contractId)).
      SetAdminKey(adminKey.PublicKey())

  // Step 3: Create the account with the hook attached
  txResponse, err := hedera.NewAccountCreateTransaction().
      SetKey(accountKey.PublicKey()).
      SetInitialBalance(hedera.NewHbar(1)).
      AddHook(hookDetails).
      SetMaxTransactionFee(hedera.NewHbar(10)).
      FreezeWith(client).
      Sign(accountKey).
      Execute(client)

  receipt, err := txResponse.GetReceipt(client)
  fmt.Printf("Account created with hook: %v\n", receipt.AccountID)
  ```
</CodeGroup>

#### Get transaction values

| Method                           | Type                       | Description                                               |
| -------------------------------- | -------------------------- | --------------------------------------------------------- |
| `getKey()`                       | Key                        | Returns the public key on the account                     |
| `getInitialBalance()`            | Hbar                       | Returns the initial balance of the account                |
| `getAutoRenewPeriod()`           | Duration                   | Returns the auto renew period on the account              |
| `getDeclineStakingReward()`      | boolean                    | Returns whether or not the account declined rewards       |
| `getStakedNodeId()`              | long                       | Returns the node ID                                       |
| `getStakedAccountId()`           | AccountId                  | Returns the node account ID                               |
| `getReceiverSignatureRequired()` | boolean                    | Returns whether the receiver signature is required or not |
| `getHooks()`                     | list\<HookCreationDetails> | Returns the hooks to be created with the account          |

<CodeGroup>
  ```java Java theme={null}
  //Create an account with 1 hbar
  AccountCreateTransaction transaction = new AccountCreateTransaction()
      // The only _required_ property here is `key`
      .setKeyWithAlias(newPublicKey)
      // DO NOT set an alias with your key if you plan to update/rotate keys in the future, Use .setKeyWithoutAlias instead 
      // .setKeyWithoutAlias(newPublicKey)
      .setInitialBalance(new Hbar(1));

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

  ```javascript JavaScript theme={null}
  //Create an account with 1 HBAR 
  const transaction = new AccountCreateTransaction()
      // The only _required_ property here is `key`
      .setKeyWithAlias(newPublicKey)
      // Do NOT set an alias if you need to rotate keys in the future. Use .setKeyWithoutAlias instead
      // .setKeyWithoutAlias(newPublicKey)
      .setInitialBalance(new Hbar(1));

  //Return the key on the account
  const accountKey = transaction.getKey();
  ```

  ```go Go theme={null}
  //Create an account with 1 hbar
  AccountCreateTransaction := hedera.NewAccountCreateTransaction().
      SetKeyWithAlias(newPublicKey).
      // DO NOT set an alias with your key if you plan to update/rotate keys in the future, Use .SetKeyWithoutAlias instead 
      // SetKeyWithoutAlias(newPublicKey).
      SetInitialBalance(hedera.NewHbar(1))

  //Return the key on the account
  accountKey, err := AccountCreateTransaction.GetKey()
  ```
</CodeGroup>
