Skip to content

Blockternship/TheCommunityMind

 
 

Repository files navigation

The Community Mind

This is a PoC project to attemt to create an ethereum based smart contract backend for TheCommunityMind. The repo for the current project can be found here

Vision

My vision for this project is explained in this article.

Technologies

This project uses a number of different technologies that I am exploring in order to achieve my goal.

  • Solidity - The language used to develop smart contracts for the Ethereum network
  • Truffle - a suite of tools used to compile and develop smart contracts in Ethereum. These incude:
    • Drizzle - Enables redux like interfacing with smart contracts
    • Ganache - A one click blockchain for test purposes
  • TheGraph - Used to index events and enables queries of these events using GraphQl
  • React - Frontend will be written using react
  • Apollo - A connector used to wrap graphql queries in React components and inject responses as props

Set Up

Pre Installation

This project can be run locally but requires some quite complicated pre installations.

  1. Install Ganache - This is for your local development blockchain

  2. Install TheGraph node and dependencies - see Quick Start section

  3. Clone the repo

git clone https://github.com/Blockternship/TheCommunityMind.git
  1. Install packages
cd TheCommunityMind
npm install
cd mind-subgraph
npm install
cd ../client
npm install

Build and migrate contracts in the main fo

  1. Start up Ganache

  2. In the main folder TheCommunityMind compile and migrate contracts

truffle compile
truffle migrate

Deploying The Graph Subgraph

  1. Install modules in mind-subgraph folder
cd mind-subgraph
npm install
  1. Start IPFS in a fresh terminal
ipfs daemon
  1. Copy the address of the migtrated TheMind contract (should be printed to terminal) to the subgraph.yaml file under:
dataSources:
- kind: ethereum/contract
  name: TheMind
  source:
    address: ***
  1. Create a symlink between your build folder containing the contract json files and an abis folder
 ln -s ../build/contracts abis
  1. build and deploy subgraph to IPFS - This will produce an IPFS_HASH in the terminal
npm run build-ipfs
  1. Start a local Graph node - You need to be in the graph-node project which should have been cloned as part of step 2. See Running a Local Graph Node in the docs.
cargo run -p graph-node --release -- \
  --postgres-url postgresql://USERNAME[:PASSWORD]@localhost:5432/adchain-subgraph \
  --ethereum-rpc localhost:http://localhost:8545 \
  --ipfs 127.0.0.1:5001 \
  --subgraph IPFS_HASH

Note: 8545 should be the port your ganache blockchain is running on. Can be checked by going to settings in ganache.

  1. Visit the graphiql interface at http://127.0.0.1:8000/ where you can query your indexed events (There wont be any indexed events yet)

Running the client

  1. Install node modules in client folder
cd ../client
npm install
  1. Start the client
npm start
  1. You will need to have MetaMask installed and pointing to your local blockchain - see here

Status

The status of this project currently is a simple smart contract that allows users to ask a Question via a text input. All I currently aim to check is that the events are indexed and can be searched via the graphql interface. Give it a try.

I will be working to create a proper interface and integrate the graphql search into the frontend using Apollo.

Get Involved

Don't hesitate to get in touch if you want to get involved!

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 85.6%
  • HTML 8.8%
  • TypeScript 3.2%
  • CSS 2.4%