The Origin Bridge Server connects the old world to the new.
Most traditional web APIs, such as those from Facebook and Twitter, can only interact with a centralized server located at a specific domain. A decentralized application, like our Origin Demo DApp, doesn't need to "live" on a particular server. (In fact, you can load it from any IPFS gateway!) Thus, in order for the DApp to use an "old world" API, it needs a Bridge Server.
Origin hosts a Bridge Server, but in the true spirit of decentralization, anyone is free to clone our open source code and host their own.
You can connect to and use our hosted Bridge Server at
bridge.originprotocol.com. The master
branch of this repo is available at
bridge.dev.originprotocol.com.
DApps can connect to the Bridge Server of their choosing in order to enable the following functionality which is either impossible or impractical to do directly onchain, including:
We need a centralized server that can handle tasks like issuing identity attestations and decryptying data that is returned from third-party services like Civic. We also need proxies for fetching public data from services like Facebook and Twitter which require authentication keys.
- Node 10 or higher required
- Postgresql 9.3 or higher required
cp dev.env .env
Adjust the values in .env now and in the future to suit your local environment.
For EnvKey support, set ENVKEY to the key of the generated local development key.
Set up your DATABASE_URL
to point to where you local database is or will be.
This is optional - only define these environment keys if you want to use your bridge server deployment as an endpoint for the DApp identity attestation functionality.
- Facebook
- FACEBOOK_CLIENT_ID
- FACEBOOK_CLIENT_SECRET
- Sendgrid
- SENDGRID_API_KEY
- SENDGRID_FROM_EMAIL
- Twilio
- TWILIO_VERIFY_API_KEY (Can be generated from your Twilio account)
- Twitter
- TWITTER_CONSUMER_KEY
- TWITTER_CONSUMER_SECRET
- Google
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
- KaKao
- KAKAO_CLIENT_ID
- KAKAO_CLIENT_SECRET
- GitHub
- GITHUB_CLIENT_ID
- GITHUB_CLIENT_SECRET
- LinkedIn
- LINKEDIN_CLIENT_ID
- LINKEDIN_CLIENT_SECRET
- WeChat
- WECHAT_CLIENT_ID
- WECHAT_CLIENT_SECRET
- Telegram
- TELEGRAM_BOT_TOKEN
If you plan on using different OAuth client for webhooks, you should set the following environment variables
- TWITTER_WEBHOOKS_CONSUMER_KEY
- TWITTER_WEBHOOKS_CONSUMER_SECRET
-
Go to
@BotFather
on Telegram -
Send the following command to create a new bot:
/newbot
Give a name and username when prompted. Note down the Bot Token once the bot is created. -
Enter the command
/mybots
to list all your bots and select the bot you created in the previous step. -
Add the bot you created to the group as an admin.
Note: You can add the bot to as many groups as you want. Events from all the groups will be posted to the webhook endpoint
-
Add the following env variables to the DApp during build time or export it on the terminal:
TELEGRAM_BOT_USERNAME=<YOUR BOT USERNAME>
-
Add the following env variables to bridge server's ENVKEY or export it on the terminal:
TELEGRAM_BOT_TOKEN=<YOUR BOT TOKEN HERE>
-
Create a web tunnel for bridge server. Refer
@origin/bridge
's README.md -
Hit the following URL on your browser:
http://localhost:5000/hooks/telegram/__init
npm run migrate
Make sure the DB name you used is indicated in your DATABASE_URL
in the .env
file. Example: DATABASE_URL
=postgresql://localhost:5432/bridge-server
npm run start
This starts a development server on localhost:5000
by default.
You need to setup a tunnel to localhost:5000 to work with Twitter Activity API and its webhooks.
-
To spin up a tunnel with
ngrok
:ngrok http 5000
-
Copy the tunnel host that
ngrok
prints and set that toWEBHOOK_TUNNEL_HOST
environment variable. -
Kill and restart the bridge server (to pick up the environment vairable change)
-
To destroy and recreate webhooks and subscriptions with the new tunnel host, go to the following URLs in a browser and authorize your account
-
Twitter:
http://localhost:5000/hooks/twitter/__init
Note: The twitter account you authorize should be same as
TWITTER_ORIGINPROTOCOL_USERNAME
-
Telegram:
http://localhost:5000/hooks/telegram/__init
If everything is successful, you will see the following JSON printed in your browser window for each of the these URLs
{ "success": true }
-
Throughout the development process and before committing or deploying, run:
npm run test
We use prettier to enforce code formatting. You can automatically format code by running:
npm run prettier
Please send your pull requests to the master
branch.
Origin is an 100% open-source and community-driven project and we welcome contributions of all sorts. There are many ways to help, from reporting issues, contributing code, and helping us improve our community.
To get involved, please join our Discord channel and review our guide to contributing.