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
POST /api/v1/plans- Create a subscription plan (Daily, Weekly, Monthly, Yearly)GET /api/v1/plans/:merchantId- Retrieve plans for a specific merchantPOST /api/v1/subscriptions/enroll- Enroll a customer in a planDELETE /api/v1/subscriptions/:id- Cancel an active subscription
- Instant Payments — Funds released immediately upon work approval via Soroban
- Blockchain Escrow — Smart contract holds funds securely until milestones are met
- Subscription Engine — Automated recurring payments for SaaS, payroll, and retainers
- 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
- Two-Factor Authentication — TOTP-based 2FA using authenticator apps with backup codes for account security
For one-click setup with Node.js, Rust, Soroban CLI, Postgres, and Redis, see docs/DEVCONTAINER.md.
# One-command stack: Postgres, Redis, backend, and frontend
scripts/devcontainer.sh up
# Or start only the infra (Postgres + Redis) on the host:
docker compose up -d
# Or the full app (infra + backend API + frontend) from the root compose file:
make up-app
make db-migrate # first run against a new databaseTyped clients are generated from the backend OpenAPI spec. CI regenerates them on every push.
cd backend && npm run sdk:generate:typescript # also: sdk:generate:python, sdk:generate:goThis runs the pinned openapi-generator-cli Docker image, so Docker is required. Use node scripts/sdk/generate-sdk.mjs typescript --print to see the command without running it. Settings come from backend/openapi-generator.config.json.
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 |
http://localhost:3001/api/v1 |
Fallback backend URL (used if NEXT_PUBLIC_API_URL is unset) |
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/:transactionHashFor common issues and solutions, please refer to our Troubleshooting Guide.
- Port Already in Use:
lsof -ti:3000,3001 | xargs kill -9 - Environment Variables: Ensure
.envfiles exist in bothbackend/andfrontend/directories. - Node Modules:
rm -rf node_modules && npm install
# 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
Root build, lint, test and dev scripts run through Turborepo using the task graph in turbo.json. Each task's hash covers the workspace's tracked files, its dependencies' hashes, NODE_VERSION, and NEXT_PUBLIC_* for builds. When the hash is unchanged, turbo restores the cached outputs (dist/, .next/ without .next/cache, coverage/) and skips the task.
| Where | Cache |
|---|---|
| Local | node_modules/.cache/turbo. Run npx turbo run build --force to bypass it. |
CI (.github/workflows/ci.yml) |
Shared remote cache when it is configured. Otherwise a per-job actions/cache fallback. Each backend/frontend job writes a cache hit/miss table to the run summary. |
To enable the shared remote cache, a maintainer sets these in Settings → Secrets and variables → Actions:
| Name | Kind | Purpose |
|---|---|---|
TURBO_TOKEN |
secret | Remote cache access token |
TURBO_TEAM |
variable | Remote cache team slug |
TURBO_REMOTE_CACHE_SIGNATURE_KEY |
secret | HMAC key. Artifacts are signed (remoteCache.signature), and unsigned or tampered artifacts are ignored |
TURBO_API |
variable, optional | Self-hosted cache server URL. Defaults to https://vercel.com/api |
To use the remote cache locally, run npx turbo login && npx turbo link, or export the same variables. If the cache is unreachable or the signing key is missing, turbo prints a warning and rebuilds. The build never fails because of the cache.
CI calls turbo@${TURBO_VERSION}, which must match the version in package-lock.json. The config uses the turbo 1.x pipeline schema. scripts/turbo-config.test.mjs checks the version pin and the pipeline contract (node --test scripts/*.test.mjs), and the Repo tooling CI job runs that test.
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: Start with the documentation index
The root Makefile maps every common dev task to a make target. Run make on its own to list them all, grouped by area.
make doctor # check Node 20+, npm, cargo, forge, docker
make setup # npm workspaces + contract toolchains
make dev # backend + frontend in watch mode (or dev-backend / dev-frontend)
make test # every workspace suite; test-backend / test-frontend / test-contracts / test-e2e
make test-backend FILE=src/services/__tests__/settlementProof.test.ts # a single file
make lint build # turbo-cached lint and build
make db-migrate db-seed # database lifecycle (db-reset needs CONFIRM=1)
make sandbox-up # local sandbox stack (sandbox-down / sandbox-reset / sandbox-logs)
make clean # remove build outputs and turbo cachesEvery target wraps the npm, cargo, forge or docker command it names, and make -n <target> prints that command without running it. You can override tool binaries (NPM=pnpm, COMPOSE="podman compose"). Set VERBOSE=1 to echo commands and TIMINGS=1 to print how long each target took. If a required tool is missing, the target fails with an install hint. scripts/makefile.test.mjs checks that every target is documented, that every npm script a target calls exists, and that every root npm script has a target. Run it with make test-tooling.
- 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 --releasescripts/verify-contract-hash.sh fetches the deployed WASM from Stellar,
hashes it, compares it with the locally built WASM and with
contracts/build-manifest.json:
./scripts/verify-contract-hash.sh --contract-id $SOROBAN_CONTRACT_ID --network testnetAfter a verified deployment, regenerate the manifest that the backend reads at startup (commit it with the release):
./scripts/verify-contract-hash.sh --contract-id $SOROBAN_CONTRACT_ID --network testnet --writeThe manifest records the contract ID, network and expected WASM SHA-256:
{
"contractId": "C...",
"network": "testnet",
"wasmSha256": "<64 hex chars>",
"wasmFile": "contracts/target/wasm32-unknown-unknown/release/agenticpay.wasm",
"builtAt": "2026-01-01T00:00:00.000Z"
}At startup the backend fetches the deployed bytecode via Soroban RPC, hashes it
and compares it with the manifest. Behaviour is controlled by
CONTRACT_HASH_VERIFICATION:
| Value | Behaviour |
|---|---|
enforce |
Default. Refuse to start on any mismatch or manifest error. |
warn |
Log the failure and continue starting (rollout / debugging only). |
off |
Skip the check entirely. |
Verification is active only when SOROBAN_CONTRACT_ID is set. On the public
network SOROBAN_RPC_URL is required; on testnet it defaults to
https://soroban-testnet.stellar.org.
| 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
- Branded Payment Links & Checkout Analytics (
backend/src/services/paymentLinks.ts,frontend/app/pay/): Track checkout funnel events (view,checkout_started,completed,abandoned), conversion/abandonment rates, revenue, and merchant-level summaries. - Customizable Project Workflow Templates (
backend/src/services/templates.ts): Instantiate parameterized workflows from templates viainstantiateWorkflowwith typed variable validation,{{variable}}interpolation, and per-step configuration overrides. - User Reputation & Challenge-Response Resets (
backend/src/services/reputation.ts): Score tracking, trust tiers, velocity gaming detection, and HMAC-SHA256 challenge-response resets (initiateReputationReset/completeReputationReset) with single-use TTL enforcement. - On-Chain Receipt Verification & QR Codes (
contracts/src/lib.rs,backend/src/services/receipts.ts): Canonical SHA-256 on-chain receipt hashes (get_receipt_hash/verify_receipt) paired with HMAC-signed verification QR codes (generateReceiptQrCode/verifyReceiptQrPayload).