Hedera Blockchain 101:  The  Hello Future Hackathon

Hedera Blockchain 101: The Hello Future Hackathon

ยท

9 min read

Introduction

In 2009, Bitcoin introduced the world to blockchain technology, revolutionizing finance with the first digital currency. However, its rigid structure limited its application beyond cryptocurrency as a store of value. By 2015, Ethereum emerged to expand blockchain's potential with smart contracts enabling the creation of Decentralized applications(DApps) for more use cases. While it overcame Bitcoin's limitations, Ethereum faced considerable scalability challenges, resulting in high transaction fees and energy consumption. Hedera Ledger addressed these issues by offering a more efficient and scalable platform, capable of handling a higher volume of transactions while maintaining low costs.

This article will provide a beginner's guide to Hedera ledger technology, create a fungible token using Hedera Token Service, and explore potential project ideas for the Hello Future Hackathon

What is the Hedera blockchain?

Hedera is an open-source, public, proof-of-stake distributed ledger technology governed by leading organizations around the world. Unlike traditional blockchains, Hedera's consensus mechanism, the Hashgraph algorithm ensures rapid transaction finality, with a low predictable price without compromising security. One key capacity of the Hedera blockchain is its energy consumption. On average it costs 0.000003 kWh per transaction as at the time of writing making it the most sustainable public network.

Core Services of Hedera

  1. Hedera Consensus Service (HCS) is a powerful tool that leverages the underlying Hashgraph consensus algorithm to provide a decentralized, auditable, and secure platform for recording and verifying data. It's essentially a layer built on top of Hedera's core consensus mechanism to offer additional functionalities. Read more.

  2. Hedera Token Services allows for the minting and managing of fungible and non-fungible tokens at a low predictable development fee. Read more.

  3. The Solidity-Based Smart Contract Service - aims to be EVM compatible layer that can execute smart contracts written in Solidity, the primary programming language for Ethereum. It mimics the Ethereum environment, allowing developers to deploy and run their existing Ethereum smart contracts with minimal modifications.

Hedera Native Token - $HBAR

$Hbar is the energy-efficient native token of the Hedera, it is used to pay transaction fees on the network and used for securing the network through proof of stake consensus. On average it costs around $0.1 and that amount doesn't vary with the network. it is fixed by the governing council.

Hedera Hashgraph

Unlike traditional blockchains that use a linear chain of blocks, Hashgraph uses a Directed Acyclic Graph(DAG). This means a transaction is linked to multiple previous transactions, creating a complex network rather than a simple chain.

How Hashgraph Works

  1. Gossip Protocol - When a transaction is initiated, it's shared with a randomly selected subset of nodes. These nodes, in turn, share the transaction with their own randomly selected subsets, creating a cascading effect. This decentralized approach ensures rapid propagation of information throughout the network while maintaining data integrity and security

  2. Virtual Voting - this algorithm allows each node to reach a consensus on the order of transactions without the need for traditional voting rounds or blockchains.

The Hello Future Hackathon

The Hello Future Hackathon is an exciting opportunity for seasoned and aspiring web3 developers to create innovative applications on the Hedera Hashgraph. It offers the opportunity to push beyond what's possible with web3 and earn from a prize pool of $300,0000.

Key features of the hackathon include:

  • Registration ends on 18th August 2024 and the Hackathon runs from 22nd July - 20 August 2024

  • A beginner track - Hashgraph Explorer is designed for those getting started in web3 to experiment and build basic functionalities.

  • Thematic Tracks: Choose from a variety of focus areas to align with your interests, Artificial Intelligence(AI), Real World Asset(RWA) Tokenization, Decentralized Finance, and open-ended projects.

  • Side Quests with a prize pool of $17,000 for active participation during the hackathon period by contributing to pre-hack resources, sharing your unique referral link received upon registration confirmation, and staying alert on Discord and other communication channels.

  • Bonus Challenge to power inclusivity in web3 to encourage more female developers in the hackathon with a prize pool of $5000 to the top 5 teams with at least 2 female developers.

  • Expert Mentorship: Access guidance and support from industry leaders.

  • Networking Opportunities: Connect with fellow developers and potential collaborators.

To participate, simply register, form a team (optional), and dive into the world of Hedera Hashgraph. Leverage the provided SDKs, tools, and documentation to bring your ideas to life.

Building Your Fungible Token

In this section, we'll be creating a token - Nosen Token using the Hedera Token Service and Javascript SDK

  1. Create a Hedera Account: Sign up for a Hedera account to access testnet resources and developer tools. You can either create an account in the Hedera portal using one of the SDKs [GO, Java, Javascript, and Swift].

    ๐Ÿ’ก
    After account creation, your new testnet account will automatically receive 1000 HBAR,
  2. Set up your project:

    • Create a folder and initialize npm keeping the default settings
    mkdir hedera-token-service
    cd hedera-token-service 
    npm init -y
  • Install hashgraph-js-sdk

      npm install --save @hashgraph/sdk
    
  • Install .dotenv for storing sensitive data.

      npm install dotenv
    
  • create the entry point for your application

       touch index.js
    
  • create your env file and copy your credentials to it - your Account ID and Der-Encoded Private Key

      MY_ACCOUNT_ID=0.0.1234
      MY_PRIVATE_KEY=302e020100300506032b657004220420ed5a93073.....
    
  1. Environment Set UP

    • Initialize your client and test if your account Id and private key have been initialized successfully

        const { Client, PrivateKey, AccountCreateTransaction, AccountBalanceQuery, Hbar, TransferTransaction } = require("@hashgraph/sdk");
        require('dotenv').config();
      
        //Grab your Hedera testnet account ID and private key from your .env file
         const myAccountId = process.env.MY_ACCOUNT_ID;
         const myPrivateKey = process.env.MY_PRIVATE_KEY;
      
        //Check if account key and private key is loaded
        async function environmentSetup(){
            if (!myAccountId || !myPrivateKey) {
                throw new Error("Environment variables MY_ACCOUNT_ID and MY_PRIVATE_KEY must be present");
            }else{
                console.log("We're ready to go")
            }
        }
        environmentSetup();
      
  2. Create your Hedera Testnet client

    Create a client and set the Operator information using your testnet account ID and private key. The operator is the default account that pays transaction and query fees in Hbar. Confirm account balance to make sure you have enough $Hbar for transactions

    ```javascript

    async function createHederaClient() { //Create your Hedera Testnet client const client = Client.forTestnet();

    //Set your account as the client's operator client.setOperator(myAccountId, myPrivateKey);

    //Set the default maximum transaction fee (in Hbar) client.setDefaultMaxTransactionFee(new Hbar(100));

    //Set the maximum payment for queries (in Hbar) client.setMaxQueryPayment(new Hbar(50));

return client; }

//Verify the account balance async function checkAccountBalance(client) { const accountBalance = await new AccountBalanceQuery() .setAccountId(myAccountId) .execute(client); // 1 Hbar is equal to 1,000,000,000 tinybars console.log("The new account balance is: " + accountBalance.hbars.toTinybars() + " tinybar."); }


5. **Create a Fungible Token - Nosen Token**

    ```javascript
    async function createToken(client) {
      // Generate a new private key for the supply key of the token
      const supplyKey = PrivateKey.generate();

      // Create a private key from the environment variable for the treasury key
      const treasuryKey = PrivateKey.fromString(process.env.MY_PRIVATE_KEY);

      // Create a new token creation transaction
      const tokenCreateTx = await new TokenCreateTransaction()
        // Set the name of the token
        .setTokenName("Nosen Token")
        // Set the symbol of the token
        .setTokenSymbol("NNT")
        // Set the token type to fungible common
        .setTokenType(TokenType.FungibleCommon)
        // Set the number of decimal places for the token
        .setDecimals(2)
        // Set the initial supply of the token
        .setInitialSupply(10000)
        // Set the account ID of the treasury account
        .setTreasuryAccountId(client.operatorAccountId)
        // Set the supply type to infinite
        .setSupplyType(TokenSupplyType.Infinite)
        // Set the supply key for the token
        .setSupplyKey(supplyKey)
        // Freeze the transaction for signing
        .freezeWith(client);

      // Sign the transaction with the treasury key
      const tokenCreateTxSigned = await tokenCreateTx.sign(treasuryKey);

      // Submit the transaction to the Hedera network
      const tokenCreateSubmit = await tokenCreateTxSigned.execute(client);

      // Get the receipt of the transaction
      const tokenCreateRx = await tokenCreateSubmit.getReceipt(client);

      // Get the token ID from the receipt
      const tokenId = tokenCreateRx.tokenId;

      // Log the token ID to the console
      console.log(`- Created token with ID: ${tokenId} \n`);
    }

    async function main() {
      try {
        // Create a Hedera client instance
        const client = await createHederaClient();

        // Check the account balance
        await checkAccountBalance(client);

        // Create a new token
        await createToken(client);
      } catch (error) {
        // Handle errors gracefully
        console.error("Error:", error);
      }
    }

    main();
  1. Import your testnet account into Hashpack Wallet to see your Token

    %[loom.com/share/9c0e3ec0b41e4faba8717552584d..

The complete code for this section can be found on GitHub

๐Ÿ’ก
The Hashgraph Association and Swirl Lab curated an online course for mastering development on Hedera. It contains 11 modules covering the architecture and fundamentals for building on Hedera Hashgraph. On completion and passing the final assessment, you earn a certificate of completion that is minted as an NFT on the network

Hedera Hashgraph Use Cases and Building Your Project

Hedera Hashgraph's unique features make it suitable for various applications across industries. Here are some prominent use cases:

  • Supply Chain Management: to track product movement, ensure authenticity, and reduce fraud.

  • Digital Identity: Securely manage and verify digital identities.

  • Financial Services: Enable cross-border payments, tokenization of real-world assets, and decentralized finance (DeFi).

  • Gaming: Create decentralized gaming platforms with fair and transparent mechanics and in-game currency.

  • Healthcare: Securely store and share patient data, and manage supply chains.

Building Your Hackathon Project

To build a successful project, consider the following steps:

  1. Identify a Problem: Determine a real-world issue that can be addressed using Hedera's unique technology.

  2. Leverage Hedera's Features: Choose the appropriate Hedera services to solve the problem (e.g., Hedera Token Service [HCS], Hedera Smart Contracts Service, Hedera Consensus Service).

  3. Design Your Application: Create a clear architecture and user interface for your application. Use tools like Figma for UI and wireframing.

  4. Develop and Test: Build your application using Hedera's SDKs and thoroughly test its functionality. Hedera currently, has SDKs in 4 programming languages - GO, Java, Javascript, and Swift.

  5. Optimize Performance: Fine-tune your application for optimal performance and scalability.

  6. Prepare Your Pitch: Develop a compelling presentation to showcase your project to the judges. Use tools like Figma or Canva to create premade templates.

Additional Tips

  • Collaborate: Work with a team to leverage diverse skills and perspectives.

  • Leverage Open Source: Utilize existing libraries and tools to accelerate development - Web3.js

  • Focus on User Experience: Create a user-friendly and intuitive application.

  • Consider Sustainability: Align your project with Hedera's commitment to environmental sustainability.

Conclusion

The Hedera blockchain is a unique blend of carbon-negative sustainable practices and low transaction fees making it a prime platform for building scalable and sustainable enterprise applications.

Hey there! Thanks for checking out my work. Want to learn more or team up on a cool project? Hit me up on Twitter or LinkedIn. My name is Ese Monday, and I am a DevRel always on the lookout for new challenges.

Introducing Nosen

Nosen is a tight-knit community of new and experienced developers who build and collaborate using various tools and technology. It is a movement to address common setbacks faced by junior engineers. With Nosen you get:

  • Weekly sprint of new projects

  • Opportunity to understand and build with diverse technology.

  • Unique projects to be added to their portfolio.

  • Certificate of participation.

  • Continued support throughout your journey.

The goal is to equip developers with the tools and support they need to thrive.

Join us in shaping the future of development. Follow Nosen on Linkedin to stay updated on our latest initiatives and opportunities.

References

Join the official communication community Discord and Twitter