Skip to main content
Version: Nitrogen

Setting Up

Dependencies

In this guide we'll be using standard tools such as git, docker, nodejs, your favorite package manager such as npm, yarn or pnpm for NodeJS and your favorite IDE/Text editor.

note

Although you can use all the aforementioned package managers we primarily use, support and generally recommend pnpm.

Installing Dependencies

Install docker from: https://docs.docker.com/engine/install/ubuntu/

Install nodejs from nodesource: (other options are also okay)

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\
sudo apt-get install -y nodejs

Installation

Start From a Template

First, let's clone our template project. Go to our hardhat template repository and click "use this template". Choose your new project name and set up a repository.

Help, I can't find the button!
Use this template

Now clone your new repository, or open a cloud-based environment such as Github Workspaces.

git clone https://github.com/your/repository.git

Change the directory into the repository and install the project dependencies

npm install

I'm more of a Free Spirit

Alternative set up paths can be just cloning or forking the example repository, or starting from scratch using our Fhenix hardhat plugin, Gitpod environment or Github Workspaces

Configuring and Starting Localfhenix

In order for us to locally deploy and test contracts we will need to run our own node, for this specific use-case we have a docker image named localfhenix. For ease of use and a simple setup we have hardhat task localfhenix:start that downloads and runs the image in a container for you.

Set up your Mnemonic

Hardhat uses an .env with mnemonics to deploy and interact with contracts. Copy the .env.example file to .env and set your mnemonics (you can use the default mnemonics if you just want to use LocalFhenix)

cp .env.example .env

This is the output of cat .env:

# obviously DO NOT USE IN PRODUCTION OR ANYWHERE OR WHATEVER
# default wallet of localfhenix
export MNEMONIC="demand hotel mass rally sphere tiger measure sick spoon evoke fashion comfort"
export WALLET=""

Starting LocalFhenix.

Use the following command:

npm run localfhenix:start

You should see input similar to the following:

> fhenix-hardhat-example@1.0.0 localfhenix:start
> hardhat localfhenix:start

Downloading docker image ghcr.io/fhenixprotocol/localfhenix:v0.2.3...
warning

In case of an error in this step make sure docker is running, and you have the necessary permissions to run docker commands.

Wait about a minute for the image to finish downloading, after which you should see a success message:

Downloading docker image ghcr.io/fhenixprotocol/localfhenix:v0.2.3...
done!
Started LocalFhenix successfully at 127.0.0.1:42069

We now have a Fhenix blockchain environment running locally! Everything is set up and ready, and we can move on to coding :)

tip
  • If you want to make sure the container is running, you can use docker ps to see the container, available ports, etc.

  • If you want to stop LocalFhenix you can issue the following command:

npm run localfhenix:stop