x402 Builder Codes Setup
First, ask the user: Are you a buyer/client (you make payment requests) or a seller (you serve paid endpoints)? Then follow the corresponding path below.Path A: Buyer / Client
Integrate a Base Builder Code into your x402 client so every payment you drive on Base is attributed to your app onchain.Steps
-
Check for a Base Builder Code
Ask the user if they already have a Base Builder Code. If not, direct them to:
Go to https://base.dev and log in. Register your app name, add and verify your domain, then go to Settings → Builder Codes to get your code.
The code looks likebc_b7k3p9daand must match^[a-z0-9_]{1,32}$(lowercase letters, digits, underscores, 1–32 characters). -
Install dependencies
-
Register the BuilderCodeClientExtension
In the file where you create your x402 client, import and register
BuilderCodeClientExtension. Replace"your_builder_code"with the user’s actual Base Builder Code. -
Verify attribution
After an x402 payment settles on Base, confirm your Builder Code was recorded. Get the settlement transaction hash and run:
Assert:
attribution?.s === "your_builder_code". Alternatively, paste the transaction hash into https://buildercode-checker.vercel.app/ to inspect attribution without writing any code.
Path B: Seller / Resource Server
Declare a Base Builder Code on your x402 resource server so every payment your endpoint receives on Base is attributed to your app onchain.Steps
-
Check for a Base Builder Code
Ask the user if they already have a Base Builder Code. If not, direct them to:
Go to https://base.dev and log in. Register your app name, add and verify your domain, then go to Settings → Builder Codes to get your code.
The code looks likebc_b7k3p9daand must match^[a-z0-9_]{1,32}$(lowercase letters, digits, underscores, 1–32 characters). -
Install dependencies
-
Declare the BuilderCodeExtension on your routes
Add
declareBuilderCodeExtensionto theextensionsfield of each route you want attributed. Replace"your_builder_code"with the user’s actual Base Builder Code.For Go, importgithub.com/x402-foundation/x402/go/v2/extensions/buildercodeand callbuildercode.DeclareBuilderCodeExtension("your_builder_code")in the route’sExtensionsmap. -
Verify attribution
After a payment settles, paste the transaction hash into https://buildercode-checker.vercel.app/ or parse the calldata programmatically.
Assert: the
afield in the parsed attribution matches your declared builder code.
Notes
- Dashboard: Attribution data and app metrics are visible at https://base.dev.
- Docs: Full details at https://docs.cdp.coinbase.com/x402/core-concepts/builder-codes.