Skip to main content

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

  1. pip install django-polaris
  2. Add "polaris" to INSTALLED_APPS in settings.py
  3. Define PROJECT_ROOT in your project's settings.py. Polaris uses this to find your .env file.
  4. 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"
    
  5. In your urls.py, add path("", include(polaris.urls)) to urlpatterns.
  6. Run migrations: python manage.py migrate
  7. 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.

  1. Go to the Stellar laboratory account creator.
  2. Click the button to "Generate keypair." This is the distribution account.
  3. Fund the account: copy-paste the value of the Public Key (G...) into the Friendbot input box.
  4. Click "Get test network lumens." You have now funded a Stellar account!
  5. Open your virtual environment file, PROJECT_ROOT/.env.
  6. Set STELLAR_DISTRIBUTION_ACCOUNT_SEED to the value of Secret Key from the Keypair Generator.
  7. Go back to the account creator, and create and fund another Stellar account. This is the issuer account.
  8. Set STELLAR_ISSUER_ACCOUNT_ADDRESS to the value of Public Key that you just funded.
  9. 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.
  10. 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

To test:

pipenv run python polaris/manage.py collectstatic --no-input
pipenv run pytest

Note: collectstatic removes some files and generates others. Make sure these changes don't make it into your PR. You can remove the files generated using:

pipenv run python polaris/manage.py collectstatic --clear

Project details


Release history Release notifications | RSS feed

This version

0.9

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-polaris-0.9.tar.gz (41.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page