Decentagram
This project is being done according to a tutorial by dapp university
- 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
- Node.js. Used to install packages and run the client side application.
- Truffle Framework. A framework for creating etherium smart contract. Write, test and deploy.
- Ganache. Personal blockchain for testing.
- 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
npx create-react-app .
truffle init
- Configure truffle-config.js
- Install required packages:
npm i bootstrap react-bootstrap identicon.js
npm i chai chai-as-promised chai-bignumber
npm i ipfs-http-client
npm i truffle web3
npm i -D gh-pages
- Add Migration.sol and 1_initial_migration.js
- Cleanup unnecessary files from react project
- Add Navbar component
npm start
Should show a working frontend
Testing if truffle is setup
- Create a new contract Decentagram.sol in contracts directory.
- Create a 2_deploy_contracts.js in migrations
- Launch Ganache
- $
truffle console
- >
migrate --reset
- >
decentagram = await Decentagram.deployed()
. This should show the contract details in a JSON. - >
await decentagram.address
returns the address of the contract
Testing a contract
- Add test.js in test
- $
truffle console
- >
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