GUN: Create a Decentralized Chat App with GUN and IPFS
Learn how to create a decentralized chat app with GUN and IPFS.
Last updated
Learn how to create a decentralized chat app with GUN and IPFS.
Last updated
GUN is a series of open-source tools that includes a decentralized database service that uses peer-to-peer networks to store relational databases and their associated information. GUN can be used to build decentralized versions of hundreds of popular websites, like Youtube, Github, Reddit, and Slack.
Read below to learn how to create a decentralized chat app with GUN and IPFS.
To do this, navigate to console.filebase.com. If you don’t have an account already, sign up, then log in.
Select ‘Create Bucket’ in the top right corner to create a new bucket.
Bucket names must be unique across all Filebase users, be between 3 and 63 characters long, and can contain only lowercase characters, numbers, and dashes.
Set up a credentials file for S3FS at ${HOME}/.passwd-s3fs
. You will need to save your Filebase Access and Secret keys to this file and give it owner permissions. You can do so with the following commands:
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ${HOME}/.passwd-s3fs
chmod 600 ${HOME}/.passwd-s3fs
ACCESS_KEY_ID is your Filebase Access key, and SECRET_ACCESS_KEY is your Filebase Secret key. For more information on Filebase access keys, see here.
You can mount a Filebase IPFS bucket with the command:
s3fs mybucket /path/to/mountpoint -o passwd_file=${HOME}/.passwd-s3fs -o url=https://s3.filebase.com
mybucket: name of your Filebase bucket
/path/to/mountpoint
cd /path/to/mountpoint
git clone https://github.com/fireship-io/gun-chat.git
cd gun-chat
npm install
npm run dev
localhost:5000
. Your app will appear and look like this:localhost:5000
, and create another user with a different name and password, then select ‘Sign up’ again.Enter some chat messages in both windows to see the chat propagate in both windows!
You now have a decentralized chat app that uses a decentralized database, GUN, that is pinned on IPFS!