Prerequisites
- A Hedera testnet operator account ID and DER-encoded private key (from the Quickstart)
- A few testnet HBAR (ℏ) to cover the ≈
$1token-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.
Project Setup and SDK Installation
- 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:createTokenDemo.js file and add the following imports:Environment Variables
Set your 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 Token Keys
Generate an ECDSA key and use it for both admin and supply operations.Why keys?
adminKey lets you update or delete the token; supplyKey authorizes mint and burn operations. We use the same key for both roles to keep this tutorial simple.Step 3: Create Your First Token on Hedera
Build aTokenCreateTransaction with your token properties like name, symbol, and initial supply. Sign the transaction with your admin key, submit it to the network, and Hedera returns a unique token ID that identifies your token.
Step 4: Query the Treasury Balance Using Mirror Node API
Use the Mirror Node REST API to check your treasury account’s token balance. Mirror nodes provide free access to network data without transaction fees. API endpoint:{accountId}- Your treasury account (operator account){tokenId}- Token ID from the creation transaction
Why this endpoint? This endpoint queries the account’s token balances, filtered by the specific token ID. It returns detailed information including the balance and token metadata, making it ideal for verifying the treasury account holds the expected initial supply.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
JavaScript
Expected sample output:
‼️ Troubleshooting
Common ERROR messages and solutions ⬇️
Common ERROR messages and solutions ⬇️
| Symptom | Likely cause | Fix |
|---|---|---|
INSUFFICIENT_PAYER_BALANCE | Not enough HBAR for transaction fees | Top up your operator account on the testnet faucet |
INVALID_SIGNATURE | Not signing the transaction with the admin key or treasury account | Add .sign(privateKey)to the transaction before executing it |
TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT | Account already associated with token | This is normal for treasury accounts - ignore this error |
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 |
Environment Issues:
- Environment variables not set or accessible
- Wrong network (mainnet vs testnet) configuration
- SDK version compatibility issues
What just happened?
- The SDK built a
TokenCreateTransactionand signed it with every required key. - A consensus node validated signatures and attached the fee.
- After network consensus, HTS registered your token and returned its token ID.
- The full initial supply now sits in your treasury account and is ready to transfer.
- The Mirror Node API confirmed your treasury account holds the token balance.
Next steps
- Create a Topic
- Try out our 3-part NFT tutorial
- Explore more examples in the SDK repos (JavaScript, Java, Go)
🎉 Great work! You’ve successfully created your first fungible token on Hedera and verified its balance using the Mirror Node API. Guard your private keys and happy building!