AbhyasKanaujia / decentagram

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Decentagram

This project is being done according to a tutorial by dapp university

Instagram

  • Instagram has a single web sever that hosts all the files.
  • The people who control instagram have full control over the plaform.
  • They can censor content and make specific conetet surface to more users.

Decentagram

  • Decentagram works on the blockchain
  • The files are stored in IPFS
  • There is a clear and transparent algorithm used to show content to the user.

Requirement for this Project

  1. Node.js. Used to install packages and run the client side application.
  2. Truffle Framework. A framework for creating etherium smart contract. Write, test and deploy.
  3. Ganache. Personal blockchain for testing.
  4. Metamask. Since browser do not directly connect to the blockchain, we use this to extend the browser.

Architecture of Decentagram

  • The use interacts using a web application and a crypto wallet.
  • The crypto wallet sends and gets data to the etherium blockchain.
  • The images are stored in the IPFS.

Initial Setup

  1. npx create-react-app .
  2. truffle init
  3. Configure truffle-config.js
  4. Install required packages:
    1. npm i bootstrap react-bootstrap identicon.js
    2. npm i chai chai-as-promised chai-bignumber
    3. npm i ipfs-http-client
    4. npm i truffle web3
    5. npm i -D gh-pages
  5. Add Migration.sol and 1_initial_migration.js
  6. Cleanup unnecessary files from react project
  7. Add Navbar component
  8. npm start Should show a working frontend

Testing if truffle is setup

  1. Create a new contract Decentagram.sol in contracts directory.
  2. Create a 2_deploy_contracts.js in migrations
  3. Launch Ganache
  4. $ truffle console
  5. > migrate --reset
  6. > decentagram = await Decentagram.deployed(). This should show the contract details in a JSON.
  7. > await decentagram.address returns the address of the contract

Testing a contract

  1. Add test.js in test
  2. $ truffle console
  3. > test
  • Testing is important.
  • Contracts are immuatble once deployed.

Events

  • This let's us know that something happened
  • We can subscribe to events externally in the application

About


Languages

Language:JavaScript 63.1%Language:Solidity 22.8%Language:HTML 13.2%Language:CSS 1.0%