Skip to main content
Learn how to launch a simple fungible token on Hedera testnet. A fungible token is a divisible digital asset (think loyalty points, stablecoins, or stocks) created by the Hedera Token Service (HTS).

Prerequisites

  • A Hedera testnet operator account ID and DER-encoded private key (from the Quickstart)
  • A few testnet HBAR (ℏ) to cover the ≈ $1 token-creation fee
We will use the operator account as the token’s treasury (the account that initially holds the supply).
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

Open your terminal and create a directory hedera-examples directory. Then change into the newly created directory:
Initialize a node.js project in this new directory:
Ensure you have Node.js v18 or later installed on your machine. Then, install the JavaScript SDK.
Update your package.json file to enable ES6 modules and configure the project:
Create a createTokenDemo.js file and add the following imports:

Environment Variables

Set your operator credentials as environment variables. Your OPERATOR_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.
‼️ Security reminder: Keep your private keys secure - anyone with access can control your token.

Step 3: Create Your First Token on Hedera

Build a TokenCreateTransaction 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:
Replace the placeholders:
  • {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:
Complete Implementation:

✅ Code check

Before running your project, verify your code matches the complete example:

Run Your Project

Ensure your environment variables are set:
JavaScript

Expected sample output:

‼️ Troubleshooting

SymptomLikely causeFix
INSUFFICIENT_PAYER_BALANCENot enough HBAR for transaction feesTop up your operator account on the testnet faucet
INVALID_SIGNATURENot signing the transaction with the admin key or treasury accountAdd .sign(privateKey)to the transaction before executing it
TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNTAccount already associated with tokenThis is normal for treasury accounts - ignore this error
INVALID_ACCOUNT_IDMalformed account ID in environment variablesVerify OPERATOR_ID format is 0.0.1234
INVALID_PRIVATE_KEYMalformed private key in environment variablesVerify 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?

  1. The SDK built a TokenCreateTransaction and signed it with every required key.
  2. A consensus node validated signatures and attached the fee.
  3. After network consensus, HTS registered your token and returned its token ID.
  4. The full initial supply now sits in your treasury account and is ready to transfer.
  5. The Mirror Node API confirmed your treasury account holds the token balance.

Next steps


🎉 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!

Additional Resources

Tokens