Skip to content

docs: fix missing userOp declaration - #452

Closed
leonschh wants to merge 4 commits into
relayprotocol:mainfrom
leonschh:patch-2
Closed

docs: fix missing userOp declaration#452
leonschh wants to merge 4 commits into
relayprotocol:mainfrom
leonschh:patch-2

Conversation

@leonschh

@leonschh leonschh commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Issue

The ERC-4337 gasless execution example references userOp and packUserOp without declaring or importing them, causing ReferenceError when users copy the example.

Impact

  • Developers cannot successfully implement gasless ERC-4337 transfers using the documentation
  • Poor developer experience for a core Relay feature

Fix

  • Added import: import { packUserOp } from "viem/account-abstraction")
  • Added userOp object declaration with placeholder values and inline comments guiding replacement

Validation

  • Example now includes all necessary declarations for the ERC-4337 flow
  • Placeholder comments clarify required user modifications

## Issue
The ERC-4337 gasless execution example references `userOp` and `packUserOp` without declaring or importing them, causing `ReferenceError` when users copy the example.

## Impact
- Developers cannot successfully implement gasless ERC-4337 transfers using the documentation
- Poor developer experience for a core Relay feature

## Fix
- Added import: `import { packUserOp } from "viem/account-abstraction")`
- Added `userOp` object declaration with placeholder values and inline comments guiding replacement

## Validation
- Code now compiles without `ReferenceError`
- Example structure follows ERC-4337 specification
- Placeholder comments clarify required user modifications

## Related
- `features/gasless-execution.mdx` (lines 581-590)
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

The documentation example requires correction before developers can reliably copy, type-check, and submit the v0.7 user operation.

Findings

  1. P1 Operation type remains v0.6
  2. P1 Empty paymaster becomes present
  3. P1 Legacy fields vanish in v0.7

Summary

  • The ERC-4337 guide updates its example to use viem’s EntryPoint v0.7 helpers, but the accompanying operation type still uses the prior v0.6 field layout. A copied example therefore cannot type-check as written. The default no-paymaster configuration also supplies a literal paymaster value that needs to be represented as absent.
  • T-Rex validation blocked The command-execution service disconnected after the isolated viem and TypeScript dependencies were installed. This prevented completion of both the compiler reproduction and the runtime packing comparison for the displayed paymaster configuration.

Reviews (4) · Last reviewed commit: "fix(docs): use EntryPoint v0.7"

Comment thread features/gasless-execution.mdx Outdated
Comment thread features/gasless-execution.mdx Outdated
Comment thread features/gasless-execution.mdx Outdated
Comment on lines +587 to +594
initCode: "0x",
callData: "0x", // Replace with the actual call data for the operation
callGasLimit: 50000n,
verificationGasLimit: 100000n,
preVerificationGas: 50000n,
maxFeePerGas: 0n,
maxPriorityFeePerGas: 0n,
paymasterAndData: "0x",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Legacy fields vanish in v0.7

This example requests EntryPoint v0.7 but defines initCode and paymasterAndData, which are v0.6 fields. viem accepts the locally declared object structurally, then ignores both values while hashing and packing. A copied account-deployment or sponsored-operation flow therefore signs and submits an operation without its documented factory or paymaster data. Define the v0.7 fields (factory, factoryData, paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, and paymasterData) in both the example and UserOperation type.

Artifacts

Focused viem ERC-4337 reproduction source

  • TypeScript source created in a disposable project to compile and run the docs-shaped and correct v0.7 user operations, showing the legacy fields are ignored.

Type-check log for the docs-shaped user operation

  • Executed `npx tsc --noEmit` against the docs-shaped reproduction and captured exit code 0, showing the local documentation type permits the incorrect v0.7 call.

Runtime log for viem 2.56.3 ERC-4337 reproduction

  • Executed the focused reproduction with viem 2.56.3 and captured empty packed legacy fields, unchanged legacy-only hash, and correct v0.7 packing, proving the documented fields are ignored.

View artifacts

T-Rex Ran code and verified through T-Rex

Comment on lines +587 to +598
factory: "0x",
factoryData: "0x",
callData: "0x", // Replace with the actual call data for the operation
callGasLimit: 50000n,
verificationGasLimit: 100000n,
preVerificationGas: 50000n,
maxFeePerGas: 0n,
maxPriorityFeePerGas: 0n,
paymaster: "0x",
paymasterVerificationGasLimit: 0n,
paymasterPostOpGasLimit: 0n,
paymasterData: "0x",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Operation type remains v0.6

When a developer copies the displayed example.ts and types.ts snippets, the v0.7 operation is checked against a type that still requires initCode and paymasterAndData and excludes the new factory and paymaster fields, causing TypeScript compilation to fail.

Comment on lines +595 to +598
paymaster: "0x",
paymasterVerificationGasLimit: 0n,
paymasterPostOpGasLimit: 0n,
paymasterData: "0x",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Empty paymaster becomes present

When the default example is used without a paymaster, toPackedUserOperation treats the truthy "0x" paymaster as present and produces non-empty paymaster data containing the zero address, causing EntryPoint validation to reject the operation.

@leonschh

Copy link
Copy Markdown
Contributor Author

I am closing this PR. Initially, I only wanted to fix the example in features/gasless-execution.mdx, but during the review process, I realized the issue runs deeper and extends beyond a single snippet.

@leonschh leonschh closed this Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants