feat(x402): stamp BlockRun builder-code service code on payments#13
Open
KillerQueen-Z wants to merge 1 commit into
Open
feat(x402): stamp BlockRun builder-code service code on payments#13KillerQueen-Z wants to merge 1 commit into
KillerQueen-Z wants to merge 1 commit into
Conversation
Tag every x402 payment XClawRouter 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. 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Tags every x402 payment XClawRouter signs with the ERC-8021 Schema 2 service code
s: ["blockrun"], so payments routed through XClawRouter 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 (not
registerExtension/ a dep bump)The official
BuilderCodeClientExtensiononly enriches when the server advertisesbuilder-codein its 402, and needs@x402/*bumped 2.11 → 2.17. The hook mirrors that extension's output but fires unconditionally with no dependency change. Safe because the EIP-712 signature covers the authorization, notextensions; the CDP facilitator readsbuilder-code.info.sand does the CBOR/ERC-8021 encoding.Test
src/builder-code.test.ts(4 cases). Full suite green: 510 passed, typecheck + build (ESM + DTS) clean.Related
Mirror of BlockRunAI/ClawRouter#198. Tracked in BlockRunAI/blockrun#199. Sibling PRs: blockrun-llm-ts#9, blockrun-llm#21, blockrun-llm-go#2.