Get the AEP2 MVP running in 5 minutes!
- Node.js 18+
- 3 Ethereum wallets (deployer, SP, client) with Base Sepolia ETH
- Base Sepolia USDC for testing
npm installcp .env.example .envEdit .env and fill in:
# Get these addresses from your wallets
DEPLOYER_PK=0x...
SP_PK=0x...
SP_ADDRESS=0x... # Address of SP_PK wallet
CLIENT_PK=0x...
PAYEE_ADDRESS=0x... # Can be same as SP or any address
# These will be filled after deployment
WALLET_ADDR=npm run compile
npm run deployCopy the deployed contract address to WALLET_ADDR in .env.
Authorize SP and check setup:
npm run setupGet Base Sepolia USDC from:
- Bridge from Ethereum Sepolia
- Swap on Base Sepolia DEX
- Use faucet if available
Address: 0x036CbD53842c5426634e7929541eC2318f3dCF7e
Deposit 1 USDC (or set DEPOSIT_AMOUNT in .env):
npm run depositTerminal 1 - Start SP:
npm run spTerminal 2 - Start Payee:
npm run payee./start-all.shView logs:
tail -f logs/sp.log
tail -f logs/payee.logStop services:
./stop-all.shTerminal 3 - Run client:
# Test without payment (should fail with 402)
npm run client no-payment
# Test with payment (should succeed)
npm run clientSuccessful payment flow:
=== AEP2 Client Demo ===
Client Address: 0x...
Payee Address: 0x...
Wallet Contract: 0x...
[1/3] Creating payment mandate...
Mandate created:
- Amount: 0.001 USDC
- Nonce: ...
- Deadline: 2024-...
- Ref: 0x...
[2/3] Encoding payment header...
Payment header: eyJtYW5kYXRlIjp7Im93b...
[3/3] Calling /predict API...
=== Success ===
ETH-USD Price: $4005.32
Timestamp: 2024-...
Payment Status: enqueued
SP Receipt:
- SP Address: 0x...
- Mandate Digest: 0x...
- Enqueue Deadline: 2024-...
Settlement will be completed on-chain by SP within 3 hours.
Check SP logs for settlement transaction:
[WORKER] Processing settlement for 0x1234567890...
[WORKER] Transaction sent: 0xabcdef...
[WORKER] Settlement successful for 0x1234567890...
Verify on Base Sepolia block explorer: https://sepolia.basescan.org/tx/[transaction_hash]
# Check balance
npx hardhat console --network baseSepolia
> const wallet = await ethers.getContractAt("AEP2DebitWallet", "YOUR_WALLET_ADDR")
> const balance = await wallet.balances("YOUR_CLIENT_ADDR", "USDC_ADDR")
> console.log(ethers.formatUnits(balance, 6))If balance is 0, run npm run deposit again.
# Check SP authorization
npx hardhat console --network baseSepolia
> const wallet = await ethers.getContractAt("AEP2DebitWallet", "YOUR_WALLET_ADDR")
> const authorized = await wallet.sp("YOUR_SP_ADDRESS")
> console.log(authorized)If false, run npm run setup or manually authorize:
await wallet.setSP("YOUR_SP_ADDRESS", true)- Check if ports 3001 and 3002 are available
- Verify RPC URL is accessible
- Check all required env vars are set
- Check SP logs for errors
- Verify SP has enough ETH for gas
- Ensure mandate hasn't expired
- Check SP is authorized on contract
- Read README.md for detailed documentation
- Check prd.md for protocol specification
- Explore contract events on block explorer
- Integrate AEP2 into your AI agent application
For issues and questions:
- Check logs in
logs/directory - Review error messages carefully
- Verify all configuration values
- Test with small amounts first
Happy building with AEP2!