Skip to content

feat(typescript): add optional builderCode to x402 client and server - #768

Open
ethanoroshiba wants to merge 5 commits into
mainfrom
ethanoroshiba/x402-builder-codes
Open

feat(typescript): add optional builderCode to x402 client and server#768
ethanoroshiba wants to merge 5 commits into
mainfrom
ethanoroshiba/x402-builder-codes

Conversation

@ethanoroshiba

@ethanoroshiba ethanoroshiba commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add optional builderCode on CdpX402Client and createX402Server to auto-attach the x402 builder-code extension (client s, server a)
  • Omit the field → extension left unset; invalid codes rejected at init/create
  • Docs, config schema, and unit coverage for inject / register / override paths

Test plan

  • Unit tests for client + server builder-code wiring pass
  • Client with builderCode attaches extension; without leaves it unset
  • Server with builderCode injects on routes; without leaves unset; route extensions override works

@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@ethanoroshiba

Copy link
Copy Markdown
Contributor Author

Note on facilitator support: the CDP-hosted facilitator supports the builder-code extension, so app (a) and service (s) codes advertised/attached by createX402Server and CdpX402Client are encoded into the ERC-8021 Schema 2 calldata suffix at settlement. No self-hosted facilitator changes are needed to get attribution on the default path.

@ethanoroshiba
ethanoroshiba marked this pull request as ready for review July 29, 2026 21:37
const client = new CdpX402Client({ builderCode: "my_client" });
```

Service codes are only attached when the resource server advertises the `builder-code` extension in its `PaymentRequired` response — against servers that do not, the codes are dropped and the payment proceeds unattributed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should change this and always attribute the client regardless of the server, dont see a good reason to drop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants