Hedera account is your identity on‑chain. It holds your HBAR (the network’s currency) and lets you sign transactions.
Prerequisites
- A Hedera testnet operator account ID and ECDSA DER-encoded private key (from the Quickstart).
- A small amount of testnet HBAR (ℏ) to pay the
$0.05account‑creation fee.
NoteYou can always check the ”✅ Code Check” section at the bottom of each page to view the entire code if you run into issues. You can also post your issue to the respective SDK channel in our Discord community here.
Install the SDK
- JavaScript
- Java
- Go
- Python
Open your terminal and create a directory Initialize a Ensure you have Node.js Update your Create a
hedera-examples directory. Then change into the newly created directory:node.js project in this new directory:v18 or later installed on your machine. Then, install the JavaScript SDK.package.json file to enable ES6 modules and configure the project:createAccountDemo.js file and add the following imports:Environment Variables
Set your testnet operator credentials as environment variables. YourOPERATOR_ID is your testnet account ID. Your OPERATOR_KEY is your testnet account’s corresponding ECDSA private key.
Step 1: Initialize Hedera Client
Load your operator credentials from environment variables and initialize your Hedera testnet client. This client will connect to the Hedera test network and use your operator account to sign transactions and pay transaction fees.Step 2: Generate a New Key Pair
Generate a new ECDSA private/public key pair for the account you’ll create.Why keys?
On the Hedera network, a private key allows you to sign transactions, ensuring only you control your assets, while a public key, shared on-chain, verifies your identity. This key pair is essential for account security.Step 3: Create Your First Account on Hedera
Build anAccountCreateTransaction with the new public key and initial balance, then execute it. Specify the public key , an optional initial HBAR balance, and once you execute it, the network creates the account and returns the new AccountId in the receipt.
Step 4: Query the Account Balance Using Mirror Node API
Use the Mirror Node REST API to check your new account’s HBAR balance. Mirror nodes provide free access to network data without transaction fees. API endpoint:{accountId}- Your new account ID from the creation transaction
Why this endpoint? This endpoint queries account balances directly by account ID. It returns detailed information including HBAR balance in tinybars, making it ideal for verifying the new account was funded with the expected initial balance.Example URLs:
✅ Code check
Before running your project, verify your code matches the complete example:JavaScript
JavaScript
Java
Java
Go
Go
Python
Python
Run Your Project
Ensure your environment variables are set:- JavaScript
- Java Maven
- Java Gradle
- Go
- Python
Expected sample output:
‼️ Troubleshooting
Common ERROR messages and solutions ⬇️
Common ERROR messages and solutions ⬇️
| Error message | Likely cause | Fix |
|---|---|---|
INSUFFICIENT_PAYER_BALANCE | Operator account lacks enough ℏ for the fee. | Top‑up your testnet account with the HBAR faucet. |
INVALID_SIGNATURE | Operator key doesn’t match operator account | Verify OPERATOR_KEY matches your OPERATOR_ID |
INVALID_ACCOUNT_ID | Malformed account ID in environment variables | Verify OPERATOR_ID format is 0.0.1234 |
INVALID_PRIVATE_KEY | Malformed private key in environment variables | Verify OPERATOR_KEY is a valid DER-encoded private key string |
KEY_REQUIRED | Missing key in AccountCreateTransaction | Ensure you call .setECDSAKeyWithAlias(newPublicKey) |
OPERATOR_ID and OPERATOR_KEY must be set | Environment variables not accessible | Check environment variables are set and accessible to your application |
Cannot read properties of undefined | Missing imports or undefined variables | Verify all imports are included and variables are defined |
What just happened?
- The SDK built an
AccountCreateTransactionand signed it with your operator key. - A consensus node validated the signature and charged the account creation fee.
- After network consensus, a unique account ID and EVM address were assigned and returned in the receipt.
- The account was funded with 20 HBAR from your operator account.
- The Mirror Node API confirmed your new account exists with the expected balance.
Next steps
- Learn more about accounts
- Create a Token
- Explore more examples in the SDK repos (JavaScript, Java, Go)
🎉 Great work! You now control a brand new Hedera account secured by your fresh key pair. Keep the private key safe and never commit it to source control.