Overview
Builder Codes (ERC-8021) allow app developers to attribute onchain activity to their application. This guide explains how to integrate Builder Code attribution on Base with Turnkey-signed transactions using viem’sdataSuffix option.
By appending an encoded Builder Code to transaction data, you can track usage analytics on base.dev and qualify for potential future rewards.
Getting started
The first step is to set up your Turnkey organization and account. By following the Quickstart guide, you should have:- A root user with a public/private API key pair within the Turnkey parent organization
- An organization ID
- A wallet with an Ethereum account created within this organization, funded with ETH on Base Mainnet
- A Builder Code from base.dev (found under Settings > Builder Code)
viemversion2.45.0or higher
Encode your Builder Code
Builder codes are displayed in their decoded format on base.dev (e.g.bc_b7k3p9da). They need to be encoded into a hex dataSuffix (ending in 80218021) before use.
Use the ox package to encode your Builder Code:
Set up the Turnkey signer with attribution
This example uses@turnkey/sdk-server with @turnkey/viem to create a Turnkey signer and configure the wallet client with the dataSuffix option. The same approach works with any of our client-side SDKs (React, React Native, Flutter, etc.) since the dataSuffix configuration is handled at the viem wallet client level.
Send a transaction
With thedataSuffix configured at the client level, all transactions automatically include your Builder Code. No changes are needed to individual transaction calls.
Verify attribution
To confirm your Builder Code is being appended correctly:- Check base.dev: Visit base.dev, select Onchain from the transaction type dropdown, and verify your attribution counts are incrementing under Total Transactions.
-
Use a block explorer: Find your transaction on Basescan, view the input data field, and verify the last 16 bytes contain the
8021repeating pattern. Decode the suffix to confirm your Builder Code is present. - Use the open source validation tool: Use the Builder Code Validation tool to check a transaction or UserOperation hash for attribution.