r/ethdev • • 9h ago

My Project We deployed an ownerless O(1) SHA-256 PayWords USDC channel on Base Mainnet (x402 batch-settlement) — 1,000 metered API calls in 0.235 ms/call ($0 gas) settled in 1 tx (783k gas) + Lean 4 proofs

2 Upvotes

If you are building metered AI APIs, MCP servers, or x402 endpoints on Base, you hit two ugly walls pretty fast:

  1. Stripe cards (2.9% + $0.30/call) make $0.001–$0.01 per-call billing mathematically impossible ($300+ in fees to settle $1 of micro-calls).
  2. Per-call on-chain EIP-3009 (x402) works great for single one-off requests, but when an agent calls your API 500–1,000 times in a loop, firing a separate on-chain tx per call adds latency, facilitator overhead, and retry double-spend risk.

We took the classic Rivest–Shamir (1996) PayWords SHA-256 hash-chain idea, implemented it against the EVM native sha256 precompile (0x02), formally proved exact escrow conservation in Lean 4, and deployed it ownerless with 0% protocol fee on Base Mainnet (eip155:8453).

How it works

  1. Payer locks USDC once: Generates a 32-byte seed w_N, hashes it N times to get public root w_0 = SHA256^N(w_N), and calls openChannel(recipient, USDC, w_0, unitAmount, N, expiry) once.
  2. Zero-gas O(1) calls: On call k, the client sends (channelId, k, w_k) in HTTP headers. The server checks 1 SHA-256 hash (SHA256(w_k) == lastAccepted) and advances a monotonic cursor — zero signatures, zero RPC calls, zero gas per request. Because k is strictly monotonic, retrying a dropped HTTP call with w_k is idempotent by construction.
  3. 1-tx batch settlement: After 100 or 1,000+ calls, the server submits claim(channelId, steps, w_k) once on Base. Unused escrow returns cooperatively via closeAndRefund() or unilaterally to the payer via refund() after expiry.

Live Base Mainnet Proofs & Measured Numbers

Companion Contract: Revenue-Backed Fair Bonding Curves (0% Premine, 0% Platform Cut)

We also deployed an immutable NewsatoshiFairCurveFactory (0xF6bE782819a8eD0D1556A8f5DC3223f9eb13a933, Sourcify exact_match) where an API/agent can pipe its settled PayWords USDC straight into injectRevenue(amount) — distributing dilution-proof pro-rata USDC dividends (REV_PRECISION = 1e30) to existing holders while preserving the exact integer constant-product curve solvency invariant.

Try It / Re-Verify Offline

Honest Trade-Offs & Current Limitations

  • Upfront channel open: Costs 1 Base tx (~235k gas) per buyer-seller pair, so per-call EIP-3009 still wins for single one-off requests to new sellers.
  • Liveness before expiry: The server must submit claim() before expiry (enforced by a configurable minRemainingExpirySec buffer in the SDK gate).
  • Audits & License: We have 20/20 Foundry tests + 256 fuzz runs + Lean 4 conservation proofs (0 sorry), but 0 external human security audits so far — treat early usage accordingly. The wire protocol is open (x402#4494); reference repo code is licensed PolyForm-Noncommercial-1.0.0.

Would genuinely appreciate any Solidity/EVM gas-golfing feedback, security review on NewsatoshiPayWordChannel.sol / NewsatoshiFairCurveFactory.sol, or thoughts on integrating batch-settlement into x402.


r/ethdev • • 23h ago

My Project Gas is cheap now, so I built a tool to check if old wallet dust is worth selling

2 Upvotes

I was trading a lot of shitcoins in 2020/2021, and most of the leftover dust wasn't worth selling. Gas was $50+ per swap, sometimes a few hundred. Now a token swap costs under $1, so I wondered whether any of it was worth selling. Most trackers showed it as $0, but some still had real liquidity in pools no price API tracks anymore. So I built a tool to check, and between an earlier version and this one it found about $830 I didn't know I had.

How it works: for each token it runs a read-only simulation of the sell on an RPC node. Nothing is signed, sent or changed onchain. The simulation uses eth_call with a state override, which lets a call pretend for that one request that the holder's address runs a small helper contract. That pretend helper approves and swaps (V2 routers, V3 and Algebra pools) using the holder's real balance, and the node throws the result away afterwards. Because it acts as the real holder, taxes, blacklists and honeypots show up as failed sells instead of a nice getAmountsOut quote you can't actually execute. For dead pools it finds the smallest part of your balance that still gets ~99.9% of the output, so you don't dump everything for nothing. Gas is subtracted, so "sellable" means worth selling.

It's at walletcrumbs.com. It's free, takes only an address or ENS name, and nothing is signed or connected. It covers ETH, BNB, Polygon, Arbitrum, Base and Avalanche, and I'm planning to add more chains in the next few days.

It's not a big deal, but I hope it helps someone find a few forgotten bucks too. Feedback welcome.