blog

Get started with the Hedera Token Service – Part 1

December 7, 2020
Hedera Team
Hedera
Hedera provides secure, scalable infrastructure for real-world decentralized applications in finance, AI, and sustainability, governed by global enterprises.

This blog post has been updated to include the latest capabilities of the Hedera Token Service. 

See the updated version: Get Started with the Hedera Token Service – Part 1: How to Mint NFTs

The Hedera Token Service (HTS) is used via a robust set of APIs for the configuration, minting, and management of tokens on Hedera, without needing to set up and deploy a smart contract. Tokens are as fast, fair, and secure as hbar and cost a fraction of 1¢ USD to transfer.

Let’s take a look at why you’d consider using it versus something like a fungible token with a smart contract on the Ethereum Blockchain, and the different types of functionalities that are available within the Hedera API (HAPI):

With HTS, it’s incredibly easy to create a new token that can represent anything from a stablecoin pegged to the USD value, or an in-game reward system.

Note: while most of the following examples are in JavaScript (v2.0.7), official SDKs supporting Go and Java are also available and implemented very similarly, alongside community-supported SDKs in .NET and various other frameworks and/or languages.

Create a Token


Create token
Create token

//Create a token

const transaction = await new TokenCreateTransaction()

.setTokenName("Your Token Name")

.setTokenSymbol("F")

.setTreasuryAccountId(treasuryAccountId)

.setInitialSupply(5000)

.setAdminKey(adminPublicKey)

.freezeWith(client);


//Sign the transaction with the token adminKey and the token treasury account private key

const signTx = await (await transaction.sign(adminKey)).sign(treasuryKey);


//Sign the transaction with the client operator private key and submit to a Hedera network

const txResponse = await signTx.execute(client);

//Get the receipt of the the transaction

const receipt = await txResponse.getReceipt(client);


//Get the token ID from the receipt

const tokenId = receipt.tokenId;

console.log("The new token ID is " + tokenId);

To show how similar the Hedera Token Service is to use in any of our supported SDKs, here is the same example but in Java.


Java Example
Java Example

//Create the transaction

TokenCreateTransaction transaction = new TokenCreateTransaction()

.setTokenName("Your Token Name")

.setTokenSymbol("F")

.setTreasuryAccountId(treasuryAccountId)

.setInitialSupply(5000)

.setAdminKey(adminKey.getPublicKey());


//Build the unsigned transaction, sign with admin private key of the token, sign with the token treasury private key, submit the transaction to a Hedera network

TransactionResponse txResponse = transaction.freezeWith(client).sign(adminKey).sign(treasuryKey).execute(client);


//Request the receipt of the transaction

TransactionReceipt receipt = txResponse.getReceipt(client);


//Get the token ID from the receipt

TokenId tokenId = receipt.tokenId;

System.out.println("The new token ID is " + tokenId);

And here is the same relevant code example for the Go SDK.


Go example
Go example

//Create the transaction and freeze the unsigned transaction

tokenCreateTransaction, err := hedera.NewTokenCreateTransaction().

SetTokenName("Your Token Name").

SetTokenSymbol("F").

SetTreasuryAccountID(treasuryAccountId).

SetInitialSupply(1000).

SetAdminKey(adminKey).

FreezeWith(client)

if err != nil {

panic(err)

}

//Sign with the admin private key of the token, sign with the token treasury private key, sign with the client operator private key and submit the transaction to a Hedera network

txResponse, err := tokenCreateTransaction.Sign(adminKey).Sign(treasuryKey).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 token ID from the receipt

tokenId := *receipt.TokenID

fmt.Printf("The new token ID is %vn", tokenId)

Token Associations

Before another account can receive or send this specific token ID, they have to become “associated” with it — this helps reduce unwanted spam, potential tax liability, or other concerns from users that don’t want to be associated with any of the variety of tokens that will be created on HTS.


Token Associations
Token Associations

//Associate a token to an account and freeze the unsigned transaction for signing

const transaction = await new TokenAssociateTransaction()

.setAccountId(accountId)

.setTokenIds([tokenId])

.freezeWith(client);


//Sign with the private key of the account that is being associated to a token

const signTx = await transaction.sign(accountKey);


//Submit the transaction to a Hedera network

const txResponse = await signTx.execute(client);


//Request the receipt of the transaction

const receipt = await txResponse.getReceipt(client);

//Get the transaction consensus status

const transactionStatus = receipt.status;

console.log("The transaction consensus status " +transactionStatus.toString());

Transferring tokens

Transferring these newly created tokens between accounts, after the token has been created and both accounts are associated with the new token ID, is almost easier.


Transferring tokens
Transferrong tokens

//Create the transfer transaction

const transaction = await new TransferTransaction()

.addTokenTransfer(tokenId, accountId1, -10)

.addTokenTransfer(tokenId, accountId2, 10)

.freezeWith(client);


//Sign with the sender account private key

const signTx = await transaction.sign(accountKey1);

//Sign with the client operator private key and submit to a Hedera network

const txResponse = await signTx.execute(client);

//Request the receipt of the transaction

const receipt = await txResponse.getReceipt(client);

//Obtain the transaction consensus status

const transactionStatus = receipt.status;

console.log("The transaction consensus status " +transactionStatus.toString());

Integrating HTS is incredibly easy, within just a few lines of code in your favorite programming language you can create, associate, and transfer tokens. Please continue reading onto Part 2 of this HTS introduction in order to learn more about the administration functionalities provided by HAPI, and in Part 3 we will discuss other compliance mechanisms like KYC compliance.

Back to Blog

discover

See more articles

February 24, 2026

Updates to the Hiero JSON-RPC Relay Default Configuration for Ethereum-Style Alignment | April 2026

The April 2026 release of the Hiero JSON-RPC Relay (v0.77.0), updates several default configuration values to better align the Relay’s behavior with what developers expect from standard Ethereum JSON-RPC implementations.
Read More
February 24, 2026

Axelar Connects Hedera, Expanding the Gateway to Onchain Finance

Axelar has integrated Hedera, giving developers and users across onchain finance seamless access to Hedera technology, applications and liquidity through a single programmable interface. The connection enables secure cross-chain transfers
Read More
February 13, 2026

Migrating from AccountBalanceQuery: What You Need to Know

The AccountBalanceQuery in the Hiero SDKs (and Hedera API) will be entirely removed in July 2026. A gradual throttle reduction begins in May 2026 to give developers time to transition.
Read More