Head to https://www.originprotocol.com/developers to learn more about what we're building and how to get involved.
Just getting started with Origin? We recommend using Origin Box for development and testing on your local machine.
Origin Bridge Server
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.
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.
See the README for the API
- Python 3.5 or higher required
- Postgresql 9.3 or higher required
Mac OS specifics
Install build tools packages:
brew install automake autoconf libtool
Set Up A Virtual Environment
git clone https://github.com/OriginProtocol/origin.git && cd origin/origin-bridge python3 -m venv ve source ve/bin/activate pip install -r requirements.txt
Clone the Starter Configuration Variables
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.
FLASK_SECRET_KEY to your unique Flask secret key. Use a unique Flask secret key per environment. Flask suggests that
python -c "import os; print(os.urandom(24))"
is a perfectly reasonable way to generate a secret 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.
- TWILIO_VERIFY_API_KEY (Can be generated from your Twilio account)
When deploying to a production system, make sure to set appropriate environment variables, in your .env file, notably
DEBUG=0 HTTPS=1 HOST=<your-prod-host> FLASK_SECRET_KEY=<unique-key> PROJECTPATH=/app # For Heroku
Set Up Your Database
createdb <db-name> # Anything you want, perhaps bridge-server
Make sure the DB name you used is indicated in your
DATABASE_URL in the
# Applies all migrations to make the DB current. Works even on an empty database. # # Run this in the virtual environment you set up above. FLASK_APP=main.py flask db upgrade
Every Time You Develop
Set Up Your Shell
cd /path/to/environment/project source ../bin/activate export PYTHONPATH=.
It's handy to save bash alias for this. Consider adding in your
alias myenv='cd /path/to/environment/project && source ../bin/activate && export PYTHONPATH=.'
Run the Server
# Run this in the virtual environment you set up above. python main.py
This starts a development server on
localhost:5000 by default.
Run the Tests
Throughout the development process and before committing or deploying, run:
pytest --flakes --codestyle
Run individual test files simply as:
Run a single test case, or an individual test, using:
Problems? Hit us up in the
engineering channel on Discord if you need help.
We are using pycodestyle to enforce code formatting. The tests will throw errors when code is not formatted properly, when using the
To automatically format the code:
autopep8 --in-place --recursive --a --a .
Please send your pull requests to the
We use Flask Migrate to handle database revisions. If you make changes to the database, use
FLASK_APP=main.py flask db migrate
to generate the required migration file. Rename it to add a description of the change after the underscore. Then run
FLASK_APP=main.py flask db upgrade
to apply your migration to your local database, then test your changes before committing.
To deploy a development copy of the site on Heroku, just choose which branch you would like to use and follow the instructions:
Heroku will prompt you to set config variables. At a minium, you must set these three:
|FLASK_SECRET_KEY||(make something up)|
|HOST||(domain name of your dev heroku app)|
See dev.env for a full list of other optional config variables.
We use following buildpacks:
heroku buildpacks:set heroku/python
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.