rocketmay / hashgraph-bootstrap

Barebones JS bootstrap of the Hedera-SDK-JS package.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hashgraph-bootstrap

Summary:

A barebones javascript project to get you connected to the Testnet using the Hedera API as fast and painlessly as possible.

First Steps for Complete Beginners:

For complete beginners who just want to get into the code and try messing around, here are a few steps to help get you started. These instructions are for windows users. If a mac user can help me out with a step-by-step I'd be grateful.

  1. Make a Github account and Download Github Desktop : https://desktop.github.com/
  2. Download Windows Terminal: https://www.microsoft.com/en-us/p/windows-terminal

Github Desktop will let you download and manage this repository. Github repositories are how people share code, and so getting your feet wet and learning how they work is going to be super useful if you want to learn how to develop apps.

Windows Terminal is the command line interface. It lets you type in commands to do things. A basic command list is here: https://www.thomas-krenn.com/en/wiki/Cmd_commands_under_Windows

Specifically for this bootstrap you will just need to learn how to change directories, the "CD" command. All you need to do is type "cd " to go to the directory of the project. For example, "cd C:\PROJECTS\hashgraph-bootstrap" . If your directory is on a different drive, add a /d to change the drive and directory at the same time: "cd /d D:\PROJECTS\hashgraph-boostrap"

  1. Clone the repository onto your computer. Basically this makes a copy of the files on your computer. Click the big green button that says "Code" in the top right of this page and select "Open in Github Desktop". This will launch Github desktop, let you choose a folder path for your files, and then clone it.

  2. You will now need to install Node, which is a package manager that helps you to download the code requirements for the project. You can find it here: https://nodejs.org/en/download/

  3. Now you can use the 'cd' command to navigate to the hashgraph-bootstrap/ folder and continue with the instructions below!

Installation Instructions:

Clone this repository into a folder using git

Then run the following commands, which will install the dependencies for the hashgraph SDK in the hashgraph-bootstrap folder. (Make sure you changed directory in the terminal to the folder, per the steps above).

npm init
  (follow the prompts to enter project information. Using the defaults is fine. If you're getting errors after typing 'npm init', make sure you read each line and enter the information it's asking for, such as project name, version, etc. If you're not sure, you can leave the line blank.)

npm install --save @hashgraph/sdk
npm install --save dotenv

Next you need to create a .env file in your folder with the following lines:

__ file: .env _____________________________

# Hedera Operator
# Used to pay for transaction fees for integration tests

# Hedera Operator Account ID
OPERATOR_ID="0.0.xxxxxx"

# Hedera Operator Private Key
OPERATOR_KEY="302e02010xxxxxxxxxxxxxxxxxxxxxxxxbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

For OPERATOR_ID and OPERATOR_KEY, you need to get a Hedera Portal Testnet Account https://portal.hedera.com/?network=testnet

Fill in the details and place them in the root folder of the project.


Now just run

node ./main.js

And you should see it connect to the Testnet and get an account balance!

Attempting to get token info from the Hedera API...
The token balance(s) for this account: {"0.0.574366":"999000"}

About

Barebones JS bootstrap of the Hedera-SDK-JS package.

License:MIT License


Languages

Language:JavaScript 100.0%