Skip to main content

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 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.
When creating a new account using the AccountCreateTransaction() API you will need an existing account to pay for the associated transaction fee.

Transaction Fees and Signing

  • The sender pays for the token association fee and the rent for the first auto-renewal period.
  • See the transaction and query fees table for the base transaction fee.
  • Use the Hedera fee estimator to estimate your transaction fee cost.
  • The account paying for the transaction fee is required to sign the transaction.

Account Properties

For a complete list of account properties, see the accounts overview.

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 ValueDescription
0Automatic 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.
-1Unlimited automatic token associations are allowed, and this is the default for accounts created via 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.
> 0If 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.
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.
Reference: HIP-904

Constructor

ConstructorDescription
new AccountCreateTransaction()Initializes the AccountCreateTransaction object

Transaction Properties

MethodTypeRequirement
setKey(<key>)KeyRequired
setInitialBalance(<initialBalance>)HbarOptional
setReceiverSignatureRequired(<booleanValue>)booleanOptional
setAutoRenewPeriod(<autoRenewPeriod>)DurationOptional
setAccountMemo(<memo>)StringOptional
setMaxAutomaticTokenAssociations(<amount>)intOptional
setStakedAccountId(<stakedAccountId>)AccountIdOptional
setStakedNodeId(<stakedNodeId>)longOptional
setDeclineStakingReward(<declineStakingReward>)booleanOptional
setHighVolume(<highVolume>)booleanOptional
This transaction supports high-volume entity creation (HIP-1313). Setting setHighVolume(true) routes the transaction through dedicated high-volume throttle capacity with variable-rate pricing. Always pair this with setMaxTransactionFee() to cap your costs.
//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

Get Transaction Values

MethodTypeDescription
getKey()KeyReturns the public key on the account
getInitialBalance()HbarReturns the initial balance of the account
getAutoRenewPeriod()DurationReturns the auto renew period on the account
getDeclineStakingReward()booleanReturns whether or not the account declined rewards
getStakedNodeId()longReturns the node ID
getStakedAccountId()AccountIdReturns the node account ID
getReceiverSignatureRequired()booleanReturns whether the receiver signature is required or not
getHighVolume()booleanReturns whether this transaction uses high-volume throttles
This transaction supports high-volume entity creation (HIP-1313). Setting setHighVolume(true) routes the transaction through dedicated high-volume throttle capacity with variable-rate pricing. Always pair this with setMaxTransactionFee() to cap your costs.

Account Alias

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.
//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();