Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changeset/kip-redundant-7702-auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"permissionless": patch
---

Skip adding `authorization` to `sendTransaction` when the account is already 7702-attached to the same address.
This prevents redundant Type-4 overhead in UserOps and reduces calldata/gas; no changes required for consumers.
18 changes: 17 additions & 1 deletion packages/permissionless/actions/smartAccount/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type {
Client,
Hash,
SendTransactionParameters,
Transport
Transport,
getCode
} from "viem"
import {
type SendUserOperationParameters,
Expand Down Expand Up @@ -95,6 +96,21 @@ export async function sendTransaction<

if (!to) throw new Error("Missing to address")

if ("authorization" in args && args.authorization) {
const bytecode = await getCode(client, { address: account.address })

if (bytecode) {
const bc = bytecode.toLowerCase()
// "0x" + "ef0100" + 40 hex (address)
if (bc.startsWith("0xef0100") && bc.length >= 48) {
const attachedAddress = "0x" + bc.slice(8, 48) // <-- exact 20 bytes
const target = (args.authorization as any).address?.toLowerCase?.()
if (target && attachedAddress === target) {
delete (args as any).authorization
}
}
}
}
userOpHash = await getAction(
client,
sendUserOperation,
Expand Down