Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ============================================================
# StellarSettle – Deployment environment variables
# Copy this file to .env and fill in your values.
# NEVER commit your real .env file to version control.
# ============================================================

# ----- Stellar network -----
# Use "testnet", "mainnet", or "futurenet"
STELLAR_NETWORK=testnet

# ----- Deployer identity -----
# Secret key of the account that signs and pays for deployment.
# Starts with 'S' (e.g. SXXXXX…)
STELLAR_SECRET_KEY=SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# Public key matching STELLAR_SECRET_KEY (starts with 'G').
# Used as the admin address for all contracts.
ADMIN_PUBLIC_KEY=GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# ----- Platform fee -----
# Fee in basis points (100 bps = 1%). Default: 300 = 3 %
PLATFORM_FEE_BPS=300

# ----- Invoice Token metadata -----
# Human-readable name for the SEP-41 invoice token
INVOICE_TOKEN_NAME="StellarSettle Invoice Token"

# Ticker symbol for the invoice token (max 12 chars recommended)
INVOICE_TOKEN_SYMBOL=SSINV

# Decimal places for the invoice token (7 matches Stellar native asset)
INVOICE_TOKEN_DECIMALS=7

# Invoice identifier used when initialising the token contract.
# Must be a valid Soroban Symbol (≤32 chars, alphanumeric + underscore).
INVOICE_TOKEN_INVOICE_ID=INV001

# ----- WASM build output paths -----
# Relative to the repo root (adjust if you use a custom release profile).
WASM_INVOICE_ESCROW=target/wasm32-unknown-unknown/release/invoice_escrow.wasm
WASM_INVOICE_TOKEN=target/wasm32-unknown-unknown/release/invoice_token.wasm
WASM_PAYMENT_DISTRIBUTOR=target/wasm32-unknown-unknown/release/payment_distributor.wasm

# ----- (Optional) Pre-deployed contract IDs -----
# Leave blank to let the scripts deploy fresh contracts.
# If set, the deploy step is skipped and only `initialize` is called.
INVOICE_ESCROW_CONTRACT_ID=
INVOICE_TOKEN_CONTRACT_ID=
PAYMENT_DISTRIBUTOR_CONTRACT_ID=
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ tarpaulin-report.html
debug/

# Maintainer-only GitHub issue tooling (not published)
/scripts/
# NOTE: /scripts/ is intentionally NOT ignored – deployment scripts are public.
80 changes: 64 additions & 16 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,10 @@ soroban contract build
```

### Deployment
```bash
# Deploy to testnet
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/invoice_escrow.wasm \
--source YOUR_SECRET_KEY \
--network testnet

# Initialize contract
soroban contract invoke \
--id CONTRACT_ID \
--source YOUR_SECRET_KEY \
--network testnet \
-- initialize \
--admin YOUR_PUBLIC_KEY \
--platform_fee_bps 300
```

Repeatable deployment scripts live in [`scripts/`](scripts/). See the [**How to run scripts**](#-how-to-run-scripts) section below for full instructions.

The scripts deploy and initialise all three contracts in the correct order using environment variables. No manual copy-paste of WASM paths or contract IDs required.

## 📚 Contract Documentation

Expand Down Expand Up @@ -101,6 +89,63 @@ pub fn record_payment(

Full API documentation: [docs/API.md](docs/API.md)

## 📜 How to run scripts

### 1. Prerequisites

- Soroban CLI installed (`cargo install --locked soroban-cli --features opt`)
- Contracts compiled: `soroban contract build`

### 2. Configure environment variables

```bash
# Copy the template and fill in your values
cp .env.example .env
$EDITOR .env # set STELLAR_SECRET_KEY, ADMIN_PUBLIC_KEY, STELLAR_NETWORK, etc.
```

See [`.env.example`](.env.example) for the full list of variables and their descriptions.

> ⚠️ **Never commit `.env` to version control.** It is already listed in `.gitignore`.

### 3a. Bash (macOS / Linux)

```bash
# Run from the repo root
bash scripts/deploy.sh
```

The script:
1. Loads `.env` automatically
2. Validates all required variables and WASM paths
3. Deploys **invoice-token**, **invoice-escrow**, and **payment-distributor** in order
4. Calls `initialize` on each contract with the configured arguments
5. Prints a summary of deployed contract IDs

### 3b. PowerShell (Windows)

```powershell
# Allow script execution for this session (if not already set)
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

# Run from the repo root
.\scripts\deploy.ps1
```

The PowerShell script is functionally equivalent to the Bash script above.

### Re-using existing contract IDs

If a contract is already deployed and only needs re-initialisation, set its ID in `.env`:

```dotenv
INVOICE_ESCROW_CONTRACT_ID=C...
INVOICE_TOKEN_CONTRACT_ID=C...
PAYMENT_DISTRIBUTOR_CONTRACT_ID=C...
```

The deploy step is skipped for any contract whose ID is pre-filled; `initialize` is still called.

## 🧪 Testing
```bash
# Run all tests
Expand All @@ -124,6 +169,9 @@ cargo tarpaulin --out Html

## 📊 Contract Addresses

> Contract IDs are printed at the end of each `deploy.sh` / `deploy.ps1` run.
> Update the values below after deploying.

### Testnet
- Invoice Escrow: `CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
- Invoice Token: `CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`
Expand Down
Loading
Loading