Context & Impact
Contract IDs in src/lib/constants.ts fall back to placeholder values ("CB...") when environment variables are missing. There is no runtime validation that these IDs are actual deployed Soroban contract addresses. If a deployment omits NEXT_PUBLIC_PAYMENT_STREAM_CONTRACT_ID or NEXT_PUBLIC_DISTRIBUTOR_CONTRACT_ID, the app silently uses invalid addresses — every transaction fails with cryptic contract errors.
Why this matters: Contributors setting up the project for the first time, or deployments with misconfigured environment variables, will see transactions fail with no clear indication that the root cause is a bad contract ID. The app should fail fast and loud at startup, not silently at transaction time.
Scope
- Add runtime validation for all required environment variables at application startup
- Validate that contract IDs match the Stellar address format (56 characters, starting with
C)
- Create a startup check that runs before the app renders and shows a clear error if config is missing
- Remove placeholder fallback values that mask configuration errors
- Add validation for
NEXT_PUBLIC_STELLAR_RPC_URL and NEXT_PUBLIC_STELLAR_HORIZON_URL as well
Implementation Guidelines
- Create a
src/lib/env-validation.ts module that validates all required env vars
- Use Zod for schema validation of environment variables (already a project dependency)
- Call validation in the root layout or a provider that runs before any contract interaction
- In development, show a full-screen error overlay listing missing/invalid variables
- In production, log the error and show a generic "Configuration error" page
- Update
.env.example with clear documentation of each required variable
Acceptance Criteria
Getting Started
- Review
src/lib/constants.ts to see current fallback values
- Review
.env.example for documented vs. undocumented variables
- Create
src/lib/env-validation.ts with a Zod schema for all NEXT_PUBLIC_* variables
- Add a validation call in the root layout or a dedicated
EnvProvider
- Create a simple error UI component for the misconfiguration state
- Remove all fallback values from
constants.ts so missing vars are caught immediately
- Test by removing env vars and verifying the error UI appears
PR Submission Guide
This section applies to every PR for this issue. Follow it exactly.
Before You Start
While Working
Before Submitting the PR
PR Requirements
PRs without a screen recording or without a linked issue will not be reviewed.
Context & Impact
Contract IDs in
src/lib/constants.tsfall back to placeholder values ("CB...") when environment variables are missing. There is no runtime validation that these IDs are actual deployed Soroban contract addresses. If a deployment omitsNEXT_PUBLIC_PAYMENT_STREAM_CONTRACT_IDorNEXT_PUBLIC_DISTRIBUTOR_CONTRACT_ID, the app silently uses invalid addresses — every transaction fails with cryptic contract errors.Why this matters: Contributors setting up the project for the first time, or deployments with misconfigured environment variables, will see transactions fail with no clear indication that the root cause is a bad contract ID. The app should fail fast and loud at startup, not silently at transaction time.
Scope
C)NEXT_PUBLIC_STELLAR_RPC_URLandNEXT_PUBLIC_STELLAR_HORIZON_URLas wellImplementation Guidelines
src/lib/env-validation.tsmodule that validates all required env vars.env.examplewith clear documentation of each required variableAcceptance Criteria
src/lib/constants.tsNEXT_PUBLIC_PAYMENT_STREAM_CONTRACT_IDcauses a clear startup errorNEXT_PUBLIC_DISTRIBUTOR_CONTRACT_IDcauses a clear startup errorNEXT_PUBLIC_STELLAR_RPC_URLcauses a clear startup error.env.exampledocuments every required variable with descriptionsGetting Started
src/lib/constants.tsto see current fallback values.env.examplefor documented vs. undocumented variablessrc/lib/env-validation.tswith a Zod schema for allNEXT_PUBLIC_*variablesEnvProviderconstants.tsso missing vars are caught immediatelyPR Submission Guide
Before You Start
mainbranch:git checkout main && git pull origin mainmain:git checkout -b fix/<issue-number>-env-validationWhile Working
feat(scope): description,fix(scope): descriptiongit pull origin main --rebaseregularlyBefore Submitting the PR
mainand rebase:git checkout main && git pull origin main && git checkout <your-branch> && git rebase mainpnpm buildpnpm lintPR Requirements
Closes #<issue-number>PRs without a screen recording or without a linked issue will not be reviewed.