seaiam / NLPeace

NLPeace is a social networking app available both on desktop and mobile. We aim to connect people and foster a safe environment free of hate and offensive content. We are leveraging natural language processing to build a strong language model that will allow for our content moderation to be automatic. Hateful content is thus nipped at the bud.
MIT License
1 stars 0 forks source link

Implementing backend chat app on Ethereum blockchain #356

Closed nellyb4 closed 7 months ago

nellyb4 commented 8 months ago

Priority: High Risk: Low Story points: 8

User should be able to message another user on the Ethereum blockchain whilst still being able to enjoy the moderation benefits of the main platform.

jeffrey-w commented 7 months ago

Demo Steps

This requires nodejs and the ganache-cli and truffle packages installed globally:

npm i -g ganache-cli truffle
  1. Navigate to the blockchain-chat/backend directory
  2. Enter the command ganahce-cli to start a private blockchain.
  3. In a new terminal at the same directory, deploy the Chat smart contract truffle deploy --network development
  4. Enter the command truffle console --network development to acquire a command line interface to the deployed contract.
  5. Create a new chat, where <blockchain account> should be one of the ten "Available Accounts" listed on the ganache-cli terminal, and <contract account> is the address to which the Chat smart contract was deployed to, listed after the command from step 3.
    web3.eth.sendTransaction({from: <blockchain account>, to: <contract account>, data: web3.eth.abi.encodeFunctionCall({name: "create", type: "function", inputs: []}, []), gas: 1000000})
  6. Send a new message to the chat:
    web3.eth.sendTransaction({from: <blockchain account, to: <contract account>, data: web3.eth.abi.encodeFunctionCall({name: "put", type: "function", inputs: [{name: "id", type: "uint256"}, {name: "message", type: "string"}]}, [0, "hi"]), gas: 1000000})
  7. You can also retrieve a message from a chat by index, the address of the person who sent it, the timestamp of a message, or the number of messages made to a given chat.
  8. Exit the truffle console and ganche-cli with Ctrl-C.
  9. Uninstall the previously installed npm packages: npm uninstall -g ganache-cli truffle
  10. A rough sketch of how this interface might be used by a front end (see #357 ) is as follows
    count = web3.call(getCount, [id])
    for i = 1 to count
    sender = web3.call(getSender, [id, i])
    message = web3.call(getMsg, [id, i])
    timestamp = web3.call(getTime, [id, i])
    displayMessage(sender, message, timestamp)