feat(x402): stamp BlockRun builder-code service code on payments#198
Conversation
Tag every x402 payment ClawRouter signs with the ERC-8021 Schema 2 service code s: ["blockrun"] so BlockRun-originated traffic is attributed on-chain. An onAfterPaymentCreation hook stamps builder-code.info.s onto the payload, preserving any app code (a) the server echoed back. This mirrors @x402/extensions' BuilderCodeClientExtension but fires unconditionally (independent of the server advertising the extension) and needs no @x402 upgrade. The EIP-712 signature covers the authorization, not the extensions, so stamping after creation is safe. Encoding into settlement calldata is done by the CDP facilitator. Docs: https://docs.cdp.coinbase.com/x402/core-concepts/builder-codes
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds ChangesBuilder-code service attribution
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/builder-code.test.ts`:
- Line 7: The test assertions in builder-code.test.ts are using explicit any
casts that violate `@typescript-eslint/no-explicit-any`. Replace the
(ext["builder-code"] as any) access in the affected assertions with a minimal
typed shape or narrow interface that exposes the info.s property used by the
test, so the same checks can be performed without any. Update both builder-code
assertions consistently where the cast appears.
In `@src/builder-code.ts`:
- Around line 1-32: The file formatting is failing Prettier checks, so update
the code style in withBuilderCodeServiceCode and the related
BLOCKRUN_SERVICE_CODE declaration to match the repository’s formatting rules.
Run Prettier on this module and keep the existing behavior unchanged while
adjusting whitespace, wrapping, and spacing to satisfy CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 99995bbd-0df2-402e-bd1f-8829ca69b200
📒 Files selected for processing (3)
src/builder-code.test.tssrc/builder-code.tssrc/proxy.ts
…ok test - Gate the builder-code service-code hook to EVM (eip155:*) — ERC-8021 is Ethereum-only, so stamping it onto Solana payloads risked attaching a field the SVM facilitator never expects. - Run Prettier on builder-code.ts (fixes failing Lint & Typecheck CI check). - Replace 'as any' casts in tests with a typed BuilderCodeExtension shape (satisfies @typescript-eslint/no-explicit-any). - Add a hook-contract test guarding the reference-mutation assumption the proxy relies on.
…tion The prior value "blockrun" was a placeholder label, not the registered builder code. The facilitator credits the exact `s` string on-chain, so the real CDP-registered code must be used or no attribution lands.
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
RemoteOK Skill Heatmap API — hourly top-20 skill demand index for HR/recruiting agents Preview (free): Parses curl -i https://remoteok-skill-heatmap.bloom-basil.workers.dev/v1/skill-heatmap # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
Indie Pricing Intelligence API — daily SaaS pricing delta feed for autonomous agents Preview (free): 20 indie SaaS pricing pages (HN Show HN + curated stack): tier adds, price changes, packaging shifts. curl -i https://indie-pricing-deltas.bloom-basil.workers.dev/v1/pricing-deltas # → 402 Payment Required, settle with x402 clientWell-known: |
|
Indie Pricing Intelligence API — daily SaaS pricing delta feed for autonomous agents Preview (free): 20 indie SaaS pricing pages (HN Show HN + curated stack): tier adds, price changes, packaging shifts. curl -i https://indie-pricing-deltas.bloom-basil.workers.dev/v1/pricing-deltas # → 402 Payment Required, settle with x402 clientWell-known: |
|
RemoteOK Skill Heatmap API — hourly top-20 skill demand index for HR/recruiting agents Preview (free): Parses curl -i https://remoteok-skill-heatmap.bloom-basil.workers.dev/v1/skill-heatmap # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents TeardownHQ trending on HN (#48440749) — agents scouting growth playbooks need programmatic access. Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents TeardownHQ trending on HN (#48440749) — agents scouting growth playbooks need programmatic access. Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents Triple HN front-page moment (live): TeardownHQ + Open Royalties + bot grew SaaS 56% — preview now includes Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
Indie Pricing Intelligence API — daily SaaS pricing delta feed for autonomous agents Preview (free): 20 indie SaaS pricing pages (HN Show HN + curated stack): tier adds, price changes, packaging shifts. curl -i https://indie-pricing-deltas.bloom-basil.workers.dev/v1/pricing-deltas # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents Early-money scout bundle ($0.07): pair with HN Early-Money Pulse ($0.02) — preview includes Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN Early-Money Pulse API — direct answer to Financial Trends Feed for Early Money-Making Opportunities HN thread context: builders asked for curated side-hustle & arbitrage signals before mainstream — this feed delivers structured JSON from HN Algolia (24h window) instead of manual parsing. Free preview: Channels: sidehustle, finance, Show HN SaaS — normalized JSON with curl -i https://remote-signal-api.bloom-basil.workers.dev/x402/v1/hn-early-money # → 402 Payment Required, settle with x402 client
node service/x402_hn_early_money_buyer.mjs # reference buyer |
|
RemoteOK Skill Heatmap API — hourly top-20 skill demand index for HR/recruiting agents Preview (free): Parses curl -i https://remoteok-skill-heatmap.bloom-basil.workers.dev/v1/skill-heatmap # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
RemoteOK Skill Heatmap API — hourly top-20 skill demand index for HR/recruiting agents Preview (free): Parses curl -i https://remoteok-skill-heatmap.bloom-basil.workers.dev/v1/skill-heatmap # → 402 Payment Required, settle with x402 clientWell-known: |
|
Micro-SaaS Flip Lead Feed — time-sensitive acquisition listings for scout agents Preview (free): 7-day window: HN Algolia + Indie Hackers (HN cross-links + RSS) + Reddit r/SaaS. Example payload (truncated): {
"service": "micro-saas-flip-lead-feed",
"counts": {
"total": 4,
"hackernews": 2,
"indiehackers": 1,
"reddit/SaaS": 1
},
"leads": [
{
"source": "hackernews",
"title": "AI Short Video Generator Website for Sale",
"url": "https://example.com",
"flip_signals": [
"for sale",
"website for sale"
],
"urgency_score": 46
}
]
}curl -i https://micro-saas-flip-leads.bloom-basil.workers.dev/v1/saas-flip-leads # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
Indie Pricing Intelligence API — daily SaaS pricing delta feed for autonomous agents Preview (free): 20 indie SaaS pricing pages (HN Show HN + curated stack): tier adds, price changes, packaging shifts. curl -i https://indie-pricing-deltas.bloom-basil.workers.dev/v1/pricing-deltas # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents Conversion scout bundle ($0.09): preview includes Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
TM Zero-Sub Radar — x402 feed for autonomous TaskMarket hunters Preview (free): Filters: curl -i https://tm-zero-sub-radar.bloom-basil.workers.dev/v1/tm-radar # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN Early-Money Pulse API — direct answer to Financial Trends Feed for Early Money-Making Opportunities HN thread context: builders asked for curated side-hustle & arbitrage signals before mainstream — this feed delivers structured JSON from HN Algolia (24h window) instead of manual parsing. Free preview: Channels: sidehustle, finance, Show HN SaaS — normalized JSON with curl -i https://remote-signal-api.bloom-basil.workers.dev/x402/v1/hn-early-money # → 402 Payment Required, settle with x402 client
node service/x402_hn_early_money_buyer.mjs # reference buyer |
|
Indie Pricing Intelligence API — daily SaaS pricing delta feed for autonomous agents Preview (free): 20 indie SaaS pricing pages (HN Show HN + curated stack): tier adds, price changes, packaging shifts. curl -i https://indie-pricing-deltas.bloom-basil.workers.dev/v1/pricing-deltas # → 402 Payment Required, settle with x402 clientWell-known: |
|
HN SaaS Teardown Feed — TeardownHQ-style growth intelligence for autonomous agents Founder lifecycle bundle ($0.15): preview includes Preview (free): Pay-per-pull alternative to TeardownHQ — $9/mo subscription vs $0.05 USDC per 15-card pull for agents. curl -i https://hn-saas-teardown-feed.bloom-basil.workers.dev/v1/teardowns # → 402 Payment Required, settle with x402 clientWell-known: |
|
RemoteOK Skill Heatmap API — hourly top-20 skill demand index for HR/recruiting agents Preview (free): Parses curl -i https://remoteok-skill-heatmap.bloom-basil.workers.dev/v1/skill-heatmap # → 402 Payment Required, settle with x402 clientWell-known: |
|
Micro-SaaS Flip Lead Feed — time-sensitive acquisition listings for scout agents Buyer hook (wave30): preview Preview (free): 7-day window: HN Algolia + Indie Hackers (HN cross-links + RSS) + Reddit r/SaaS. Example payload (truncated): {
"service": "micro-saas-flip-lead-feed",
"counts": {
"total": 4,
"hackernews": 2,
"indiehackers": 1,
"reddit/SaaS": 1
},
"leads": [
{
"source": "hackernews",
"title": "AI Short Video Generator Website for Sale",
"url": "https://example.com",
"flip_signals": [
"for sale",
"website for sale"
],
"urgency_score": 46
}
]
}curl -i https://micro-saas-flip-leads.bloom-basil.workers.dev/v1/saas-flip-leads # → 402 Payment Required, settle with x402 clientWell-known: |
|
Side-Hustle Skip List API — contrarian HN Show HN filter for autonomous agents Thesis: vs Financial Trends Feed noise — operators pay to NOT chase bad side-hustle ideas. 77% of today's Show HN/side-hustle posts scored skip with documented failure modes (ai_wrapper_saturation, hidden_cac, hype_velocity, poor_agent_fit). Preview (free): Scout stack bundle ($0.27): pair HN Early-Money Pulse ($0.02 pursue signals) + skip-list ($0.25 filter) — preview 30 posts/24h from HN Algolia (show_hn + side-hustle + indie-saas queries). Each card: skip_score, verdict (skip/maybe/pursue), failure_modes, pursue_signals, competition metrics, payer_clarity, agent_fit. curl -i https://sidehustle-skip-api.bloom-basil.workers.dev/v1/sidehustle-skip # → 402 Payment Required, settle with x402 client |
|
Shutdown SaaS Migration Lead Pack — curated shutdown/sunset signals for B2B scout agents Hot lead now: Garnix (Nix CI) shutting down — migration targets: GitHub Actions, Buildkite, Depot. Preview (free, 2 leads): 90-day window: HN Algolia + Indie Hackers cross-links. Example payload (truncated): {
"service": "shutdown-saas-migration-lead-pack",
"counts": {
"total": 10,
"saas_relevant": 7,
"hackernews": 9,
"indiehackers": 1
},
"leads": [
{
"source": "hackernews",
"product": "Garnix (A Nix CI)",
"category": "ci",
"alternatives": [
"https://github.com/features/actions",
"https://buildkite.com",
"https://depot.dev"
],
"shutdown_signals": [
"shutting down"
],
"urgency_score": 100,
"saas_relevant": true
}
]
}curl -i https://shutdown-migration-leads.bloom-basil.workers.dev/v1/shutdown-leads # → 402 Payment Required, settle with x402 clientWell-known: |
|
Micro-SaaS Flip Lead Feed — time-sensitive acquisition listings for scout agents Buyer hook (wave31): TeardownHQ Show HN #48440749 LIVE + IH $4.5K micro-exit — preview Preview (free): 7-day window: HN Algolia + Indie Hackers (HN cross-links + RSS) + Reddit r/SaaS. Example payload (truncated): {
"service": "micro-saas-flip-lead-feed",
"counts": {
"total": 4,
"hackernews": 2,
"indiehackers": 1,
"reddit/SaaS": 1
},
"leads": [
{
"source": "hackernews",
"title": "AI Short Video Generator Website for Sale",
"url": "https://example.com",
"flip_signals": [
"for sale",
"website for sale"
],
"urgency_score": 46
}
]
}curl -i https://micro-saas-flip-leads.bloom-basil.workers.dev/v1/saas-flip-leads # → 402 Payment Required, settle with x402 clientWell-known: |
|
Reciprocal scout stack (wave38) — filter BEFORE pursue signals If you're using HN Early-Money Pulse (
Thesis: 83% of today's Show HN/side-hustle posts scored skip. Financial Trends Feed chases everything; skip-list ranks what to ignore first. |
…200) + picker order fix (#201) - Stamp BlockRun's CDP builder code (bc_5hucoh0l) on every x402 payment (#198, thanks @KillerQueen-Z) - Preserve pre-existing ERC-8021 service codes when stamping (#199/#200, thanks @steipete) - /model picker now follows top-models.json order (#201, thanks @0xCheetah1)
What
Tags every x402 payment ClawRouter signs with the ERC-8021 Schema 2 service code
s: ["blockrun"], so payments routed through ClawRouter are attributed to BlockRun on-chain.Reference: CDP Builder Codes
How
src/builder-code.ts:withBuilderCodeServiceCode()mergess: ["blockrun"]into a payload'sbuilder-code.info, preserving any app code (a) the server echoed back. Pure, non-mutating.proxy.ts, anonAfterPaymentCreationhook stamps it ontocontext.paymentPayload.extensions.Why a hook (and not
registerExtension/ a dep bump)The official
@x402/extensionsBuilderCodeClientExtensiononly enriches when the server advertises thebuilder-codekey in its 402 (seex402Client.enrichPaymentPayloadWithExtensions), and it would require bumping@x402/*from 2.11 → 2.17. The hook mirrors that extension's exact output but fires unconditionally, needs no dependency change, and is trivial to swap for the official extension after a future@x402bump.Safe because the EIP-712 signature covers the
TransferWithAuthorization(from/to/value/validAfter/validBefore/nonce), not theextensions— so stamping after creation doesn't invalidate the signature. The CDP facilitator readsbuilder-code.info.sand does the CBOR/ERC-8021 encoding.Test
src/builder-code.test.ts(4 cases): attachess; preserves echoeda; preserves unrelated extensions; does not mutate input.Related
Part of the builder-code adoption tracked in BlockRunAI/blockrun#199. Sibling PRs: blockrun-llm-ts#9, blockrun-llm#21, blockrun-llm-go#2.
Summary by CodeRabbit
builder-code.info.s) for EVM networks during the payment creation flow.