Implements internal JSON-RPC methods that support EIP-7702 account upgrade functionality. These methods are internal to MetaMask and not defined in EIP-7702, but provide the necessary infrastructure for EIP-7702 account upgrades.
yarn add @metamask/eip-7702-internal-rpc-middleware
or
npm install @metamask/eip-7702-internal-rpc-middleware
Upgrades an EOA account to a smart account using EIP-7702.
Parameters:
account(string): Address of the EOA to upgradechainId(string, optional): Chain ID for the upgrade (defaults to current)
Returns:
transactionHash(string): Hash of the EIP-7702 authorization transactionupgradedAccount(string): Address of the upgraded account (same as input)delegatedTo(string): Address of the contract delegated to
Example:
{
"method": "wallet_upgradeAccount",
"params": [
{
"account": "0x1234567890123456789012345678901234567890",
"chainId": "0x1"
}
]
}Checks if an account has been upgraded using EIP-7702.
Parameters:
account(string): Address of the account to checkchainId(string, optional): Chain ID for the check (defaults to current)
Returns:
account(string): Address of the checked accountisUpgraded(boolean): Whether the account is upgradedupgradedAddress(string | null): Address to which the account is upgraded (null if not upgraded)chainId(string): Chain ID where the check was performed
Example:
{
"method": "wallet_getAccountUpgradeStatus",
"params": [
{
"account": "0x1234567890123456789012345678901234567890",
"chainId": "0x1"
}
]
}Example Response (Upgraded Account):
{
"account": "0x1234567890123456789012345678901234567890",
"isUpgraded": true,
"upgradedAddress": "0xabcdef1234567890abcdef1234567890abcdef12",
"chainId": "0x1"
}Example Response (Non-Upgraded Account):
{
"account": "0x1234567890123456789012345678901234567890",
"isUpgraded": false,
"upgradedAddress": null,
"chainId": "0x1"
}This package is part of a monorepo. Instructions for contributing can be found in the monorepo README.