-
Notifications
You must be signed in to change notification settings - Fork 391
fix: Update 8021 docs to include dataSuffix capability #796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+166
−6
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
docs/base-account/reference/core/capabilities/dataSuffix.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| --- | ||
| title: "dataSuffix" | ||
| description: "Append arbitrary data to transaction calldata for attribution tracking" | ||
| --- | ||
|
|
||
| Defined in [ERC-8021](https://eip.tools/eip/8021) | ||
|
|
||
| <Info> | ||
| The dataSuffix capability allows apps to append arbitrary hex-encoded bytes to transaction calldata. This enables attribution tracking, allowing platforms to identify which app originated a transaction and distribute rewards accordingly. | ||
| </Info> | ||
|
|
||
| ## Parameters | ||
|
|
||
| <ParamField body="value" type="`0x${string}`" required> | ||
| Hex-encoded bytes to append to the transaction calldata. This value is appended to the end of the calldata for each call in the batch. | ||
| </ParamField> | ||
|
|
||
| <ParamField body="optional" type="boolean"> | ||
| When `true`, the wallet may ignore the capability if it doesn't support it. When `false` or omitted, the wallet must support the capability or reject the request. | ||
| </ParamField> | ||
|
|
||
| ## Returns | ||
|
|
||
| <ResponseField name="dataSuffix" type="object"> | ||
| The data suffix capability configuration for the specified chain. | ||
|
|
||
| <Expandable title="DataSuffix capability properties"> | ||
| <ResponseField name="supported" type="boolean"> | ||
| Indicates whether the wallet supports appending data suffixes to transaction calldata. | ||
| </ResponseField> | ||
| </Expandable> | ||
| </ResponseField> | ||
|
|
||
| ## Example Usage | ||
|
|
||
| <RequestExample> | ||
| ```typescript Check DataSuffix Support | ||
| const capabilities = await provider.request({ | ||
| method: 'wallet_getCapabilities', | ||
| params: [userAddress] | ||
| }); | ||
|
|
||
| const dataSuffixSupport = capabilities["0x2105"]?.dataSuffix; | ||
| ``` | ||
|
|
||
| ```typescript Send Transaction with DataSuffix | ||
| const result = await provider.request({ | ||
| method: "wallet_sendCalls", | ||
| params: [{ | ||
| version: "1.0", | ||
| chainId: "0x2105", | ||
| from: userAddress, | ||
| calls: [{ | ||
| to: "0x1234567890123456789012345678901234567890", | ||
| value: "0x0", | ||
| data: "0xa9059cbb000000000000000000000000..." | ||
| }], | ||
| capabilities: { | ||
| dataSuffix: { | ||
| value: "0x1234567890abcdef1234567890abcdef", | ||
| optional: true | ||
| } | ||
| } | ||
| }] | ||
| }); | ||
| ``` | ||
| </RequestExample> | ||
|
|
||
| <ResponseExample> | ||
| ```json Capability Response (Supported) | ||
| { | ||
| "0x2105": { | ||
| "dataSuffix": { | ||
| "supported": true | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ```json Capability Response (Unsupported) | ||
| { | ||
| "0x2105": { | ||
| "dataSuffix": { | ||
| "supported": false | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
| </ResponseExample> | ||
|
|
||
| ## Error Handling | ||
|
|
||
| | Code | Message | Description | | ||
| | ---- | ------- | ----------- | | ||
| | 4100 | Data suffix not supported | Wallet does not support data suffix functionality | | ||
| | 5700 | DataSuffix capability required | Transaction requires dataSuffix but wallet doesn't support it | | ||
|
|
||
| ## How It Works | ||
|
|
||
| When a wallet receives a `dataSuffix` capability, the suffix is appended to `userOp.callData`. The suffix bytes are concatenated directly to the end of the calldata, making them available for onchain parsing and attribution. | ||
|
|
||
| ## Use Cases | ||
|
|
||
| ### Builder Codes Attribution | ||
|
|
||
| The primary use case for `dataSuffix` is [Builder Codes](/base-chain/quickstart/builder-codes) attribution. Builder Codes are unique identifiers that allow apps to receive attribution for onchain activity they generate. | ||
|
|
||
| ```typescript | ||
| import { Attribution } from "ox/erc8021"; | ||
|
|
||
| // Example: Using Builder Code with dataSuffix. | ||
| // Using the ox/erc8021 package to generate the ERC-8021 suffix from your builder code. | ||
| const builderCodeSuffix = Attribution.toDataSuffix({ | ||
| codes: ['bc_foobar'], // Get your code from base.dev | ||
| }); | ||
|
|
||
| await provider.request({ | ||
| method: "wallet_sendCalls", | ||
| params: [{ | ||
| version: "1.0", | ||
| chainId: "0x2105", | ||
| from: userAddress, | ||
| calls: [{ | ||
| to: contractAddress, | ||
| value: "0x0", | ||
| data: swapCallData | ||
| }], | ||
| capabilities: { | ||
| dataSuffix: { | ||
| value: builderCodeSuffix, | ||
| optional: true | ||
| } | ||
| } | ||
| }] | ||
| }); | ||
| ``` | ||
|
|
||
| Register on [base.dev](https://base.dev) to get your Builder Code for proper attribution. | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Use with Builder Codes**: Register on [base.dev](https://base.dev) to get your Builder Code for proper attribution | ||
| 2. **Set optional appropriately**: Use `optional: true` if your app can function without attribution tracking | ||
| 3. **Keep suffixes small**: Larger suffixes increase gas costs | ||
|
|
||
| <Info> | ||
| For wallet developers implementing dataSuffix support, see the [For Wallet Developers](/base-chain/quickstart/builder-codes#for-wallet-developers) section in the Builder Codes guide. | ||
| </Info> | ||
|
|
||
| ## Related Capabilities | ||
|
|
||
| - [paymasterService](/base-account/reference/core/capabilities/paymasterService) - Combine with sponsored transactions | ||
| - [atomic](/base-account/reference/core/capabilities/atomic) - Use with atomic batch transactions | ||
|
|
||
| import PolicyBanner from "/snippets/PolicyBanner.mdx"; | ||
|
|
||
| <PolicyBanner /> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a title here if you can