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 to create a previewnet or testnet account. You can also use third-party wallets to generate free mainnet accounts. 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 of the transaction.
{% hint style="info" %}
When creating a new account using theAccountCreateTransaction()
API you will need an existing account to pay for the associated transaction fee.
{% endhint %}
Account Properties
{% content-ref url="../../../core-concepts/accounts/account-properties.md" %} account-properties.md {% endcontent-ref %}
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 table for the base transaction fee.
- Please use the Hedera fee estimator to estimate your transaction fee cost.
Transaction Signing Requirements
- The account paying for the transaction fee is required to sign the transaction.
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 | The number of automatic token associations an account can have is unlimited. -1 is the default value for new automatically-created accounts. |
> 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. |
{% hint style="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.
{% endhint %}
Reference: HIP-904
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 |
{% hint style="warning" %}
If an alias is set during account creation, it becomes immutable, 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. {% endhint %}
{% tabs %} {% tab title="Java" %}
//Create the transaction
AccountCreateTransaction transaction = new AccountCreateTransaction()
.setKey(ecdsaPublicKey)
//Do NOT set an alias if you need to update/rotate keys in the future
.setAlias(ecdsaPublicKey.toEvmAddress()
.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
{% endtab %}
{% tab title="JavaScript" %}
//Create the transaction
const transaction = new AccountCreateTransaction()
.setKey(ecdsaPublicKey)
//Do NOT set an alias if you need to update/rotate keys in the future
.setAlias(ecdsaPublicKey.toEvmAddress()
.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
{% endtab %}
{% tab title="Go" %}
//Create the transaction
transaction := hedera.NewAccountCreateTransaction().
SetKey(ecdsaPublicKey).
//do not set if you need to rotate keys in the future
SetAlias(ecdsaPublicKey.ToEvmAddress()).
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
{% endtab %} {% endtabs %}
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 |
{% tabs %} {% tab title="Java" %}
//Create an account with 1 hbar
AccountCreateTransaction transaction = new AccountCreateTransaction()
// The only _required_ property here is `key`
.setKey(newPublicKey)
//Do NOT set an alias if you need to update/rotate keys in the future
.setAlias(newPublicKey.toEvmAddress())
.setInitialBalance(new Hbar(1));
//Return the key on the account
Key accountKey = transaction.getKey();
{% endtab %}
{% tab title="JavaScript" %}
//Create an account with 1 HBAR
const transaction = new AccountCreateTransaction()
// The only _required_ property here is `key`
.setKey(newPublicKey)
//Do NOT set an alias if you need to update/rotate keys in the future
.setAlias(newPublicKey.toEvmAddress())
.setInitialBalance(new Hbar(1));
//Return the key on the account
const accountKey = transaction.getKey();
{% endtab %}
{% tab title="Go" %}
//Create an account with 1 hbar
AccountCreateTransaction := hedera.NewAccountCreateTransaction().
SetKey(newPublicKey).
//Do NOT set an alias if you need to update/rotate keys in the future
SetAlias(newPublicKey.ToEvmAddress()).
SetInitialBalance(hedera.NewHbar(1))
//Return the key on the account
accountKey, err := AccountCreateTransaction.GetKey()
{% endtab %} {% endtabs %}