Code Monkey home page Code Monkey logo

dd2485-smart-contract-project's Introduction

BlockThoughts

logo

BlockThoughts is a chat forum service. A user can add their username, post threads and comment on other peoples threads. BlockThoughts is decentralized and data is stored on a blockchain. Specifically, the protocol is written in Solidity and can run on Ethereum compatible blockchains, however it is not deployed on mainnet yet. The repo contains a guide for deploying locally and hosting an example website to show how the protocol could be used in practice.

There have been many implementations of decentralized chat forums using peer-to-peer networks such as https://retroshare.cc/ and https://getaether.net/. However, a decentralized chat forum on a blockchain network has yet to be practically implemented. This is likely due to a variety of issues regarding gas fees and scalability.

Deploy locally

Start by cloning the repository and install all dependencies

git clone [email protected]:Osksacho/DD2485-Smart-Contract-Project.git
npm install

Now you can start a local blockchain using

npx hardhat node

In another terminal you can now compile and deploy the contract with the command (use network-name "localhost" to deploy on local blockchain).

npx hardhat compile
npx hardhat run scripts/deploy.js --network [network-name]

Tests and code coverage

You can run the tests and get a coverage report of 100% by using

npx hardhat coverage

Host website locally

There are a few extra steps here. First, to host the site locally you can go inte blockthoughts-site folder and

npm run dev

To interact with the local blockchain you will need to have metamask installed in your browser and add your localhost as the blockchain network

image

You will also need to copy one of the private keys of an address generated by the local hardhat chain and create an account on metamask. This account will be given 10000 ETH by default.

image

Finally, make sure that the contract address on the local blockchain is correctly specified in model.js. The ABI should be up to date.

image

Now you should be able to enter the site on http://127.0.0.1:5173/. Metamask will prompt you to allow access from the site.

Potential error

When signing a transaction, you might get an RPC error. This often happens after restarting the hardhat network. Fix this error by clearing activity in Metamask (clearing browser cache might also work)

image

dd2485-smart-contract-project's People

Contributors

osksacho avatar flaxxen avatar

Watchers

 avatar  avatar

dd2485-smart-contract-project's Issues

Smart contract data state

Create the state structure for data contained on chain. Including:

  • Wallet - userdata mapping
  • Thread - comment mapping
  • Something more?

The frontend webpage

  • User data view and model function
  • Posting and retrieving threads
  • Posting and retrieving comments
  • Optimize userdata? (can create a map that stores addresses usernames so you do not have to call getUserData for each thread/comment
  • Better error handling?
  • Create functionality for storing and retrieving data from IPFS
  • Add more stuff

Define JSON format for data

Decide on how the data located on IPFS should be structured. Includes:

  • User data
  • Thread data
  • Comment data

Suggestion for comment data;
{
"author_address": "0x2d711642b7...",
"message": "hey hows every1 doing",
"time": "2023-11-29T12:00:00Z"
}

Smart contract state modifiers

Create functions that are callable for commiting to the data state. Includes;

  • Register new user?
  • Create new thread
  • Create comment on thread

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.