Decentralized service routing and incentive protocol for the x402 payment ecosystem
XSRN (X402 Service Routing Network) is the incentive and quality assurance layer for the x402 payment protocol. It provides:
- π Protocol Fee Distribution - 0.3% fee on x402 transactions distributed to network participants
- π Epoch-based Rewards - Weekly reward cycles with Merkle tree distribution
- β Quality Assurance - Bond/Challenge mechanism to ensure service quality
- π Service Routing - Intelligent routing for optimal payment paths
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Payment β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β XsrnSessionManager β
β (Session Key Payment Entry) β
βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β XsrnFeeSplitter β
β (Core Fee Distribution Contract) β
β β
β β’ Deducts 0.3% protocol fee β Treasury β
β β’ Records receipt β ReceiptRegistry β
β β’ Forwards 99.7% β Commission contract β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββ΄βββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββββ βββββββββββββββββββββ
β XsrnTreasury β βMerchant/Commissionβ
β (Protocol Fees) β β (Merchant Split) β
β β β β
β β’ 40% Watcher β β β’ Merchant β
β β’ 30% Operator β β β’ Agent/Referrer β
β β’ 20% Public Good β β β’ Agent/execution β
β β’ 10% Reserve β β β’ platform β
βββββββββββββββββββββ βββββββββββββββββββββ
| Contract | Description | Status |
|---|---|---|
XsrnSessionManager |
Session key payment management (ERC-8004) | β Deployed |
XsrnFeeSplitter |
Core fee splitting (0.3% protocol fee) | β Deployed |
XsrnTreasury |
Protocol fee treasury (40/30/20/10 distribution) | β Deployed |
ReceiptRegistry |
On-chain payment receipts | β Deployed |
EpochManager |
7-day epoch cycle management | β Deployed |
MerkleDistributor |
Merkle tree reward distribution | β Deployed |
AttestationRegistry |
Quality attestation with Bond/Challenge | β Deployed |
npm install @xsrn/protocol
# or
yarn add @xsrn/protocolimport { XsrnClient, EpochService, MerkleGenerator } from '@xsrn/protocol';
// Initialize client
const client = new XsrnClient({
rpcUrl: 'https://bsc-testnet.nodereal.io/v1/...',
chainId: 97,
contracts: {
treasury: '0x3FDfB8408cdd91B5692E68F07B8937fD5F62fC01',
feeSplitter: '0x371E206CA565f5713b8Cd1f8922A2eb8FB0F98F7',
// ... other contract addresses
}
});
// Get epoch info
const epochInfo = await client.getEpochInfo();
console.log(`Current Epoch: ${epochInfo.id}, Ends: ${epochInfo.endTime}`);
// Claim rewards
const proof = await client.getMerkleProof(userAddress, epochId);
await client.claimRewards(epochId, proof);# Clone repository
git clone https://github.com/Agentrix2025/XSRN.git
cd XSRN
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your private key and RPC URL
# Compile contracts
npm run compile
# Run tests
npm test
# Deploy to BSC Testnet
npm run deploy:testnetEvery x402 payment deducts 0.3% as protocol fee, distributed as:
| Role | Share | Purpose |
|---|---|---|
| Watcher | 40% | On-chain monitoring and alerts |
| Operator | 30% | Node operation and maintenance |
| Public Goods | 20% | Ecosystem public goods funding |
| Security Reserve | 10% | Security reserve fund |
- Cycle: 7 days
- Distribution: Merkle tree proofs
- Claim: Users call
claim()orclaimMultiple()
- Submit Attestation: Agent submits service quality proof + optional bond
- Challenge Period: 7-day window for challenges
- Arbitration: If challenged, arbiter makes decision
- Outcome:
- Challenge succeeds: 50% bond goes to challenger
- Challenge fails: Agent keeps bond, gets validation badge
| Parameter | Value | Description |
|---|---|---|
| Min Bond | 10 USDT | Minimum stake for attestation |
| Challenge Period | 7 days | Time window for challenges |
| Slash Percentage | 50% | Penalty for failed attestation |
xsrn-protocol/
βββ contracts/ # Solidity smart contracts
β βββ XsrnFeeSplitter.sol
β βββ XsrnTreasury.sol
β βββ XsrnSessionManager.sol
β βββ ReceiptRegistry.sol
β βββ EpochManager.sol
β βββ MerkleDistributor.sol
β βββ AttestationRegistry.sol
βββ src/ # TypeScript SDK source
β βββ client.ts
β βββ services/
β βββ types/
βββ test/ # Test files
βββ scripts/ # Deployment scripts
βββ frontend/ # React components
βββ docs/ # Documentation
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific test file
npx hardhat test test/XsrnProtocol.test.ts# Lint code
npm run lint
# Fix lint issues
npm run lint:fix
# Format code
npm run formatclass XsrnClient {
constructor(config: XsrnConfig);
// Epoch methods
getEpochInfo(): Promise<EpochInfo>;
getEpochStats(epochId: number): Promise<EpochStats>;
// Rewards methods
getRewardsBalance(address: string): Promise<RewardsBalance>;
getMerkleProof(address: string, epochId: number): Promise<MerkleProof>;
claimRewards(epochId: number, proof: MerkleProof): Promise<TxResult>;
claimMultipleRewards(claims: ClaimData[]): Promise<TxResult>;
// Attestation methods
submitAttestation(contentHash: string, bondAmount?: bigint): Promise<TxResult>;
challenge(attestationId: string, reason: string): Promise<TxResult>;
getAttestationStatus(attestationId: string): Promise<AttestationStatus>;
}See API Documentation for full reference.
| Contract | Address |
|---|---|
| XsrnTreasury | 0x3FDfB8408cdd91B5692E68F07B8937fD5F62fC01 |
| XsrnFeeSplitter | 0x371E206CA565f5713b8Cd1f8922A2eb8FB0F98F7 |
| XsrnSessionManager | 0x85F03Ca00307f4F7C218CF88aC15Ae7FdD6b0F95 |
| ReceiptRegistry | 0x1BBEeb73AC8bbDC9D5063B6E53470D3234B7240c |
| EpochManager | 0xAe969539b6c840798658dd2e141e6a5F898C9f00 |
| MerkleDistributor | 0xC72d761b6dE93F33Dcba2fA150316F6E1F63f6E2 |
| AttestationRegistry | 0x6BfDDeBbF72E32f4d9fd87452da3fFDe58341267 |
Coming soon after security audit.
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Solidity Style Guide
- Write comprehensive tests for new features
- Update documentation as needed
- Keep commits atomic and well-documented
This project is licensed under the MIT License - see the LICENSE file for details.
- Website: https://xsrn.x402.org
- Documentation: https://docs.xsrn.x402.org
- x402 Protocol: https://x402.org
- Twitter: @x402protocol
- Discord: Join our Discord
- Email: Jacky2025@agentrix.top
- GitHub Issues: Report a bug