Skip to content

Conversation

@AyushBherwani1998
Copy link
Member

@AyushBherwani1998 AyushBherwani1998 commented Oct 23, 2025

Description

Currently, user need to be upgraded MetaMask smart account in order to use the ERC-7715. Adds an additional step for dApp to handle the upgrade.

Issue(s) fixed

Fixes #

Preview

Checklist

  • If this PR updates or adds documentation content that changes or adds technical meaning, it has received an approval from an engineer or DevRel from the relevant team.
  • If this PR updates or adds documentation content, it has received an approval from a technical writer.

Note

Adds a Smart Account upgrade check (with EIP-7702-based code sample) to the ERC‑7715 guide and renumbers subsequent steps in both current and versioned docs.

  • Docs (ERC-7715 guide):
    • New prerequisite step: Add “Check the EOA account code” before requesting permissions, explaining Smart Account upgrade requirement and how to handle upgrades.
      • Include code to fetch publicClient.getCode(...), derive delegatorAddress per EIP-7702, and compare with getDeleGatorEnvironment(...).implementations.EIP7702StatelessDeleGatorImpl to detect upgrade.
    • Renumbered steps: Request ERC-7715 permissions → step 5, Set up a Viem client → step 6, Redeem ERC-7715 permissions → step 7.
    • Applied to both delegation-toolkit/guides/erc7715/execute-on-metamask-users-behalf.md and versioned docs at gator_versioned_docs/version-0.13.0/....

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

@AyushBherwani1998 AyushBherwani1998 requested review from a team as code owners October 23, 2025 22:04
@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
metamask-docs Ready Ready Preview Comment Oct 24, 2025 0:48am

cursor[bot]

This comment was marked as outdated.


// If account is not upgraded to MetaMask smart account, you can
// either upgrade programmatically or ask the user to switch to a smart account manually.
const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase();
Copy link

Choose a reason for hiding this comment

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

Bug: Incomplete Account Upgrade Handling

The isAccountUpgraded variable is computed but unused, making the account upgrade check incomplete. The guide describes handling both upgraded and non-upgraded accounts, but the code doesn't demonstrate this conditional logic.

Additional Locations (1)

Fix in Cursor Fix in Web

// represents the delegation.
//
// You need to remove the first 8 characters (0xef0100) to get the delegator address.
const delegatorAddress = `0x${code.substring(8)}`;
Copy link

Choose a reason for hiding this comment

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

Bug: Delegation Prefix Validation Missing

The logic for checking EOA account code extracts the delegator address using substring(8) without first validating if the code starts with the EIP-7702 delegation prefix (0xef0100). This can lead to incorrect delegation detection and misidentification of account upgrade status.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor

@alexandratran alexandratran left a comment

Choose a reason for hiding this comment

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

Added some edits and one remaining question.

Currently, ERC-7715 does not support automatically upgrading a user's account to a [MetaMask smart account](../../concepts/smart-accounts.md). Therefore, you must
ensure that the user is upgraded to a smart account before requesting ERC-7715 permissions.

If the user has not yet been upgraded, you can handle the upgrade [programmatically](/wallet/how-to/send-transactions/send-batch-transactions/#about-atomic-batch-transactions) or ask the
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you specifically need to do to handle the upgrade programmatically? This links to the wallet api send batch txns page – but is it also possible through the SDK tutorial or the DTK 7702 quickstart?

Copy link
Member Author

Choose a reason for hiding this comment

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

You need to initiate the wallet_sendCalls (ERC-5792) request. This can’t be done through the DTK 7702 Quickstart, as that guide focuses on upgrading embedded accounts to MetaMask Smart Accounts. Instead, it can be achieved using the SDK tutorial, but the two guides aren’t fully aligned.

In the SDK tutorial, you’ll use Wagmi, connect the wallet, and then interact through hooks. The Wallet API documentation, on the other hand, focuses on using the provider, which you can obtain directly from the WalletClient created earlier, allowing you to follow a single, streamlined flow without needing the extra steps described in the SDK tutorial.

@AyushBherwani1998
Copy link
Member Author

@bgravenorst can we get your review?

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