This project consists of three parts:
- Example Solidity contract
- Subgraph
- UI (dApp)
Follow the instructions in our Getting Started Guide to learn more about subgraphs and how to create one.
- This project is set up using
react-scripts - We use Prisma to mock a GraphQL server. Connection to the Prisma endpoint is achieved though Apollo Client in
src/apollo.js. - Example components can be found in
src/components/ - An example GraphQL schema can be found in
src/domain/schema.graphql
In order to run this project and get events from the blockchain, we need to install a couple of tools.
-
$ npm install -g truffle@beta(or$ yarn global add truffle@beta)
-
$ npm install -g ganache-cli(or$ yarn global add ganache-cli)
-
IPFS - please follow instructions in their docs
-
PostgreSQL - install Postgres and create a database for this project by running:
createdb scaffold
Open 7 terminal tabs, and follow the steps in each tab:
-
Run
$ ganache-cli -
Make sure you are inside of the ethereum folder and run
$ truffle compilefollowed by$ truffle migrate. Copy the contract address and paste it inside of thesubgraph.yamlunderaddress. -
Make sure you are inside of the ui folder and then you can run the following:
yarnto install dependenciesyarn startto serve the UI code on http://localhost:3000
-
Run
$ ipfs daemon -
Clone the
graph-noderepository from here -
Go to the
graph-noderepo that you cloned, and pull from the newestmasterbranch. 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.
- Make sure you are inside of the subgraph folder, and run
yarnfollowed byyarn create-subgraphand thenyarn deploy. It will deploy the subgraph tograph-nodeand watch for changes.
NOTE: You can find these instructions here too.
Copyright © 2018 Graph Protocol, Inc.
Licensed under the MIT License.