Skip to content

Instantly share code, notes, and snippets.

@nickgaski
Last active June 22, 2021 17:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickgaski/0bbe5228c2639147757315347d0f3a83 to your computer and use it in GitHub Desktop.
Save nickgaski/0bbe5228c2639147757315347d0f3a83 to your computer and use it in GitHub Desktop.

Getting Started on FireFly

FireFly CLI

Let's start by downloading the FireFly CLI. This provides you with a straightforward interface for standing up a local FireFly stack.

References and Dependencies

  • CLI Repo README
  • Go - latest version recommended (v1.16.5)
    • If you haven't installed Go previously, make sure to add to your $PATH env variable - $HOME/go/bin
  • Docker - the CLI will download the requisite FireFly images and bootstrap a collection of containers (Ethereum adapter, FireFly Core, IPFS, local Ganache blockchain, postgres, etc.)

Get the CLI

  • On Go 1.16 or newer
    • go install github.com/hyperledger-labs/firefly-cli/ff@latest
  • On earlier versions of Go
    • go get github.com/hyperledger-labs/firefly-cli/ff

Starting the CLI

  • First, check that it is installed on your machine: ff -h this should expose the various exercisable commands and flags.
  • Standing up your first stack:
    • Make sure you have Docker running
    • In your terminal run the following command - ff init [stack_name]. For example, ff init dev1.
    • You will be prompted to select the number of members in your system. Choose 3
    • Now start the FireFly stack by running - ff start [stack_name]. For example, ff start dev1.
    • Be patient on this step. The CLI is downloading the various images encapsulated within a FireFly node and starting the corresponding containers. This may take a couple of minutes.
    • Once the system is running, you will be able to access an interactive Swagger interface for each membership on ports 5000, 5001 and 5002 respectively. These will be enumerated in your terminal session.

FireFly Samples

This repository contains two straightforward, turnkey samples. A simple CLI-based flow, and a more robust flow with a React frontend, with the option for customized recipients and messaging strings.

  • FireFly Samples Repo
    • clone this ^^
  • Node.js - latest version recommended (v14.17.0)
    • node -v to check your current version
  • Install the node dependencies in each folder: (/firefly-samples/private-data-transfer-cli & /firefly-samples/private-data-transfer-ui) with npm install.
  • The following command: npm run start will kick either program. Run the command separately from the root of each project.
    • The "Private-Data-Transfer-Cli" will self execute with a message broadcast and acknowledgement of message receipt.
    • The "Private-Data-Transfer-UI" will serve locally on port 3000. You can toggle amongst your FireFly memberships to see different message/transaction details - timestamp, sender and inputs.

HTTPS Data Exchange App

  • Data Exchange Repo
    • clone this ^^
  • Node.js - latest version recommended (v14.17.0)
    • node -v to check your current version
  • Visual Studio
  • From the root of the project - install the dependencies - npm i and then build - npm run build
    • Behind the scenes this will create two members - Member-A & Member-B and generate associated PKI artifacts.
  • Open your Visual Studio IDE and import the project after you've built the dependencies.
  • Kick off the available programs for Member-A & Member-B
  • Member-A’s interactive Swagger is accessible locally on port 3000
  • Member-B’s interactive Swagger is accessible locally on port 4000

If you see “Unauthorized” responses within the Swagger instance or through a REST client, be sure to update the API key value:

  • In Swagger - click “Authorize” at the top of the screen and input xxxxx as the api key for Member-A.
  • In Swagger - click "Authorize" at the top of the screen and input yyyyy as the api key for Member-B.
  • Via a REST client - create an x-api-key header with xxxxx as the value for Member-A.
  • Via a REST client - create an x-api-key header with yyyyy as the value for Member-B.

Helpful tips/FAQs

  • "My CLI didn't fully initialize."
    • No problem. Try stopping and restarting your stack. ff stop [stack_name] followed by `ff start [stack_name]
  • "How do I see the core components running in my FireFly stack?"
    • Take a peek at your currently running Docker containers. docker ps
  • "How do I see additional transaction details?"
    • Tail the logs for your FireFly Eth_Connect container that is owned by your first member (i.e. the entity submitting transactions). For example - docker logs -f dev1_ethconnect_0_1. This will expose transaction hashes and the accompanying JSON/RPC methods that are exercised for Ethereum transaction submission.
  • "I'm running the HTTPS Data Exchange Application and seeing Unauthorized errors in my Swagger/REST client."
    • You just need to input the following - xxxxx or yyyyy - as the API key value for Member-A and Member-B respectively.
  • "None of this is working on my machine!"
    • No problem. Just let us know in the chat or audio. This session has all of the core engineers that built and maintain the FireFly project. We're here to help and more than happy to hop into a smaller breakout room to help with debug.
  • "This is cool, but I'd like to talk at a more high level about my use case and business requirements."
    • Great. Just let us know in the chat or audio, and we'll arrange a time to talk with you in more detail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment