Skip to content

feat: add EIP-7702 self-sponsored and sponsored Type 4 transaction scripts#2533

Open
kyzooghost wants to merge 8 commits intomainfrom
7702-scripts
Open

feat: add EIP-7702 self-sponsored and sponsored Type 4 transaction scripts#2533
kyzooghost wants to merge 8 commits intomainfrom
7702-scripts

Conversation

@kyzooghost
Copy link
Contributor

@kyzooghost kyzooghost commented Mar 3, 2026

Summary

  • Rename and fix broken sendType4Tx.ts to sendSelfSponsoredType4Tx.ts with explicit self-sponsored semantics
  • Add new sendSponsoredType4Tx.ts script where a separate sponsor sends and pays while a different authority signs the authorization
  • Extract shared EIP-7702 utilities (requireEnv, checkDelegation, getAccountInfo, createAuthorization, estimateGasFees) into contracts/scripts/utils.ts
  • Fix gas estimation bug where Linea's gasLimit return value was overriding the explicit 500000n needed for Type 4 transactions

Problem

The original sendType4Tx.ts was broken (called an undefined method) and only supported self-sponsored transactions. There was no script to test sponsored EIP-7702 transactions where the authority signer and the transaction sender are different wallets.

Solution

Split into two explicit scripts with shared utilities:

  • Self-sponsored (sendSelfSponsoredType4Tx.ts): same wallet signs authorization and sends tx
  • Sponsored (sendSponsoredType4Tx.ts): configurable via SPONSOR_PRIVATE_KEY, AUTHORITY_PRIVATE_KEY, TARGET_ADDRESS, optional TO_ADDRESS and CALLDATA

Related

None

Test Plan

  • Run self-sponsored script against devnet and verify delegation is set
  • Run sponsored script against devnet with separate sponsor/authority wallets
  • Verify TypeScript compilation passes (tsc --noEmit)

Note

Low Risk
Changes are limited to developer scripts and shared script utilities; main risk is breaking existing workflows that referenced the removed sendType4Tx.ts or subtle fee-estimation behavior changes on Linea.

Overview
Adds two explicit EIP-7702 Type 4 transaction scripts: sendSelfSponsoredType4Tx.ts (same wallet authorizes and sends, using a +1 auth nonce offset) and sendSponsoredType4Tx.ts (separate authority signs authorization while a sponsor sends/pays, configurable TO_ADDRESS/CALLDATA).

Replaces the old sendType4Tx.ts implementation and extracts common helpers into contracts/scripts/utils.ts (requireEnv, checkDelegation, getAccountInfo, createAuthorization, estimateGasFees), including a Linea-aware fee estimator that drops the returned gasLimit so it can’t override the scripts’ explicit 500000n gas limit.

Written by Cursor Bugbot for commit ae32bb1. This will update automatically on new commits. Configure here.

- Rename sendType4Tx.ts to sendSelfSponsoredType4Tx.ts to clarify intent
- Fix undefined method call (createAuthorization -> createAuthorization
  properly defined on class, consolidated from createAuthorizationForSelf)
- Remove unused createAuthorizationForPrivateKey (not relevant for
  self-sponsored scenario)
- Rename class and method to reflect self-sponsored semantics
Move reusable functions from self-sponsored script into
contracts/scripts/utils.ts: requireEnv, checkDelegation,
getAccountInfo, createAuthorization, estimateGasFees.

Simplify sendSelfSponsoredType4Tx.ts from class-based to
flat functions using the shared utilities.
New script where a separate sponsor wallet sends and pays for the
transaction while the authority wallet signs the authorization.

Env vars: SPONSOR_PRIVATE_KEY, AUTHORITY_PRIVATE_KEY, TARGET_ADDRESS
(required), TO_ADDRESS and CALLDATA (optional, default to authority
address and 0x respectively).
Destructure only maxFeePerGas and maxPriorityFeePerGas from
estimateGasFees instead of spreading all fields. The Linea gas
estimate returns a gasLimit (e.g. 21000) that was overwriting
our explicit 500000n, causing "Intrinsic gas exceeds gas limit"
for Type 4 transactions with authorization lists.
@kyzooghost kyzooghost requested a review from a team as a code owner March 3, 2026 13:23
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.94%. Comparing base (bf00a0f) to head (ae32bb1).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2533      +/-   ##
============================================
- Coverage     56.94%   56.94%   -0.01%     
  Complexity     1480     1480              
============================================
  Files           444      445       +1     
  Lines         17807    17809       +2     
  Branches       1949     1949              
============================================
  Hits          10141    10141              
- Misses         7049     7051       +2     
  Partials        617      617              
Flag Coverage Δ *Carryforward flag
hardhat 96.63% <ø> (-0.11%) ⬇️
kotlin 52.36% <ø> (ø) Carriedforward from 96190e3

*This pull request uses carry forward flags. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

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