/hedera-hcs-chat-js

An example chat application, which uses the Hedera Consensus Service for pub-sub messaging.

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Hedera Consensus Service Chat Tutorial

An example web app which demonstrates how you can use decentralized pub-sub messaging on the Hedera Consensus Service.

UI]

Estimated set up is ~10 minutes. If it takes you longer or issues arise, please reach out!

Built With

Contributors & maintainers

I'd love your help supporting, growing, and improving this application. Seriously!

If you have any ideas please get in touch or file a pull request.

Prerequisites

This demo assumes that you have an account on the Hedera Testnet. For example:

ACCOUNT_ID=0.0.123456789

PUBLIC_KEY=302a300506032b657003210013d392c9ebcf942a3c4ca165e6ee7721df293960001dfe0c347ea8542ef6c4a4

PRIVATE_KEY=302e020100300506032b657004220420f4361ec73dc43e568f1620a7b7ecb7330790b8a1c7620f1ce353aa1de4f0eaa6

If you don't have one yet, sign up at portal.hedera.com.

Getting Started

You can clone this repository by running the following command:

git clone https://github.com/Cooper-Kunz/hello-hedera-chat-js.git

Create a .env file in the root of the project.

Then and add your Testnet account info to the .env file, like below:

ACCOUNT_ID=0.0.123456789

PUBLIC_KEY=302a300506032b657003210013d392c9ebcf942a3c4ca165e6ee7721df293960001dfe0c347ea8542ef6c4a4

PRIVATE_KEY=302e020100300506032b657004220420f4361ec73dc43e568f1620a7b7ecb7330790b8a1c7620f1ce353aa1de4f0eaa6

After downloading and setting up our environment, we'll install our packages via npm.

npm install

If installing the dependencies was succesful, now try to run the server!

node server.js

After running your server, it will prompt you to configure your chat, e.g.

1. What mode do you want to run in?  <--- "Default", "Minimal", "Debug"
2. What's your account ID?           <---  defaults to the .env schema
3. What's your private key?          <---  defaults to the .env schema
4. Should we create a new HCS topic, or connect to an existing one?

Set up If everything was configured properly, the chat should now open at a random port location.

You can additionally run another instance of the chat application by creating a new terminal, and running the application again. This will find another unused, random port location, and deploy multiple instances to your local machine. With the environment configurability, you can test out multi-client chats.

Disclaimer

This is just a simple demo application. Please use responsibly.

Contact me if you need anything, or file an issue if you see problems.

LICENSE

Apache 2.0