Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Nov 4, 2025


PR-Codex overview

This PR introduces support for extraMetadata in the x402 payment requirements, allowing additional data to be included in payment requests.

Detailed summary

  • Added extraMetadata to the payment request in facilitator.ts.
  • Included extraMetadata in the function parameters in common.ts.
  • Updated the decodePaymentRequest function to accept extraMetadata.
  • Documented extraMetadata as an optional field in types.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Payment requests now accept an optional extraMetadata field, allowing callers to attach arbitrary metadata to x402 payment flows for improved context and processing.
  • Chores

    • Patch release recorded to include extraMetadata support.

@vercel
Copy link

vercel bot commented Nov 4, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Nov 4, 2025 10:16pm
nebula Ready Ready Preview Comment Nov 4, 2025 10:16pm
thirdweb_playground Ready Ready Preview Comment Nov 4, 2025 10:16pm
thirdweb-www Ready Ready Preview Comment Nov 4, 2025 10:16pm
wallet-ui Ready Ready Preview Comment Nov 4, 2025 10:16pm

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

🦋 Changeset detected

Latest commit: ef731a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Nov 4, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

Threaded an optional extraMetadata field through the x402 payment flow: added it to PaymentArgs and forwarded it from decodePaymentRequest into the facilitator accepts request payload.

Changes

Cohort / File(s) Summary
x402 core changes
packages/thirdweb/src/x402/types.ts, packages/thirdweb/src/x402/common.ts, packages/thirdweb/src/x402/facilitator.ts
Added extraMetadata?: Record<string, unknown> to PaymentArgs. decodePaymentRequest now extracts/forwards extraMetadata and facilitator.accepts includes extraMetadata in its POST payload.
Release metadata
\.changeset/four-ghosts-tickle.md
Added changeset entry noting a patch release: "Add support for extraMetadata in x402 payment requirements."

Sequence Diagram(s)

sequenceDiagram
  participant Caller as decodePaymentRequest
  participant Fac as facilitator.accepts
  participant Server as x402 facilitator server

  Caller->>Fac: POST /accepts { amount, chainId, request, extraMetadata } 
  Note right of Caller `#DDEBF7`: extraMetadata forwarded from PaymentArgs
  Fac->>Server: HTTP POST (payload includes extraMetadata)
  Server-->>Fac: 402 + response body/headers
  Fac-->>Caller: structured response (status, headers, body)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Check packages/thirdweb/src/x402/types.ts for correct optional typing and comment.
  • Verify decodePaymentRequest (common.ts) correctly destructures and forwards extraMetadata.
  • Confirm facilitator.accepts (facilitator.ts) includes extraMetadata in the request body and that JSON serialization/typing is consistent.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes a PR-Codex overview summarizing changes, but lacks explicit sections for reviewer notes and testing instructions from the template. Consider adding explicit 'Notes for the reviewer' and 'How to test' sections to match the repository template and provide clearer guidance for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for extra metadata in x402 payment requests.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _X402_Add_support_for_extra_metadata_in_payment_requests

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

Comment @coderabbitai help to get the list of available commands and usage tips.

@joaquim-verges joaquim-verges changed the title [X402] Add support for extra metadata in payment requests [SDK] Add support for extra metadata in x402 payment requests Nov 4, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review November 4, 2025 21:54
@joaquim-verges joaquim-verges requested review from a team as code owners November 4, 2025 21:54
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/thirdweb/src/x402/types.ts (1)

38-39: LGTM! Clean addition of optional metadata field.

The type Record<string, unknown> appropriately allows flexible metadata while avoiding any. The documentation clearly describes the purpose.

Consider enhancing the comment to mention serialization requirements or provide an example of typical usage, but the current documentation is sufficient.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c756994 and ef731a9.

📒 Files selected for processing (4)
  • .changeset/four-ghosts-tickle.md (1 hunks)
  • packages/thirdweb/src/x402/common.ts (2 hunks)
  • packages/thirdweb/src/x402/facilitator.ts (1 hunks)
  • packages/thirdweb/src/x402/types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/four-ghosts-tickle.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/x402/facilitator.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/x402/common.ts
  • packages/thirdweb/src/x402/types.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/x402/common.ts
  • packages/thirdweb/src/x402/types.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/x402/common.ts
  • packages/thirdweb/src/x402/types.ts
**/types.ts

📄 CodeRabbit inference engine (AGENTS.md)

Provide and re‑use local type barrels in a types.ts file

Files:

  • packages/thirdweb/src/x402/types.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/x402/common.ts (2)

47-47: Correct destructuring of the new optional field.

The extraMetadata field is properly extracted from the args parameter.


58-58: Verified: facilitator.accepts() correctly handles extraMetadata.

The implementation properly includes extraMetadata from the args parameter in the request payload (line 284, packages/thirdweb/src/x402/facilitator.ts). The field is correctly serialized alongside other request parameters and passed to the /accepts endpoint without issues.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

size-limit report 📦

Path Size
@thirdweb-dev/nexus (esm) 104.88 KB (0%)
@thirdweb-dev/nexus (cjs) 316.6 KB (0%)

@joaquim-verges joaquim-verges merged commit 1d54cff into main Nov 4, 2025
19 of 21 checks passed
@joaquim-verges joaquim-verges deleted the _X402_Add_support_for_extra_metadata_in_payment_requests branch November 4, 2025 22:13
@joaquim-verges joaquim-verges mentioned this pull request Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants