{"id":19294594,"url":"https://github.com/web3-storage/example-forum-dapp","last_synced_at":"2025-04-22T08:30:34.745Z","repository":{"id":46280044,"uuid":"416396727","full_name":"web3-storage/example-forum-dapp","owner":"web3-storage","description":"An example of a decentralized forum app built with Web3.Storage and Ethereum","archived":true,"fork":false,"pushed_at":"2022-01-11T22:12:56.000Z","size":7406,"stargazers_count":38,"open_issues_count":0,"forks_count":23,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-12T22:42:37.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/web3-storage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-12T15:38:54.000Z","updated_at":"2024-10-14T14:36:39.000Z","dependencies_parsed_at":"2022-09-24T14:03:32.456Z","dependency_job_id":null,"html_url":"https://github.com/web3-storage/example-forum-dapp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3-storage%2Fexample-forum-dapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3-storage%2Fexample-forum-dapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3-storage%2Fexample-forum-dapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web3-storage%2Fexample-forum-dapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web3-storage","download_url":"https://codeload.github.com/web3-storage/example-forum-dapp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250205976,"owners_count":21392158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T22:38:50.503Z","updated_at":"2025-04-22T08:30:33.925Z","avatar_url":"https://github.com/web3-storage.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web3.Storage Forum dApp example\n\nThis repository contains an example of a decentralized application that uses [Web3.Storage](https://web3.storage) and [Ethereum](https://ethereum.org) to provide a simple online forum. \n\nAll post and comment content is stored on Filecoin and IPFS, while all ids and votes are stored in an Ethereum smart contract.\n\n![An animation showing a user posting a comment and a new post on the decentralized forum app.](./img/w3news.gif)\n\n## Install / Run\n\nThere's no long-lived deployment of the app yet, so you'll need to run in local development mode.\n\nYou'll need a recent version of Node.js and npm version 7 or greater.\n\n1. Clone this repo:\n\n   ```bash\n   git clone https://github.com/web3-storage/example-forum-dapp\n   ```\n\n2. Install dependencies:\n\n  ```bash\n  npm install\n  ```\n\n3. Run local blockchain and webapp server:\n\n  ```\n  npm run dev\n  ```\n\nLeave the last command running and open your browser to [http://localhost:3000](http://localhost:3000).\n\n### Setting up MetaMask\n\nTo interact with the app, you'll need an Ethereum wallet like [MetaMask](https://metamask.io) installed.\nYou'll also need to configure MetaMask to use the local HardHat development network. \n\nTo do that, open the MetaMask extension and go to `Settings -\u003e Network -\u003e Localhost 8545` and change the Chain ID input to `31337`.\n\n**Important**: if you've made any write transactions, the next time you restart the local blockchain you'll get an error about an incorrect nonce if you try to make a transaction on the new chain. This is because MetaMask still remembers the state of the old blockchain instance. To fix this, open MetaMask and go to `Settings -\u003e Advanced -\u003e Reset Account` and press the `Reset Account` button. This will not mess with your balances or any important state - it just clears out the stale history.\n\n### Getting play money\n\nWhen running in local development mode, there will be a `faucet` link in the header of the app. Click the link to have a small amount of devnet ETH deposited into your MetaMask wallet. You'll need to do this before performing any write operations (e.g. posting, commenting, voting, etc).\n\n## App overview\n\nThe app consists of a smart contract and supporting TypeScript code for interacting with the blockchain, along with a single-page web app, written in React.\n\nAt a high level, the app works like this:\n\nA [`Forum` smart contract][src-forum-sol] is deployed to an Ethereum network, which allows creating posts, commenting on them, and voting on posts and comments.\n\n### Items\n\nPosts and comments are represented internally as `Item` structs:\n\n```solidity\n  /**\n    * @notice Represents a single forum post or comment. \n    */\n  struct Item {\n    /// @notice what kind of item (post or comment)\n    ItemKind kind;\n\n    /// @notice Unique item id, assigned at creation time.\n    uint256 id;\n\n    /// @notice Id of parent item. Posts have parentId == 0.\n    uint256 parentId;\n\n    /// @notice address of author.\n    address author;\n\n    /// @notice block number when item was submitted\n    uint256 createdAtBlock;\n\n    /// @notice ids of all child items, with oldest items at front.\n    uint256[] childIds;\n\n    /// @notice IPFS CID of item content.\n    string contentCID;\n  }\n```\n\nEach `Item` has a `kind` field that can be either `ItemKind.POST` or `ItemKind.COMMENT`. Comments link to their parent post (or comment) using the `parentId` field, and parents keep a list of their children in the `childIds` field. When a new child commment is added, the parent's `childIds` is updated to include the new child.\n\nThe content of the post or comment is stored as a JSON file in IPFS and Filecoin using [Web3.Storage](https://web3.storage), and the file's CID is stored in the `contentCID` field.\n\nYou can retrieve a comment or post with the `getItem` contract function, passing in the item's id. You then need to fetch the content from IPFS and parse the JSON in order to render the complete item.\n\n### Voting\n\nAnyone can vote on a comment or post by calling either `voteForItem(itemId, voteValue)`  where `voteValue` is `-1` for a downvote, `+1` for an upvote, or `0` to retract a previous vote.\n\nEach account can only vote once for each post or comment - subequent votes replace the previous vote from that account.\n\nYou can retrive the vote total for a post or comment with `getItemScore(itemId)`, which returns the sum of all up and downvotes.\n\nTo get the \"karma\" or number of votes an author has recieved for their posts and comments, call `getAuthorKarma(author)`, passing in the author's address.\n\n\nSee [`packages/contract`](./packages/contract/README.md) for details about the smart contract.\nSee [`packages/webapp`](./packages/webapp/README.md) for details about the user interface.\n\n\n[src-forum-sol]: ./packages/contract/contracts/Forum.sol\n\n[ipfs-docs-cid]: https://docs.ipfs.io/concepts/content-addressing/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb3-storage%2Fexample-forum-dapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb3-storage%2Fexample-forum-dapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb3-storage%2Fexample-forum-dapp/lists"}