/hackathon-scaffold

A starting point for building dApps on The Graph

Primary LanguageJavaScript

Hackathon scaffold project

This project consists of three parts:

  • Example Solidity contract
  • Subgraph
  • UI (dApp)

Subgraph

Follow the instructions in our Getting Started Guide to learn more about subgraphs and how to create one.

UI

Installation

In order to run this project and get events from the blockchain, we need to install a couple of tools.

  1. Truffle:

    • $ npm install -g truffle@beta (or $ yarn global add truffle@beta)
  2. Ganache

    • $ npm install -g ganache-cli (or $ yarn global add ganache-cli)
  3. IPFS - please follow instructions in their docs

  4. PostgreSQL - install Postgres and create a database for this project by running:

    • createdb scaffold

Development

Open 7 terminal tabs, and follow the steps in each tab:

  1. Run $ ganache-cli

  2. Make sure you are inside of the ethereum folder and run $ truffle compile followed by $ truffle migrate. Copy the contract address and paste it inside of the subgraph.yaml under address.

  3. Make sure you are inside of the ui folder and then you can run the following:

  4. Run $ ipfs daemon

  5. Clone the graph-node repository from here

  6. Go to the graph-node repo that you cloned, and pull from the newest master branch. Run the following command using the subgraph ID from the previous step:

cargo run -p graph-node --release -- \
  --postgres-url postgresql://<USERNAME>@localhost:5432/scaffold \
  --ethereum-rpc <NETWORK_NAME>:http://127.0.0.1:8545 \
  --ipfs 127.0.0.1:5001 \
  --debug

Note: Try your OS username as <USERNAME> and anything except for the mainnet as <NETWORK_NAME> (for example, ganache or testnet)

This will spin up a GraphQL interface at http://localhost:8000 so you can run your queries against the blockchain.

  1. Make sure you are inside of the subgraph folder, and run yarn followed by yarn create-subgraph and then yarn deploy. It will deploy the subgraph to graph-node and watch for changes.

NOTE: You can find these instructions here too.

License

Copyright © 2018 Graph Protocol, Inc.

Licensed under the MIT License.