A Comprehensive Guide to Fungible Token Development on Hedera

Posted By : Yogesh

Nov 17, 2023

This article explores a step-by-step guide on fungible token development on the Hedera Hashgraph network using JavaScript and the Hedera Hashgraph SDK. 

 

Hedera Hashgraph

 

Hedera Hashgraph is a distributed ledger technology and blockchain alternative that employs a unique consensus algorithm called Hashgraph. Designed for efficiency, security, and scalability, Hedera offers fast and fair transactions and utilizes a decentralized governance model. Its native cryptocurrency, HBAR, facilitates network operations and incentivizes users. Hedera's consensus mechanism achieves consensus asynchronously and avoids the energy-intensive proof-of-work approach. 

 

With features like smart contracts and file storage, Hedera aims to provide a robust platform for decentralized applications while prioritizing stability and sustainability in the evolving landscape of blockchain technology.

 

Check It Out | Hedera Hashgraph | Moving Beyond Blockchain

 

Prerequisites

 

Before diving into the code, ensure you have the following:

 

Hedera Testnet Account:

 

  • Set up a testnet account on Hedera Hashgraph to obtain your operator's private key and account ID.
  • Create a .env file to store your operator's private key (OPERATOR_PVKEY) and account ID (OPERATOR_ID).

 

npm i dotenv @hashgraph/sdk
const {
  ContractCreateFlow,
  AccountId,
  Client,
  PrivateKey,
  AccountBalanceQuery,
  // ... other imports ...
} = require("@hashgraph/sdk");
require("dotenv").config();

const operatorKey = PrivateKey.fromString(process.env.OPERATOR_PVKEY);
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const client = Client.forTestnet().setOperator(operatorId, operatorKey);

async function main() {
  // ... code for client initialization ...

  let tokenCreateTx = await new TokenCreateTransaction()
    .setTokenName("HTSB")
    .setTokenSymbol("HTSB")
    .setTokenType(TokenType.FungibleCommon)
    .setDecimals(3)
    .setInitialSupply(100000000000000)
    .setTreasuryAccountId(operatorId)
    .freezeWith(client)
    .sign(operatorKey);

  let tokenCreateSubmit = await tokenCreateTx.execute(client);
  let tokenCreateRx = await tokenCreateSubmit.getReceipt(client);
  let tokenId = tokenCreateRx.tokenId;
  console.log(` - Created fungible token with ID: ${tokenId}`);
}

 

  • Creates a fungible token using the TokenCreateTransaction class.
  • Configures various parameters for the token, including name, symbol, type, decimals, initial supply, and treasury account.
  • Signs and executes the transaction on the Hedera network.
  • Retrieves the transaction receipt to obtain the generated token ID.

 

Also, Discover | Deploying a Smart Contract on Hedera Hashgraph Network with Java

 

Conclusion

 

Creating fungible tokens on Hedera Hashgraph is a straightforward process, thanks to the Hedera SDK. This functionality opens up opportunities for various use cases, including creating digital currencies, loyalty points, and much more. 

 

If you are interested in fungible token development, then connect with our blockchain developers.

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

September 8, 2024 at 02:38 am

Your comment is awaiting moderation.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us
Telegram Button
Youtube Button
Contact Us

Oodles | Blockchain Development Company

Name is required

Please enter a valid Name

Please enter a valid Phone Number

Please remove URL from text