Skip to content

Latest commit

 

History

History
242 lines (170 loc) · 10.5 KB

environment-setup.md

File metadata and controls

242 lines (170 loc) · 10.5 KB
description
Step-by-Step Hedera Environment Setup Guide

Environment Setup

This environment setup guide outlines the steps needed to get your development environment ready for building applications on the Hedera network.

What you will accomplish

By the end of this guide, you will be able to:

  • Set up a project and install dependencies.
  • Create and configure a .env file to store environment variables.

Prerequisites

Before you begin, you should have completed the following guide:

Also, you should have the following set up on your computer ⬇
  • POSIX-compliant shell
    • For Linux & Mac: The shell that ships with the operating system will work. Either bash or zsh will work.
    • For Windows: The shells that ship with the operating system (cmd.exe, powershell.exe) will not work.
  • git installed
  • A code editor or IDE
  • NodeJs + npm installed
    • Minimum version of NodeJs: 18
      • Check version: node -v
    • Minimum version of npm: 9.5
      • Check version: npm -v
    • Recommended for Linux & Mac: nvm
    • Recommended for Windows: nvm-windows

Gitpod (Optional)

To skip the setup steps and quickly get started, open the project repository in your language of choice and click the Open in Gitpod button. This will launch a Gitpod workspace/environment that automatically installs all the dependencies.

➡️ Try now with Gitpod:

{% hint style="info" %} Once your workspace is fully launched, you will see the instructions to enter values for the prompts:

🟣 Please enter values requested, or accept defaults, in the interactive prompts below.

  1. Follow the prompts in the Gitpod console to configure your .env file. Refer to the Prompts expandable in Step 2 for guidance on completing your .env file setup.
  2. Refer to Step 3 for guidance on managing metrics. Learn how to disable them in Gitpod if you prefer not to store your progress metrics on-chain.
  3. Once everything is set up, head to the Next Steps section to choose your learning path and start building. {% endhint %}

Step 1: Project Setup

Clone the project repository in your language of choice. git clone the repo and cd into the project's root directory.

{% tabs %} {% tab title="JavaScript" %}

git clone https://github.com/hedera-dev/hello-future-world-js
cd hello-future-world-js

{% endtab %}

{% tab title="Java" %}

git clone https://github.com/hedera-dev/hello-future-world-java
cd hello-future-world-java

{% endtab %}

{% tab title="Go" %}

git clone https://github.com/hedera-dev/hello-future-world-go
cd hello-future-world-go

{% endtab %} {% endtabs %}

Install all dependencies:

./util/03-get-dependencies.sh 

Open your project directory in your code editor or IDE. This is what it should look like.


Step 2: Create Your .env File

When setting up your project, you must create a .env file to store your environment variables. To make this process easier, run the script below. It will interactively prompt you for input and automatically populate the required values in the file based on your responses.

In your project root directory, run:

./util/00-main.sh
Prompts
  1. Enter a BIP-39 seed phrase

    (enter a blank value to generate a new one at random)

    • If you don't have one to provide, click enter, and a 12-word seed phrase will be created for you.
  2. Enter a number of testnet accounts to generate from your BIP-39 seed phrase

    Default: "3" (enter a blank value to use the default value)

    • The default number of accounts will enable you to complete all examples.
  3. Enter your preferred JSON-RPC endpoint URL

    Current: "https://7546-hederadev-hellofuturewo-l2r7cpgqrcv.ws-us117.gitpod.io" (enter a blank value to use the default value)

    • List of public endpoints here.
    • Note that the default value will be different if you are using Gitpod.
  4. Enter your operator account (ECDSA) private key

    (enter a blank value to use the first account created from the BIP-39 seed phrase as the operator account)

    • This is the hex-encoded private key1 (ECDSA secp256k1) from the testnet account created on the Hedera Portal or HashPack wallet.
    • If you used the Hedera faucet to create a testnet account, this would be its corresponding private key.
  5. Do you wish to overwrite the .env file with the above?

    (restart/yes/No)

    • Enter yes to complete creating the .env file.
    • Enter no if you prefer to manually configure the file.
    • Enter restart if you entered the wrong values and need to start the setup process over.

After the last prompt, you should see a new .env file in your project root directory. Check that each of the environment variables has a value.

{% hint style="danger" %}

⚠️ Warning

Storing private keys in a .env file is not considered best practice. There is always a risk of accidentally committing and pushing to a public GitHub repo and exposing your keys. Make it a habit to add .env to your .gitignore file as a precautionary measure.

node_modules
package-lock.json
/.env
/.rpcrelay.env
/logger.json

We highly advise against using a private key with mainnet funds. {% endhint %}


Step 3: Progress Metrics (Optional)

Your progress will captured as metrics and published to the Hedera network for you to share with others! If you would like to disable publishing the metrics to the public ledger and viewable in a network explorer, please change metricsHcsDisabled value to true in the logger.json file located in the root directory. The metrics are enabled by default with the value false.

Example logger.json file:

{% tabs %} {% tab title="Enabled (default)" %}

{
  "config": {
    "scriptCategory": "config",
    "ansiDisabled": false,
    "metricsId": "",
    "metricsHcsTopicId": "0.0.4573319",
    "metricsHcsTopicMemo": "HFWV2",
    "metricsAccountId": "",
    "metricsAccountKey": "",
    "metricsHcsDisabled": false
  }
}

{% endtab %}

{% tab title="Disabled" %}

{
  "config": {
    "scriptCategory": "config",
    "ansiDisabled": true,
    "metricsId": "",
    "metricsHcsTopicId": "0.0.4573319",
    "metricsHcsTopicMemo": "HFWV2",
    "metricsAccountId": "",
    "metricsAccountKey": "",
    "metricsHcsDisabled": true
  }
}

{% endtab %} {% endtabs %}


Complete

Congratulations, you have completed the Environment Setup guide in the Getting Started series!

You have learned how to:

  • Clone the project repository.
  • Create a .env file to store environment variables.

Next Steps: Choose Your Developer Learning Path

Now that your environment is set up, you can start building on the Hedera Testnet! Based on your experience level and development needs, choose one of the following paths that best describes you:

Web2 DevelopersChoose this path if you're a web2 developer or a student new to web3 and Hedera. Learn to build on Hedera using SDKs in Java, JavaScript, or Go. Start with transferring HBAR, creating tokens, and managing topics.

LEARN MORE

web2-developers
EVM DevelopersChoose this path if you have experience deploying Solidity contracts on Ethereum and other EVM networks. Learn to write, compile, deploy, and verify smart contracts using familiar EVM-compatible tools.

LEARN MORE

evm-developers

{% hint style="info" %} Have questions? Join the Hedera Discord and post them in the developer-general channel or ask on Stack Overflow. {% endhint %}

Footnotes

  1. (e.g., 0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890)