Trust scoring, adaptive escrow, and dispute resolution for AI agent payments.
x402 enables AI agents to pay for API calls with USDC. But there's a critical vulnerability: agents pay first, receive service after. If a provider doesn't deliver, the agent loses funds with no recourse.
x402 Trust Protocol adds three protection layers:
Before: Agent → Pay → Hope → Maybe receive service
After: Agent → Check score → Decide → Pay securely → Guaranteed outcome
| Contract | Purpose | Address |
|---|---|---|
| TrustProtocol | Main entry point | 0x1eC0007C...329F |
| ReputationEngine | Trust scoring (1900 lines) | 0x86fa599c...DA1e |
| EscrowVault | Payment lifecycle | 0x35D3d7Ff...d817 |
| DisputeManager | Multi-track disputes | 0x7449713F...58a9 |
| TrustOracle | External data feeds | 0xe8b92BAe...52Bd |
| PaymentRouter | Auto-routing | 0xe37B0FA6...0Cf6 |
| CrossChainEscrow | CCTP integration | Ready for deployment |
| MockUSDC | Test token | 0x8Fd5A8a2...237B |
Chain ID: 5042002 | RPC: https://rpc.testnet.arc.network
| Action | Transaction Hash |
|---|---|
| Mint USDC | 0x5aa17f4e... |
| Approve Stake | 0xbb15a47f... |
| Register Provider | 0x97155c0c... |
| Approve Escrow | 0x522601f5... |
| Create Payment | 0xd9cb1e5e... |
Multi-factor trust scoring (300-900) that takes TIME to build:
| Factor | Weight | Description |
|---|---|---|
| Success Rate | 35% | Successful / Total transactions |
| Volume-Weighted | 25% | Large tx count more |
| Counterparty Diversity | 20% | Unique buyers (anti-wash-trading) |
| Longevity | 10% | Time since registration |
| Response Speed | 10% | Avg response time |
Hard Constraints:
- Score > 600 requires 7 days
- Score > 700 requires 30 days
- Score > 800 requires 60 days
- Max +5 points/day regardless of activity
- 100 tx in 60s = auto-quarantine
Both sides are rated:
struct BuyerProfile {
uint256 score; // 300-900
BuyerTier tier; // Unknown → Premium
uint256 disputesWon; // Legitimate complaints
uint256 disputesLost; // Frivolous complaints
uint256 hallucinationScore; // False claim detection
}Import your reputation from another chain with 50% discount:
| Day | Unlock | Example (800 imported) |
|---|---|---|
| 0 | 50% | 400 |
| 7 | 60% | 480 |
| 15 | 75% | 600 |
| 30 | 100% | 800 |
Bad behavior? Frozen — restart from MIN_SCORE.
- 24-hour waiting period before flags take effect
- Cross-validation: ≥3 buyers must agree
- Appeal system: 48h window, 10 USDC stake
- Flagger credibility: Bad flaggers penalized
- Buyers rate response quality (1-5 stars)
- Cross-agent consensus detects outliers
- 3+ outlier events = warning, severe = quarantine
if (score >= 850) → Direct payment, 5 min timeout
if (score >= 700) → Escrow optional, 10 min timeout
if (score >= 500) → Escrow required, 15 min timeout
if (score < 500) → Escrow + extra scrutiny, 20 min timeout| Track | Trigger | Timeline |
|---|---|---|
| FastTrack | <$100 | 60 hours |
| Standard | $100-$10K | 120 hours |
| Complex | >$10K | 192 hours |
6 chains supported: Ethereum, Base, Arbitrum, Optimism, Polygon, Avalanche
# Clone
git clone https://github.com/x402-trust/protocol.git
cd protocol
npm install
# Test (125 tests)
npm run test
# Deploy
npx hardhat run scripts/deploy.js --network arcTestnetclawhub install x402-trust5 Actions:
| Action | Description |
|---|---|
check_provider |
Get trust score and escrow recommendation |
secure_payment |
Pay with escrow protection |
confirm_delivery |
Release funds, update scores |
raise_dispute |
Start dispute process |
compare_providers |
Compare multiple providers |
125 tests across 9 suites:
| Suite | Tests |
|---|---|
| Security.test.js | 42 |
| CrossChainEscrow.test.js | 20 |
| BuyerReputation.test.js | 13 |
| Integration.test.js | 12 |
| CrossChainReputation.test.js | 11 |
| EscrowVault.test.js | 10 |
| ReputationEngine.test.js | 8 |
| DisputeManager.test.js | 5 |
| TrustProtocol.test.js | 4 |
MIT License — see LICENSE