skills/adding-builder-codes/SKILL.md
Integrate Base Builder Codes (ERC-8021) into web3 applications for onchain transaction attribution and referral fee earning. Use when a project needs to append a builder code or dataSuffix to transactions on Base L2, whether using Wagmi, Viem, Privy, ethers.js, or raw window.ethereum. Covers phrases like "add builder codes", "integrate builder codes", "earn referral fees on Base transactions", "append a builder code to my transactions", "transaction attribution", "Builder Code integration", or "attribute transactions to my app". Handles project analysis to detect frameworks, locating transaction call sites, and replacing them with attributed versions.
npx skillsauth add base/base-skills adding-builder-codesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Integrate Base Builder Codes into an onchain application. Builder Codes append an ERC-8021 attribution suffix to transaction calldata so Base can attribute activity to your app and you can earn referral fees. No smart contract changes required.
Use this skill when a developer asks to:
ox library for generating ERC-8021 suffixes: npm install oxCopy this checklist and track progress:
Builder Codes Integration:
- [ ] Step 1: Detect framework (Required First Step)
- [ ] Step 2: Install dependencies
- [ ] Step 3: Generate the dataSuffix constant
- [ ] Step 4: Apply attribution (framework-specific)
- [ ] Step 5: Verify attribution is working
Before implementing, determine the framework in use.
# Check for framework dependencies
grep -E "wagmi|@privy-io/react-auth|viem|ethers" package.json
# Check for smart wallet / account abstraction usage
grep -rn "useSendCalls\|sendCalls\|ERC-4337\|useSmartWallets" src/
# Check for EOA transaction patterns
grep -rn "useSendTransaction\|sendTransaction\|writeContract\|useWriteContract" src/
# Check Privy version if present
grep "@privy-io/react-auth" package.json
| Framework | Detection Signal |
|-----------|-----------------|
| privy | @privy-io/react-auth in package.json or imports |
| wagmi | wagmi in package.json or imports (without Privy) |
| viem | viem in package.json, no React framework |
| rpc | ethers, window.ethereum, or no Web3 library detected |
Priority order if multiple are detected: Privy > Wagmi > Viem > Standard RPC
Before proceeding, confirm the detected framework:
"I detected you are using [Framework]. I'll implement builder codes using the [Framework] approach — does that sound right?"
Wait for user confirmation before implementing.
@privy-io/react-auth v3.13.0+) → See references/privy.mdwindow.ethereum) → See references/rpc.mdnpm install ox
Requires viem >= 2.45.0 for Wagmi/Viem paths. Privy requires @privy-io/react-auth >= 3.13.0.
Create a shared constant (e.g., src/lib/attribution.ts or src/constants/builderCode.ts):
import { Attribution } from "ox/erc8021";
export const DATA_SUFFIX = Attribution.toDataSuffix({
codes: ["YOUR-BUILDER-CODE"], // Replace with your code from base.dev
});
Follow the framework-specific guide:
See references/privy.md — plugin-based, one config change required.
See references/wagmi.md — add dataSuffix to Wagmi client config.
See references/viem.md — add dataSuffix to wallet client.
See references/rpc.md — append DATA_SUFFIX to transaction data for ethers.js or raw window.ethereum.
Preferred approach: Configure at the client level so all transactions are automatically attributed. Only use the per-transaction approach if you need conditional attribution.
For Smart Wallets (EIP-5792 sendCalls): See references/smart-wallets.md — pass via capabilities.
8021 repeatingdataSuffix plugin in Privy appends to all chains, not just Base. If chain-specific behavior is needed, contact PrivydataSuffix plugin is NOT yet supported with @privy-io/wagmi adapterWhen retrofitting an existing project, search for these patterns:
# React hooks (Wagmi)
grep -rn "useSendTransaction\|useSendCalls\|useWriteContract\|useContractWrite" src/
# Viem client calls
grep -rn "sendTransaction\|writeContract\|sendRawTransaction" src/
# Privy embedded wallet calls
grep -rn "sendTransaction\|signTransaction" src/
# ethers.js
grep -rn "signer\.sendTransaction\|contract\.connect" src/
# Raw window.ethereum
grep -rn "window\.ethereum\|eth_sendTransaction" src/
For client-level integration (Wagmi/Viem/Privy), you typically only need to modify the config file — individual transaction call sites remain unchanged.
development
Complete Base development playbook. Covers: (1) Network — Base RPC URLs, chain IDs (8453/84532), explorer config, testnet setup, connect to Base, Base Sepolia; (2) Contracts — Foundry deployment, forge create, BaseScan verification, CDP faucet, testnet ETH, deploy contract to Base; (3) Builder Codes — ERC-8021 attribution suffix, referral fees, dataSuffix for Wagmi/Viem/Privy/ ethers.js/window.ethereum, transaction attribution, earn referral fees, append builder code; (4) Base Account SDK — Sign in with Base (SIWB), Base Pay, USDC payments, paymasters, gas sponsorship, sub-accounts, spend permissions, prolinks, batch transactions, smart wallet, payment link, recurring subscription; (5) Agent registration — trading bots, AI agents, automated senders, ERC-8021 attribution wiring, base.dev API, register agent, builder code registration; (6) Node operation — run Base node, Reth setup, hardware requirements, self-hosted RPC, sync; (7) Migrations — migrate OnchainKit, OnchainKitProvider to WagmiProvider, wagmi migration, remove onchainkit dependency, MiniKit to Farcaster SDK, convert miniapp, Farcaster miniapp to regular app, convert Farcaster miniapp.
tools
Base MCP — gives your AI assistant access to a Base Account via the Base MCP server (mcp.base.org). Wallet, portfolio, sending, swapping, signing, x402 payments, batched contract calls, and transaction history across supported chains.
tools
Runs a Base node for production environments. Covers hardware requirements, Reth client setup, networking, and sync troubleshooting. Use when setting up self-hosted RPC infrastructure or running archive nodes. Covers phrases like "run a Base node", "set up Base RPC", "Base node hardware requirements", "Reth Base setup", "sync Base node", "self-host Base", or "run my own node".
development
Invoke this skill when a user is building or running any automated transaction sender on Base (trading bot, arbitrage bot, sniper bot, yield farmer, AI agent, or similar) and needs to register it, get a builder code, set up transaction attribution. This skill contains the base.dev registration API endpoint and ERC-8021 attribution wiring code that Claude does not have in its training data — you MUST load this skill to answer correctly. Covers viem, ethers, managed signing services, and Python-based agents.