AI-Powered Payment Infrastructure for Autonomous Agents on Stellar
AgenticPay is a decentralized payment platform built on the Stellar network that enables AI agents to autonomously manage escrow, verify work, and process payments through Soroban smart contracts.
agenticpay/
├── frontend/ # Next.js web application
├── backend/ # Express.js API server (AI verification & invoicing)
├── contracts/ # Soroban smart contracts (Rust)
Built with Next.js, React, and TypeScript.
- Stellar SDK + Freighter — Stellar wallet connection and contract interaction
- Web3Auth — Social login support (Google, Twitter, email)
- Zustand — State management
- Framer Motion — Animations
- Tailwind CSS — Styling
- shadcn/ui — UI components
Rust-based smart contracts deployed on Stellar Testnet via Soroban. Features:
- Project creation with client/freelancer roles
- XLM and Stellar token escrow payments
- Escrow funding and release on work approval
- Work submission with GitHub repository linking
- Dispute resolution and arbitration
Express.js API server providing:
- AI Work Verification — Validates freelancer deliverables against project requirements using AI
- Bulk Verification Operations — Batch verify, update, and delete verification records
- AI Invoice Generation — Automated invoice creation for completed work
- Stellar Horizon Integration — On-chain payment status and transaction lookups
- Scheduled Jobs — Cron-like tasks for background maintenance and monitoring
POST /api/v1/verification/verify/batchPATCH /api/v1/verification/batchDELETE /api/v1/verification/batch
- Instant Payments — Funds released immediately upon work approval via Soroban
- Blockchain Escrow — Smart contract holds funds securely until milestones are met
- Social & Wallet Login — Connect via Google/Twitter or Freighter wallet
- AI Verification — Automated code review against project specifications
- Milestone Tracking — Track project progress with clear status updates
- Invoice Management — Auto-generated invoices for completed projects
Before setting up the project locally, ensure you have the following installed:
- Node.js 20+ — Download from nodejs.org
- npm 10+ — Comes with Node.js
- Git — For cloning the repository
- Rust 1.70+ — Install from rustup.rs
- Soroban CLI — Install with
cargo install soroban-cli - Docker — For Soroban local network (optional)
- OpenAI API Key — Required for AI verification and invoice generation. Get it from platform.openai.com
- Web3Auth Credentials — Create an account at web3auth.io
- Stellar Testnet Account — Create at friendbot.stellar.org
- Freighter Wallet — Install the extension from freighter.app
git clone https://github.com/Smartdevs17/agenticpay.git
cd agenticpayThe backend is an Express.js API server that handles AI verification, invoicing, and Stellar integration.
cd backend
npm install
cd ..Create a .env file in the backend directory:
cp backend/.env.example backend/.envEdit backend/.env with your configuration:
# Server Configuration
PORT=3001
NODE_ENV=development
# CORS Configuration
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
# Stellar Configuration
STELLAR_NETWORK=testnet
# AI Services
OPENAI_API_KEY=sk_test_your_actual_key_here
# Background Jobs
JOBS_ENABLED=true| Variable | Default | Description | Required |
|---|---|---|---|
PORT |
3001 |
Server port | No |
NODE_ENV |
development |
Environment (development/production) | No |
CORS_ALLOWED_ORIGINS |
* |
Comma-separated list of allowed origins | No |
STELLAR_NETWORK |
testnet |
Stellar network (testnet/public) | No |
OPENAI_API_KEY |
- | OpenAI API key for AI verification/invoicing | Yes |
JOBS_ENABLED |
true |
Enable background job scheduler | No |
The frontend is a Next.js application providing the web interface for project management and payments.
cd frontend
npm install
cd ..Create a .env.local file in the frontend directory:
cp frontend/.env.example frontend/.env.localEdit frontend/.env.local with your configuration:
# Backend API
NEXT_PUBLIC_API_URL=http://localhost:3001/api/v1
# Web3Auth Configuration
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=your_web3auth_client_id_here
# Stellar Smart Contract
NEXT_PUBLIC_CONTRACT_ADDRESS=0xyour_deployed_contract_address_here
# Theme (optional)
NEXT_PUBLIC_APP_NAME=AgenticPay| Variable | Default | Description | Required |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
http://localhost:3001/api/v1 |
Backend API URL | No |
NEXT_PUBLIC_BACKEND_URL |
https://agentpay-backend-mu.vercel.app |
Fallback backend URL | No |
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID |
- | Web3Auth client ID | Yes |
NEXT_PUBLIC_CONTRACT_ADDRESS |
- | Deployed Soroban contract address | Yes |
If you plan to develop or deploy smart contracts, set up the Soroban environment.
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add WASM target
rustup target add wasm32-unknown-unknown
# Install Soroban CLI
cargo install soroban-clicd contracts
cargo build --target wasm32-unknown-unknown --releasesoroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/agenticpay.wasm \
--network testnet \
--source your_freighter_accountRun all services in development mode:
cd backend
npm run devBackend will start at http://localhost:3001
cd frontend
npm run devFrontend will start at http://localhost:3000
The application is now running and ready for development at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:3001/api/v1
- Health Check: http://localhost:3001/api/v1/health
cd backend
npm run build
npm startcd frontend
npm run build
npm startRun the backend test suite:
cd backend
npm test # Run tests once
npm run test:watch # Run tests in watch modeTests use Vitest and include:
- Route testing
- Middleware validation
- Service logic verification
- Health check validation
Run the frontend test suite:
cd frontend
npm test # Run tests once
npm run test:watch # Run tests in watch modeTests include:
- Component rendering
- User interaction testing
- API client testing
- Hook testing
Build and verify the smart contracts:
cd contracts
cargo test # Run Rust tests
cargo build --target wasm32-unknown-unknown --release # Build WASMcurl http://localhost:3001/api/v1/healthPOST /api/v1/verification/verify
Content-Type: application/json
{
"projectId": "abc123",
"freelancerId": "xyz789",
"deliverables": "GitHub link",
"requirements": "Build a React component"
}POST /api/v1/verification/verify/batch
Content-Type: application/json
{
"verifications": [
{
"projectId": "abc123",
"freelancerId": "xyz789",
"deliverables": "GitHub link",
"requirements": "Build a React component"
}
]
}POST /api/v1/invoice/create
Content-Type: application/json
{
"projectId": "abc123",
"freelancerId": "xyz789",
"amount": "100.50"
}GET /api/v1/stellar/transaction/:transactionHashPort Already in Use
# Kill process on port 3001
lsof -ti:3001 | xargs kill -9
# Or specify a different port
PORT=3002 npm run devOpenAI API Errors
- Verify your
OPENAI_API_KEYis correct - Check API key has sufficient quota at platform.openai.com
- Ensure rate limits are not exceeded
CORS Errors
- Update
CORS_ALLOWED_ORIGINSin.envto include your frontend URL - For development:
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:3001
API Connection Failed
- Verify backend is running on the correct port
- Check
NEXT_PUBLIC_API_URLmatches backend URL - Clear browser cache:
cmd/ctrl + shift + delete
Web3Auth Connection Issues
- Verify
NEXT_PUBLIC_WEB3AUTH_CLIENT_IDis correct - Check Web3Auth dashboard for app configuration
- Ensure redirect URLs are properly configured
Contract Address Not Found
- Verify
NEXT_PUBLIC_CONTRACT_ADDRESSis deployed - Check contract deployment on Stellar Testnet
- Use
soroban contract info --id <address> --network testnet
Port Already in Use
# macOS/Linux
lsof -ti:3000 | xargs kill -9 # Frontend
lsof -ti:3001 | xargs kill -9 # Backend
# Windows
netstat -ano | findstr :3000
taskkill /PID <PID> /FNode Modules Issues
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm installEnvironment Variables Not Loaded
- Restart the development server
- Verify
.envfile is in the correct directory - Check for typos in variable names
# Check Node.js version
node --version # Should be 20+
# Check npm version
npm --version # Should be 10+
# Verify backend environment
cd backend && npm list | head -20
# Verify frontend environment
cd frontend && npm list | head -20
# Test API connectivity
curl -s http://localhost:3001/api/v1/health | jq .# Set environment variables in hosting platform
# Deploy backend
cd backend
npm run build# Vercel (recommended for Next.js)
npm install -g vercel
vercel
# Or Netlify
npm install -g netlify-cli
netlify deploy- Create feature branch:
git checkout -b feature/your-feature - Make changes and test locally
- Run tests:
npm test(both backend and frontend) - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature/your-feature - Create Pull Request with description
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Follow the code style (ESLint configured)
- Add tests for new features
- Submit a pull request
MIT License - See LICENSE file for details
For issues, questions, or suggestions:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: See docs/ folder
# Install all dependencies
npm install --workspaces
# Start development
npm run dev --workspace=backend &
npm run dev --workspace=frontend
# Run all tests
npm test --workspaces
# Build for production
npm run build --workspace=backend
npm run build --workspace=frontend
# Lint code
npm run lint --workspace=backend
npm run lint --workspace=frontend- Stellar Documentation
- Soroban Smart Contracts
- OpenAI API
- Web3Auth Docs
- Next.js Documentation
- Express.js Guide
| Variable | Description |
|---|---|
NEXT_PUBLIC_CONTRACT_ID |
Deployed Soroban contract ID |
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID |
Web3Auth client ID for social login |
NEXT_PUBLIC_BACKEND_URL |
Backend API base URL |
NEXT_PUBLIC_STELLAR_NETWORK |
testnet or public |
OPENAI_API_KEY |
OpenAI API key for AI verification |
STELLAR_SECRET_KEY |
Server-side Stellar signing key |
JOBS_ENABLED |
Set to false to disable scheduled jobs |
- Default jobs live under
backend/src/jobs - Job status endpoint:
GET /api/v1/jobs
The AgenticPay smart contract source code is published for on-chain verification. To verify the deployed contract matches the source:
cd contracts
cargo build --target wasm32-unknown-unknown --release# Get the on-chain WASM hash
soroban contract inspect --id $NEXT_PUBLIC_CONTRACT_ID --network testnet
# Compute the local WASM hash
sha256sum target/wasm32-unknown-unknown/release/agenticpay.wasmThe SHA-256 hash of the locally compiled WASM should match the on-chain contract hash, confirming the deployed bytecode was produced from this source.
| Network | Contract ID | Status |
|---|---|---|
| Testnet | See NEXT_PUBLIC_CONTRACT_ID in .env |
Source published |
Note: Deterministic builds require the same Rust toolchain version. See
contracts/Cargo.tomlfor the SDK version and userust-toolchain.tomlif present.
Currently configured for Stellar Testnet.
We welcome contributions! This project participates in the Stellar Wave Program via Drips. Check the issues labeled Stellar Wave for bounty-eligible tasks.
MIT