Skip to content

feat(x402): attach BlockRun builder-code service code to payments#9

Open
KillerQueen-Z wants to merge 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/builder-code-service-code
Open

feat(x402): attach BlockRun builder-code service code to payments#9
KillerQueen-Z wants to merge 1 commit into
BlockRunAI:mainfrom
KillerQueen-Z:feat/builder-code-service-code

Conversation

@KillerQueen-Z

Copy link
Copy Markdown
Contributor

What

Tags every x402 payment this SDK signs with the ERC-8021 Schema 2 service code s: ["blockrun"], so payments originated through BlockRun's client SDK are attributed to BlockRun on-chain.

Reference: CDP Builder Codes

How

  • New helper withBuilderCodeServiceCode() merges s: ["blockrun"] into the payload's builder-code.info, preserving any app code (a) the server echoes back in its 402 response (so we never clobber seller attribution).
  • Wired into both payload builders — EVM (createPaymentPayload) and Solana (createSolanaPaymentPayload).
  • The service code is exported as BLOCKRUN_SERVICE_CODE for reuse.

Why this is all the client needs

The CBOR / ERC-8021 calldata encoding is done by the CDP facilitator at settlement time (it reads builder-code.info.s from the payment payload). The client only sets a JSON field — so this needs no new dependency, no @x402/extensions, no CBOR and works unconditionally on every payment.

Scope / inheritance

This SDK (@blockrun/llm) is the payment layer for @blockrun/mcp, @blockrun/clawrouter-codex, and other TS consumers — they inherit this attribution automatically once they bump to the released version.

Buyer-side only. Seller-side app code (a) on the gateway is tracked separately (needs a registered code from dashboard.base.org).

Test

  • Added 2 cases to test/unit/x402.test.ts: service code is always attached; server-echoed a is preserved when s is added.
  • Full suite green: 197 passed, typecheck clean.

Tag every x402 payment this SDK signs with the ERC-8021 Schema 2 service
code s: ["blockrun"] so BlockRun-originated traffic is attributed on-chain.
Merged into builder-code.info.s in both the EVM and Solana payload builders,
preserving any app code (a) the server echoes back in its 402. Encoding into
settlement calldata is handled by the CDP facilitator; the client only sets
the JSON field, so no new dependency or CBOR is required.

Docs: https://docs.cdp.coinbase.com/x402/core-concepts/builder-codes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant