Skip to content

feat: implement contract address registry API#160

Merged
Wilfred007 merged 3 commits intoGildado:mainfrom
meshackyaro:address-registry-api
Feb 25, 2026
Merged

feat: implement contract address registry API#160
Wilfred007 merged 3 commits intoGildado:mainfrom
meshackyaro:address-registry-api

Conversation

@meshackyaro
Copy link
Copy Markdown
Contributor

@meshackyaro meshackyaro commented Feb 25, 2026

Description

This PR implements a Contract Address Registry API that exposes deployed Soroban contract addresses through a centralized endpoint, enabling hot-swappable contract deployments without frontend rebuilds.

Changes

Backend

  • Added GET /api/contracts endpoint that returns contract addresses with metadata
  • Implemented configuration service that reads from environments.toml with automatic fallback to environment variables
  • Added contract validator for Stellar address format validation
  • Integrated structured logging for all contract registry operations

Frontend

  • Created contracts.ts service with automatic caching (1-hour TTL)
  • Implemented retry logic with exponential backoff (3 attempts: 1s, 2s, 4s)
  • Added TypeScript type definitions for type-safe contract access
  • Included migration guide for transitioning from hardcoded addresses

Configuration

  • Updated environments.toml with sample contract data for testnet and mainnet
  • Supports dynamic contract discovery (add new contracts via config only)

Documentation

  • Comprehensive API documentation in docs/CONTRACT_REGISTRY_API.md
  • Full spec with requirements, design, and implementation tasks

Acceptance Criteria

  • ✅ Endpoint returns structured JSON with contractId, network, and version per contract
  • ✅ Values sourced from environments.toml or server-side env vars (not hard-coded)
  • ✅ Frontend contracts.ts service fetches and caches the registry on startup
  • ✅ Adding a new contract requires only a config change, not a code change
  • ✅ Response includes deployedAt ledger sequence for reference

Testing

Start the backend and test the endpoint:

cd backend
npm run dev

# Test endpoint
curl http://localhost:3000/api/contracts

Supported Contracts

  • bulk_payment
  • vesting_escrow
  • revenue_split
  • cross_asset_payment

Closes #151

- Add GET /api/contracts endpoint to serve deployed contract addresses
- Implement configuration service with environments.toml and env var fallback
- Add contract validator for Stellar address format validation
- Create frontend contract service with caching and retry logic
- Add comprehensive documentation and spec files
- Update environments.toml with sample contract data

Closes Gildado#78
Add explicit type assertion for import.meta.env.VITE_API_BASE_URL
@meshackyaro
Copy link
Copy Markdown
Contributor Author

Hi @Wilfred007, PR created and pipeline fixed

@Wilfred007 Wilfred007 merged commit 3c171d3 into Gildado:main Feb 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#078: Contract Address Registry API

2 participants