Skip to content

Instantly share code, notes, and snippets.

@liuhaidong
Forked from nguyer/build_web3_apps.md
Last active May 28, 2022 12:46
Show Gist options
  • Select an option

  • Save liuhaidong/3b185d87f5acfba3ed7c110f442475b5 to your computer and use it in GitHub Desktop.

Select an option

Save liuhaidong/3b185d87f5acfba3ed7c110f442475b5 to your computer and use it in GitHub Desktop.
Build Ethereum Web3 Apps Quickly Using the Latest Tools

Workshop Guide - Building Apps on FireFly

Welcome! We're glad you're here! This is the guide that we will be going through during the workshop.

Before the workshop

IMPORTANT: Please make sure you have done the following before the workshop so that we can hit the ground running when the workshop starts.

Install Docker

The FireFly CLI uses docker and docker-compose to create a local development environment on your machine for offline development. Please make sure you have the latest (or very recent) version of Docker and docker-compose on your machine.

For details on how to get started with Docker, please see: https://www.docker.com/get-started/

Linux Users

NOTE: For Linux users, it is recommended that you add your user to the docker group so that you do not have to run ff or docker as root or with sudo. For more information about Docker permissions on Linux, please see Docker’s documentation on the topic.

Windows Users

NOTE: For Windows users, we recommend that you use Windows Subsystem for Linux 2 (WSL2). FireFly binaries provided for Linux will work in this environment.

To verify installation, you can run:

docker --version
Docker version 20.10.14, build a224086
docker-compose --version
Docker Compose version v2.4.1

Open SSL

The FireFly CLI also uses Open SSL for certificate generation. You probably already have a version of it installed. If not, please use your system's package manager to install Open SSL

To verify installation you can run:

openssl version
LibreSSL 2.8.3

Install Node.js

We will be using Hardhat to compile and deploy a custom smart contract during the workshop, so you'll need to make sure you have a recent version of Node.js installed.

To install Node.js for your platform please visit: https://nodejs.org/en/

To verify installation you can run:

node --version
v16.14.0
npm --version
8.3.1

Getting Started

For this portion of this workshop we will be going through the first two sections of the Getting Started Guide in the FireFly Docs to Install the FireFly CLI and Start your environment. Please follow along there.

Deploying a custom smart contract with Hardhat

To boostrap our custom smart contract, we will follow Hardhat's Getting Started guide here: https://hardhat.org/getting-started/

After creating our project directory, we need to update the hardhat.config.js file which has a module.exports section at the bottom. To get Hardhat to talk to the same blockchain node that our FireFly network is using, make the bottom of the file look like this:

module.exports = {
  solidity: "0.8.4",
  defaultNetwork: "firefly",
  networks: {
    firefly: {
      url: "http://127.0.0.1:5100"
    }
  }
};

Compile the contract

npx hardhat compile

Deploy the contract

npx hardhat run scripts/sample-script.js
Greeter deployed to: 0x3FA91D0571e8C99A88A7155138293c691bf935bb

In this case, the hex string 0x3FA91D0571e8C99A88A7155138293c691bf935bb is our deployed contract address. This is what we will use when creating a Contract API in the FireFly Sandbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment