- Quick Start Guide
Follow these instructions to get started with the Stellar Disbursement Platform (SDP).
- Docker: Make sure you have Docker installed on your system. If not, you can download it from here.
- Git: You will need Git to clone the repository. You can download it from here.
- Go: If you want to use the
make_env.sh
script to create Stellar accounts and a.env
file, you will need to have Go installed on your system. You can download it from here. - jq: If you want to use the
main.sh
script to bring up the local environment, you will need to havejq
installed. You can install it using Homebrew:
brew install jq
git clone https://github.com/stellar/stellar-disbursement-platform.git
This update is needed to simulate the multi-tenant capabilities of the SDP. The SDP uses the subdomain of the request URL to resolve the tenant.
Be sure that the added tenant hosts are included in the host configuration file.
To check it, you can run the command cat /etc/hosts
.
To include them, you can run command sudo nano /etc/hosts
and insert the lines below:
127.0.0.1 bluecorp.stellar.local
127.0.0.1 redcorp.stellar.local
127.0.0.1 pinkcorp.stellar.local
To automatically create Stellar accounts for SEP10 authentication and a distribution wallet, and to set up the necessary configuration values in a .env file, follow these steps:
- Navigate to the dev directory:
cd dev
- Run the make_env.sh script:
scripts/make_env.sh
The script will generate new keypairs with a USDC funded distribution account and create the .env file with the following configuration values. Example:
# Generate a new keypair for SEP-10 signing
SEP10_SIGNING_PUBLIC_KEY=GCRSCJEVHB5JFXNZH3KYQRHSKDX3ZRFMMPKDPNX7AL3JSXJSILTV7DEW
SEP10_SIGNING_PRIVATE_KEY=SBEZHHWE2QPBIKNMVHPE5QD2JUUN2PLYNEHYQZZPQ7GYPYWULDTJ5RZU
# Generate a new keypair for the distribution account
DISTRIBUTION_PUBLIC_KEY=GBKLZHYBZR5HN6EBF5FP3A7ROMLUVWJPOWM6ZUUBB5JCK5LCIRCG65Q6
DISTRIBUTION_SEED=SDDWY3N3DSTR6SNCZTECOW6PNUIPOHDTMLKVWDQUTHLRNIKMAUIT46M6
# CHANNEL_ACCOUNT_ENCRYPTION_PASSPHRASE
CHANNEL_ACCOUNT_ENCRYPTION_PASSPHRASE=SDDWY3N3DSTR6SNCZTECOW6PNUIPOHDTMLKVWDQUTHLRNIKMAUIT46M6
# Distribution signer
DISTRIBUTION_ACCOUNT_ENCRYPTION_PASSPHRASE=SDDWY3N3DSTR6SNCZTECOW6PNUIPOHDTMLKVWDQUTHLRNIKMAUIT46M6
To spin up all necessary Docker containers and provision sample tenants.
cd dev
./main.sh
Note
In the following section, we will assume you're using the bluecorp
tenant that was provisioned when you ran main.sh
.
The main.sh setup script will print Login information for each tenant.
ππππ SUCCESS! ππππ
Login URLs for each tenant:
πTenant `redcorp`: [http://redcorp.stellar.local:3000](http://redcorp.stellar.local:3000)
username: `[email protected]`
password: `Password123!`
πTenant `bluecorp`: [http://bluecorp.stellar.local:3000](http://bluecorp.stellar.local:3000)
username: `[email protected]`
password: `Password123!`
πTenant `pinkcorp`: [http://pinkcorp.stellar.local:3000](http://pinkcorp.stellar.local:3000)
username: `[email protected]`
password: `Password123!`
-
Navigate to the SDP frontend service by opening a browser and going to http://bluecorp.stellar.local:3000.
-
Create First Disbursement
- Click
New Disbursement+
on the Dashboard screen. You should see a funded distribution account ready for your disbursement. - Use
Demo Wallet
as your wallet and choose a verification method. - Select
United States
as the Country. - Select
Date of Birth
as the verification method.
- Click
-
Create and Upload a Disbursement File
- A sample file template is available sample-disbursement.csv.
- Make sure to update the invalid phone numbers before using it.
- Here is an example of a disbursement file with a single payment:
phone,id,amount,verification +13163955627,4ba1,.1,1987-12-01
-
In this example, when registering, the payment receiver will be asked to verify their phone number and date of birth which will need to match the payment file instructions.
-
Upload the CSV and then click the Review button. When you are ready to start the disbursement, click the
Confirm disbursement
button.
-
View the Disbursement Details Dashboard
Navigate to Disbursement Details and see the payment in the disbursement is currently in a
Ready
state. This means the receiver has yet to accept the invitation and deposit the funds.
Now deposit the disbursement payment into the digital wallet using the SEP-24 deposit flow from the Wallet Client Wallet to SDP.
-
Access locally installed demo-wallet in your browser.
-
Click on
Generate Keypair for new account
to generate a new keypair. Make sure to save your public key & secret if you want to use this account later. -
Click
Create account
(in front of public key) to actually create the account on the Stellar testnet. -
Your newly created account will have 10,000 XLM.
-
Add
USDC
by clickingAdd from preset assets
link, selecting theUSDC
Checkbox and clickingOverride Home Domain
to edit the home domain. Enterhttp://bluecorp.stellar.local:8000
and click theConfirm
button. -
Click the
Add trustline
link next to theSelect Action
dropdown. -
In the
USDC
Select action
dropdown, selectSEP-24 Deposit
and then click theStart
button. -
In the new window, enter the phone number
+13163955627
from the disbursement CSV payment. -
To verify the payment, enter the passcode and date of birth. You can use
000000
passcode or find the actual passcode in thesdp-api
container logs. -
The SEP-24 interactive pop-up will confirm the registration was successful. At this point, the SDP can associate the wallet address with the receiver phone number. It should then start processing the transaction to send the payment. If you check the dashboard, the payment should be in a
PENDING
state. -
Once complete, the payment status will be
Success
and your wallet will have the USDC.
You need to create and configure two Stellar accounts to use the SDP. You can either create the accounts manually use the provided script to automate the process.
Option 1: Manually Create and Configure Accounts
- Create and fund a Distribution account that will be used for sending funds to receivers. Follow the instructions here.
- Create a SEP-10 account for authentication. It can be created the same way as the distribution account but it doesn't need to be funded.
- Create a
.env
file in thedev
directory by copying the env.example file:cp .env.example .env
- Update the
.env
file with the public and private keys of the two accounts created in the previous steps.
Option 2: Use make_env.sh script to create accounts and .env file
You can use the make_env.sh script to automatically create a stellar accounts for SEP-10 authentication and a funded (XLM and USDC) Stellar distribution account. To run the make_env.sh script:
- Use make_env.sh script to create stellar accounts and .env file automatically:
- Navigate to the
dev
directory from the terminal:
cd dev
- Run the
make_env.sh
in thescripts
folder.
You should see output as follows:scripts/make_env.sh
β― scripts/make_env.sh ====> π Checking if .env environment file exists in <REPO_ROOT>/stellar-disbursement-platform-backend/dev .env file does not exist. Creating Generating SEP-10 signing keys... Generating distribution keys with funding... .env file created successfully ====> β Finished .env setup
- Navigate to the
A main.sh wrapper script has been included to help you bring up a local environment. The script stops and removes existing Docker containers, optionally deletes persistent volumes, and then uses Docker Compose to bring up new containers for the Stellar Disbursement Platform (SDP). This includes the SDP, Anchor Platform (for user registration), PostgreSQL database, Kafka for event handling, and a local demo wallet instance. It then initializes tenants if they don't exist and adds test users, setting up the local environment for the SEP-24 deposit flow.
- Execute the following command to create all the necessary Docker containers needed to run SDP as well as provision sample tenants:
./main.sh
This will spin up the following services:
sdp_v2_database
: The main SDP and TSS database.anchor-platform-postgres-db
: Database used by the anchor platform.anchor-platform
: A local instance of the anchor platform.sdp-api
: SDP service running on port8000
.sdp-tss
: Transaction Submission service.sdp-frontend
: SDP frontend service running on port3000
.demo-wallet
: The demo wallet client that will be used as a receiver wallet, running on port4000
.
Using Kafka for event handling is optional. If you want to use Kafka, you can start the Kafka service by running the following command from the dev
directory:
docker compose -p sdp-multi-tenant -f docker-compose.yml -f docker-compose-kafka.yml up -d
This will start the following containers on top of the ones listed above:
kafka
: Kafka service running on ports9092
,9094
(external).kafka-init
: Initial workflow to exec into the Kafka container and create topics.
To help collaborators debug remotely against the Docker containers, the environment started with main.sh
also launches a development version of the Dockerfile (Dockerfile-development
). This builds and runs a debug Docker container for the SDP. A sample launch.json is provided.
Follow these steps to debug remotely using VS Code or IntelliJ GoLang:
Make sure the Docker containers are up and running by executing the main.sh
script:
./main.sh
- Open the Project in VS Code:
- Place the
launch.json
file in the.vscode
directory within your project. A samplelaunch.json
is available here. - Open the Debug panel by clicking on the Debug icon in the Activity Bar on the side of VS Code.
- Select the
DEBUG SDP-API
configuration (as configured in the sample launch.json) from the dropdown. - Click the green play button or press
F5
to start debugging.
-
Open the Project in IntelliJ: Open your project in IntelliJ.
-
Configure Remote Debugging:
- Go to
Run
>Edit Configurations
. - Click on the
+
icon and selectGo Remote
. - Fill in the configuration details:
- Name: DEBUG SDP-API
- Host: 127.0.0.1
- Port: 2345
- Package path: (your project path)
- Mode: remote
- Remote Path: /app/github.com/stellar/stellar-disbursement-platform
- Local Path: /${workspaceFolder}/stellar-disbursement-platform-backend
- Go to
The debugger should now attach to the running Docker container, and you should be able to hit breakpoints and debug your code.
The SDP supports monitoring via Prometheus and Grafana.
The containers can be started by running the following command from the dev
directory:
docker compose -p sdp-multi-tenant -f docker-compose-monitoring.yml up -d
This will start the following services:
prometheus
: Prometheus service running on port9090
.grafana
: Grafana service running on port3002
.
- Access the Grafana dashboard by opening a browser and going to http://localhost:3002.
- Log in with the default credentials:
- Username:
admin
- Password:
admin
- Username:
- Click on the
+
icon on the left sidebar and selectImport Dashboard
. - Copy the contents of the dashboard.json file and paste it into the
Import via dashboard JSON model
text box.
A sample Postman collection is available in the sample
directory. It contains endpoints for managing tenants, authentication, and other operations. You can import SDP.postman_collection.json
into Postman to easily interact with the API.
Making payments requires transaction fees that are paid in XLM from the distribution account. Payments will start failing if the distribution account does not have enough XLM to pay for these fees. To check this:
- Find the distribution account public key in
dev/docker-compose.yml
under the variableDISTRIBUTION_PUBLIC_KEY
- Access https://horizon-testnet.stellar.org/accounts/:accountId in your browser and check the balance.
- You could also check the balance using demo wallet
- If the balance is indeed low, here are some of the options to add additional XLM to the distribution account:
-- from the dev
directory run the create_and_fund.go script and specify an existing account using the --secret
option to specify the account secret key and the --fundxlm` option to add additional xlm via friendbot. Note: you will need to install golang. example:
./go run scripts/create_and_fund.go --secret SECRET_KEY --fundxlm
-- Create a new funded account via Demo Wallet website and send funds to the Distribution account.
- Access https://demo-wallet.stellar.org/ in your browser.
- Click on
Generate Keypair for new account
to create a new testnet account. Your account comes with 10,000 XLM. - Click on
Send
and enter the distribution account public key and the amount you want to send. - Using Freighter or Stellar Laboratory, swap the XLM for USDC if you wish to test with USDC.
- Just use the newly created account (with 10,000 XLM) as the distribution account by updating the
DISTRIBUTION_PUBLIC_KEY
variable indev/docker-compose.yml
and restarting thesdp-api
container.