AI-native payment application leveraging x402 protocol for agent-triggered payments on Cronos EVM
| Platform | Link |
|---|---|
| π± Telegram | t.me/novustch |
| π² WhatsApp | wa.me/14105015750 |
| π¬ Discord | discordapp.com/users/985432160498491473 |
Feel free to reach out for implementation assistance or integration support.
- Overview
- Features
- Architecture
- Getting Started
- Smart Contracts
- Frontend Application
- Deployment
- API Reference
- Testing
- Contributing
- License
Cronos x402 Paytech is a production-ready application that enables AI agents to autonomously trigger and execute payments on the Cronos blockchain using the x402 protocol. The system provides programmable payment rails with support for:
- Agent-triggered payments: AI agents can create payment requests autonomously
- Recurring payments: Automated recurring payment schedules
- Conditional payments: Payments that execute based on predefined conditions
- Batch processing: Efficient multi-payment execution
- Native CRO and ERC-20 support: Flexible token payment options
This project was built for the [Cronos x402 Paytech] and demonstrates integration with Cronos EVM, x402 facilitator, and Crypto.com AI Agent SDK.
-
β x402-Compatible Payment Facilitation
- Secure payment request creation and execution
- Support for native CRO and ERC-20 tokens
- Deadline-based payment requests with expiration handling
-
β AI Agent Integration
- Authorized agent system for secure automation
- Integration with Crypto.com AI Agent SDK
- Agent-triggered payment workflows
-
β Advanced Payment Management
- Recurring payment schedules
- Conditional payment execution
- Batch payment processing
-
β Modern Web Interface
- Next.js 14 with React 18
- RainbowKit wallet integration
- Responsive design with Tailwind CSS
- Reentrancy protection
- Access control with authorized agents
- Deadline validation
- Emergency withdrawal functions
- Comprehensive test coverage
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β React UI β β Wallet Conn β β API Routes β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Smart Contracts (Solidity) β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β X402PaymentFacilitatorβ β AgentPaymentManager β β
β β - Payment Requests β β - Recurring β β
β β - Payment Execution β β - Conditional β β
β β - Agent Auth β β - Workflows β β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Cronos EVM Network β
β (Testnet: Chain ID 338) β
β (Mainnet: Chain ID 25) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
-
X402PaymentFacilitator: Core payment facilitation contract
- Creates and manages payment requests
- Executes payments (native CRO and ERC-20)
- Manages agent authorization
- Batch payment execution
-
AgentPaymentManager: Advanced payment workflow manager
- Recurring payment schedules
- Conditional payment logic
- Multi-step settlement workflows
- Node.js >= 18.0.0
- npm >= 9.0.0 or yarn >= 1.22.0
- Git
- MetaMask or Crypto.com DeFi Wallet (for testing)
- Cronos Testnet CRO (get from faucet)
- Clone the repository
git clone https://github.com/Novus-Tech-LLC/Cronos-x402-Paytech.git
cd Cronos-x402-Paytech- Install dependencies
npm install- Set up environment variables
cp .env.example .envEdit .env and configure:
# Private key for deployment (NEVER commit this!)
PRIVATE_KEY=your_private_key_here
# Contract addresses (update after deployment)
NEXT_PUBLIC_X402_FACILITATOR_ADDRESS=0x...
NEXT_PUBLIC_AGENT_PAYMENT_MANAGER_ADDRESS=0x...
# WalletConnect Project ID
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id
# Network Configuration
NEXT_PUBLIC_CHAIN_ID=338
NEXT_PUBLIC_RPC_URL=https://evm-t3.cronos.org- Compile smart contracts
npm run compile- Run tests
npm test- Start development server
npm run devVisit http://localhost:3000 to access the application.
The core contract for x402-compatible payments.
Key Functions:
createPaymentRequest(recipient, token, amount, deadline): Create a new payment requestexecutePayment(requestId): Execute a payment requestbatchExecutePayments(requestIds[]): Execute multiple payments in one transactionauthorizeAgent(agent): Authorize an AI agent to create paymentsgetPaymentRequest(requestId): Query payment request details
Example Usage:
// Create a payment request (agent only)
bytes32 requestId = facilitator.createPaymentRequest(
recipientAddress,
address(0), // Native CRO
1 ether,
block.timestamp + 1 hours
);
// Execute the payment
facilitator.executePayment{value: 1 ether}(requestId);Manages advanced payment workflows.
Key Functions:
createRecurringPayment(recipient, token, amount, interval, duration): Set up recurring paymentsexecuteRecurringPayment(paymentId): Execute a due recurring paymentcreateConditionalPayment(recipient, token, amount, conditionHash): Create conditional paymentexecuteConditionalPayment(conditionId, conditionProof): Execute if condition met
- Next.js 14: React framework with App Router
- Wagmi: Ethereum React hooks
- RainbowKit: Wallet connection UI
- Tailwind CSS: Styling
- TypeScript: Type safety
- Wallet connection (MetaMask, WalletConnect, Crypto.com DeFi Wallet)
- Payment request creation interface
- Payment execution interface
- Transaction status tracking
- Responsive design
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start- Deploy to Cronos Testnet
npm run deploy:testnet- Deploy to Cronos Mainnet
npm run deploy:mainnetAfter deployment, update your .env file with the deployed contract addresses.
The frontend can be deployed to:
- Vercel (recommended for Next.js)
- Netlify
- Any Node.js hosting service
Vercel Deployment:
# Install Vercel CLI
npm i -g vercel
# Deploy
vercelMake sure to set environment variables in your hosting platform.
The project includes integration points for Crypto.com AI Agent SDK:
import { initializeAIAgent } from '@/lib/ai-agent-sdk'
const agent = initializeAIAgent({
agentAddress: '0x...',
facilitatorAddress: '0x...',
network: 'testnet'
})
// Create payment via AI agent
const requestId = await agent.createPaymentRequest({
recipient: '0x...',
amount: '1.0',
token: undefined, // Native CRO
})
// Execute payment
const txHash = await agent.executePayment(requestId)POST /api/agent/payment: Create payment request via AI agentPOST /api/agent/execute: Execute payment via AI agentGET /api/agent/status/[requestId]: Get payment status
# Run all tests
npm test
# Run with coverage
npx hardhat coverage
# Run specific test file
npx hardhat test test/X402PaymentFacilitator.test.jsThe test suite covers:
- Agent authorization and revocation
- Payment request creation
- Payment execution (native CRO and ERC-20)
- Batch payment execution
- Error handling and edge cases
- Reentrancy protection
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Solidity style guide for smart contracts
- Use TypeScript for frontend code
- Write tests for new features
- Update documentation as needed
- Follow conventional commit messages
- Cronos Testnet Faucet
- CronosScan (Block Explorer)
- Hardhat Documentation
- β Project Overview: Comprehensive AI-native payment system
- β On-Chain Component: Fully deployed smart contracts on Cronos EVM
- β Functional Prototype: Complete frontend and backend implementation
- β Testnet Deployment: Ready for Cronos Testnet deployment
This project is licensed under the MIT License - see the LICENSE file for details.
- Crypto.com for the AI Agent SDK and ecosystem support
- OpenZeppelin for secure smart contract libraries
- RainbowKit and Wagmi teams for excellent wallet integration tools
- Repository: GitHub
- Documentation: [This README]
Built with β€οΈ for the Cronos x402 Paytech