A SEP-24-compliant Django anchor server
Project description
Django-Polaris
This project is a WIP reusable django app implementing SEP 24. It is intended to act as a reference implementation for prospective anchors or used in production within an existing Django project. The stellar-anchor-server is an example Django project that uses this this package.
IMPORTANT DISCLAIMER: This code should not be used in production without a thorough security audit.
Installation
pip install django-polaris
- Add
"polaris"
toINSTALLED_APPS
in settings.py - Define
PROJECT_ROOT
in your project'ssettings.py
. Polaris uses this to find your.env
file. - Paste the text below into
PROJECT_ROOT/.env
. The stellar-anchor-server repository contains instructions for modifying this file to fit your use case.DJANGO_SECRET_KEY="secretkeykeysecret" DJANGO_DEBUG=True STELLAR_DISTRIBUTION_ACCOUNT_SEED="SCHTHF3N4SHEQM25M43FJ43UTCZP6OO3JKYVJCJBZ4YW6KVVAGC2OUCT" STELLAR_ISSUER_ACCOUNT_ADDRESS="GCTVATNFP4FYKZ7BXZ3EOPVKEL2DGDCB2AVBDUNLW7NYR7REF5PMKY4V" # STELLAR_NETWORK_PASSPHRASE can either be "Test SDF Network ; September 2015" or # "Public Global Stellar Network ; September 2015" or a custom passphrase # if you're using a private network. STELLAR_NETWORK_PASSPHRASE="Test SDF Network ; September 2015" # HORIZON_URI can point to a custom Horizon URI. It currently points # to the testnet URL. HORIZON_URI="https://horizon-testnet.stellar.org/" SERVER_JWT_KEY="secret"
- In your
urls.py
, addpath("", include(polaris.urls))
tourlpatterns
. - Run migrations:
python manage.py migrate
- Run the server:
python manage.py runserver
Before running the project
As an anchor, you need setup your stellar accounts for asset issuance and distribution and configure your server to use these accounts. The following instructions outline how to do this on the testnet.
- Go to the Stellar laboratory account creator.
- Click the button to "Generate keypair." This is the distribution account.
- Fund the account: copy-paste the value of the Public Key (G...) into the Friendbot input box.
- Click "Get test network lumens." You have now funded a Stellar account!
- Open your virtual environment file,
PROJECT_ROOT/.env
. - Set
STELLAR_DISTRIBUTION_ACCOUNT_SEED
to the value ofSecret Key
from the Keypair Generator. - Go back to the account creator, and create and fund another Stellar account. This is the issuer account.
- Set
STELLAR_ISSUER_ACCOUNT_ADDRESS
to the value ofPublic Key
that you just funded. - Now, run this script, using the issuer seed and distribution seed of the accounts just created. You can decide the name of your asset and amount to issue. This will issue an asset and send some amount of that asset to the distribution account.
- Finally, modify the
SERVER_JWT_KEY
to a more secure phrase for more secure SEP-10 authentication.
Contributing and Testing
To set up the development environment:
pip install pipenv
git clone https://github.com/stellar/django-polaris.git
cd django-polaris
pipenv install --dev
Git Flow
At the time of writing this, the latest public release is v0.9. After each release, a new development branch is created for the next upcoming release. In this case, that is 0.9.1.dev. Follow the instructions below to submit a valid pull request.
- Checkout the current development branch (0.9.1.dev) (
git checkout
) - Create a new branch based off the latest dev branch (
git checkout -b
) - Make your changes (
git add .; git commit -m
) - Push your changes to a new remote branch matching your local branch (
git push --set-upstream origin
) - Create a pull request based off the current dev branch
- If the latest dev branch has changed, rebase your branch on the new dev branch (
git fetch; git rebase
)
- If the latest dev branch has changed, rebase your branch on the new dev branch (
Testing
pipenv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.