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

March 25, 2026

McLaren Racing Joins Hedera Council to Accelerate Digital Innovation

McLaren Racing has joined Hedera Council, the governing body of Hedera, strengthening the Council’s leadership in consumer applications and bringing one of the world’s most recognizable motorsport brands into the
Read More
FRNT live on Hedera
March 12, 2026

Wyoming Frontier Stable Token (FRNT) now live on Hedera

Wyoming’s Frontier Stable Token (FRNT), the first U.S. state-issued stable token, is now live on Hedera. Tokens have been minted on the Hedera EVM, as announced in the Wyoming Stable
Read More
March 12, 2026

Hedera integrates USDT0 for crosschain stablecoin liquidity

USDT0, the omnichain deployment of Tether’s USDT, is now live on Hedera. This integration brings native, frictionless stablecoin liquidity to the Hedera ecosystem, with no wrapped tokens, no synthetic assets,
Read More