DaydreamsAI bounty deliverable: an x402-gated agent that audits risky token approvals for an EVM wallet and returns risk flags plus safe revoke transaction data.
This repo now has a live Cloudflare Worker deployment for RFDY review. See RFDY_REVIEW.md and DEPLOYMENT_REPORT.md before making any public PR/comment because full paid x402 verification/settlement still depends on configuring X402_FACILITATOR_URL.
- Scans curated top ERC-20 approval history across Ethereum, Base, Polygon, Arbitrum, Optimism, BSC, Avalanche, Fantom, and Gnosis.
- Reads current
allowance(owner, spender)before reporting so revoked/zero allowances are ignored. - Flags:
unlimited_allowancenonzero_allowancestale_approvaloperator_approval_for_allfor NFT collection approvalsunknown_spender_contract/unknown_spender_eoawhen bytecode checks are available
- Builds revoke calldata:
- ERC-20:
approve(spender, 0) - NFT:
setApprovalForAll(operator, false)
- ERC-20:
- Exposes agent discovery and invocation endpoints:
GET /.well-known/agent.jsonGET /entrypointsPOST /entrypoints/audit_approvals/invokecanonical Daydreams-style invoke routePOST /entrypoints/audit-approvals/invokecompatibility aliasPOST /entrypoints/audit/invokeshort agent-kit-style compatibility aliasPOST /invokelegacy compatibility routePOST /auditlegacy direct audit route
- Enforces x402-style payment when
PAYMENT_ADDRESSis configured:- Missing or invalid
X-PAYMENTreceives HTTP 402 and payment requirements. - Valid payments are verified before the audit runs.
- Successful audits optionally settle through a facilitator and return
X-PAYMENT-RESPONSE.
- Missing or invalid
npm installNode 20+ is required.
npm test
npm run build# Show help
npm start
# Run an audit and print JSON
npm start -- audit --wallet 0xYourWallet --chains ethereum,base
# Write report to a file
npm start -- audit --wallet 0xYourWallet --chains ethereum,base --out report.jsonUnpaid local/dev mode:
npm start -- servex402-enforced mode:
PAYMENT_ADDRESS=0xYourPaymentAddress \
PRICE_USD=0.01 \
PUBLIC_BASE_URL=http://localhost:3000 \
X402_FACILITATOR_URL=https://your-facilitator.example \
npm start -- serveEnvironment:
| Variable | Purpose |
|---|---|
PAYMENT_ADDRESS |
Enables x402 enforcement and receives payment. If absent, local/dev audits are not paywalled. |
PRICE_USD |
Human price metadata; default 0.01. Converted to 6-decimal USDC atomic units for maxAmountRequired. |
PAYMENT_NETWORK |
Payment network in x402 accept object; default base. |
PAYMENT_ASSET |
Asset in x402 accept object; default USDC. Replace with facilitator-required token address if needed. |
PUBLIC_BASE_URL |
Public HTTPS origin used in manifest and x402 resource fields. |
X402_FACILITATOR_URL |
Facilitator base URL. Server calls POST /verify before audit and POST /settle after audit. |
PORT, HOST |
Node server bind settings. |
GET /health— basic service metadata.GET /.well-known/agent.json— agent discovery manifest with endpoint URLs and x402 metadata.GET /entrypoints— Daydreams/agent-kit-style entrypoint list.POST /entrypoints/audit_approvals/invoke— canonical Daydreams-style agent invocation endpoint.POST /entrypoints/audit-approvals/invoke— compatibility alias for hyphenated entrypoint clients.POST /entrypoints/audit/invoke— compatibility alias for shortauditentrypoint clients.POST /invoke— legacy compatibility invocation endpoint.POST /audit— legacy direct audit endpoint with same payment enforcement.
Invoke request:
curl -s http://localhost:3000/entrypoints/audit_approvals/invoke \
-H 'content-type: application/json' \
-H 'X-PAYMENT: <x402-payment-payload>' \
-d '{"entrypoint":"audit_approvals","input":{"wallet":"0x1234567890123456789012345678901234567890","chains":["ethereum","base"]}}'If payment is required but missing/invalid, response is HTTP 402:
{
"error": "payment_required",
"x402Version": 1,
"accepts": [
{
"scheme": "exact",
"network": "base",
"payTo": "0x...",
"asset": "USDC",
"maxAmountRequired": "10000",
"resource": "https://your-agent.example/entrypoints/audit_approvals/invoke",
"description": "Approval Risk Auditor report with risky ERC-20 approvals and revoke transaction calldata.",
"mimeType": "application/json",
"maxTimeoutSeconds": 120
}
]
}Successful invoke response:
{
"entrypoint": "audit_approvals",
"result": {
"wallet": "0x...",
"generated_at": "2026-01-01T00:00:00.000Z",
"approvals": [],
"risk_flags": { "summary": { "total": 0, "critical": 0, "high": 0, "medium": 0, "low": 0 }, "by_approval": [] },
"revoke_tx_data": [],
"methodology": []
},
"x402": { "paid": true }
}Set any of these to override public/default RPC behavior:
ETHEREUM_RPC_URLBASE_RPC_URLPOLYGON_RPC_URLARBITRUM_RPC_URLOPTIMISM_RPC_URLBSC_RPC_URLAVALANCHE_RPC_URLFANTOM_RPC_URLGNOSIS_RPC_URL
Build and run locally:
docker build -t approval-risk-auditor .
docker run --rm -p 3000:3000 \
-e PAYMENT_ADDRESS=0xYourPaymentAddress \
-e PRICE_USD=0.01 \
-e PUBLIC_BASE_URL=http://localhost:3000 \
-e X402_FACILITATOR_URL=https://your-facilitator.example \
approval-risk-auditorLive Worker:
- Public URL:
https://approval-risk-auditor.tolga-730.workers.dev - x402 payTo EVM address:
0xd2475a9a1a6eC3B76e1c38F9C368084cfd98D46a - Solana payout public address for submission:
8sqgL8Srd7QCWJnQRFw1Gsi4spS9rndAbER1HEGDHLNT
The repo includes src/worker.ts and wrangler.toml for a Worker-shaped serverless deployment.
# Local preview
npx wrangler dev
# Configure secrets before deployment
npx wrangler secret put PAYMENT_ADDRESS
npx wrangler secret put X402_FACILITATOR_URL
npx wrangler secret put PUBLIC_BASE_URL
# Optional if not using defaults
npx wrangler secret put PRICE_USD
npx wrangler secret put PAYMENT_NETWORK
npx wrangler secret put PAYMENT_ASSET
# Redeploy after config/code changes
npx wrangler deployNotes:
PUBLIC_BASE_URLmust match the final Worker URL so/.well-known/agent.jsonand x402resourcevalues are correct.PAYMENT_ASSETmay need to be the facilitator's exact Base USDC contract address rather than the display stringUSDC; confirm against the chosen facilitator.
fly launch --dockerfile Dockerfile --no-deploy
fly secrets set PAYMENT_ADDRESS=0xYourPaymentAddress \
PRICE_USD=0.01 \
PUBLIC_BASE_URL=https://your-app.fly.dev \
X402_FACILITATOR_URL=https://your-facilitator.example
fly deploy- Create a Web Service from this repo.
- Runtime: Docker.
- Dockerfile path:
Dockerfile. - Set environment variables listed above.
- Health check path:
/health.
This is intentionally conservative for the bounty:
- It focuses on high-signal ERC-20 approvals for common assets on major chains.
- It validates current on-chain allowance before surfacing a risk.
- It does not move funds or submit transactions. It only returns unsigned transaction targets/calldata for the user to review and execute in their own wallet.
- NFT approval-for-all discovery is implemented through RPC/global logs where supported plus Etherscan-compatible fallback hooks.
- Public RPC
getLogsover wide ranges can rate-limit; production should prefer provider/explorer API keys or a dedicated indexer.
See FINAL_READINESS.md for the current submit/no-submit recommendation, competitor comparison, verification evidence, and draft public wording.