Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions features/gasless-execution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,11 @@ If Relay cannot map a custom error selector to a known contract error, the respo
encodeAbiParameters,
toHex,
} from "viem";
import {
toPackedUserOperation,
getUserOperationHash,
entryPoint07Abi,
} from "viem/account-abstraction";
import { base } from "viem/chains";
import { UserOperation } from "./types.ts";
import { entryPointAbi, smartAccountAbi } from "./abis.ts";
Expand All @@ -576,29 +581,42 @@ If Relay cannot map a custom error selector to a known contract error, the respo
transport: http()
});

const userOpPackHash = keccak256(packUserOp(userOp));

const encoded = encodeAbiParameters(
[
{ type: "bytes32" }, // userOp hash
{ type: "address" }, // entryPoint
{ type: "uint256" }, // chainId
],
[userOpPackHash, ENTRY_POINT, BigInt(base.id)],
);
const userOp: UserOperation = {
sender: YOUR_WALLET_ADDRESS,
nonce: 0n, // Replace with actual nonce from smartAccountAbi.getNonce()
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",
Comment on lines +587 to +598

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

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.

signature: "0x",
};

const userOpHash = keccak256(encoded);
const userOpHash = getUserOperationHash({
chainId: base.id,
entryPointAddress: ENTRY_POINT,
entryPointVersion: "0.7",
userOperation: userOp,
});

const signature = await walletClient.signMessage({
message: { raw: userOpHash },
});

const signedUserOp: UserOperation = { ...userOp, signature };
const packedSignedUserOp = toPackedUserOperation(signedUserOp);

const handleOpsData = encodeFunctionData({
abi: entryPointAbi,
abi: entryPoint07Abi,
functionName: "handleOps",
args: [[signedUserOp], BENEFICIARY],
args: [[packedSignedUserOp], BENEFICIARY],
});
```
```typescript types.ts
Expand Down
Loading