|
| 1 | +--- |
| 2 | +description: How to resolve the InvalidEOASignature error when redeeming delegations. |
| 3 | +sidebar_label: Invalid EOA signature |
| 4 | +toc_max_heading_level: 2 |
| 5 | +keywords: [InvalidEOASignature, error code, delegation, troubleshooting, invalid EOA signature] |
| 6 | +--- |
| 7 | + |
| 8 | +# Invalid EOA signature |
| 9 | + |
| 10 | +The Delegation Manager reverts with `InvalidEOASignature()` in the following cases. |
| 11 | + |
| 12 | +## Smart account is not deployed |
| 13 | + |
| 14 | +The [root delegation's](../concepts/delegation/index.md#delegation-types) delegator must be a |
| 15 | +MetaMask smart account. The Delegation Manager checks the delegator code to determine |
| 16 | +whether it is an externally owned account (EOA) or a smart account. |
| 17 | + |
| 18 | +If the smart account is not deployed yet, its address has no contract code. The Delegation |
| 19 | +Manager treats the address as an EOA and attempts ECDSA signature recovery. Because the |
| 20 | +delegation was signed by the smart account, signature recovery returns a different address, |
| 21 | +and the call reverts. |
| 22 | + |
| 23 | +### Solution |
| 24 | + |
| 25 | +Verify that the smart account used as the delegator is deployed before redeeming the delegation. The |
| 26 | +smart account can be either an ERC-4337 smart account or an EIP-7702 upgraded EOA. |
| 27 | + |
| 28 | +For an ERC-4337 smart account, the first user operation sent from that account deploys it |
| 29 | +automatically. For more information, see the [deploy a smart account](../guides/smart-accounts/deploy-smart-account.md) guide. |
| 30 | + |
| 31 | +For an EIP-7702-upgraded EOA, verify that you submit the authorization to set the account code |
| 32 | +before redeeming the delegation. |
| 33 | + |
| 34 | +```ts |
| 35 | +import { getSmartAccountsEnvironment } from "@metamask/smart-accounts-kit"; |
| 36 | +import { sepolia as chain } from "viem/chains"; |
| 37 | + |
| 38 | +// Get the EOA account code |
| 39 | +const code = await publicClient.getCode({ |
| 40 | + address, |
| 41 | +}); |
| 42 | + |
| 43 | +if (code) { |
| 44 | + // According to EIP-7702, the code format is 0xef0100 || address. |
| 45 | + // Remove the first 8 characters (0xef0100) to get the delegator address. |
| 46 | + const delegatorAddress = `0x${code.substring(8)}`; |
| 47 | + |
| 48 | + const statelessDelegatorAddress = getSmartAccountsEnvironment(chain.id) |
| 49 | + .implementations |
| 50 | + .EIP7702StatelessDeleGatorImpl; |
| 51 | + |
| 52 | + // If the account isn't upgraded to a MetaMask smart account, you can |
| 53 | + // either upgrade programmatically or ask the user to switch to a smart account manually. |
| 54 | + const isAccountUpgraded = delegatorAddress.toLowerCase() === statelessDelegatorAddress.toLowerCase(); |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +To upgrade an EOA to a MetaMask smart account, see the [EIP-7702 quickstart](../get-started/smart-account-quickstart/eip7702.md). |
| 59 | + |
| 60 | +## Incorrect signer |
| 61 | + |
| 62 | +The delegation was signed with an account that doesn't correspond to the delegator |
| 63 | +address. When the delegator is an EOA, the Delegation Manager recovers the signer from |
| 64 | +the EIP-712 typed data hash and compares it to the `delegator` field. If they don't |
| 65 | +match, the transaction reverts. |
| 66 | + |
| 67 | +This occurs when redeeming a [delegation chain](../guides/delegation/create-redelegation.md). An |
| 68 | +intermediate or leaf delegation has an EOA as the delegator, but the delegation is signed by an |
| 69 | +account other than the expected delegator. |
| 70 | + |
| 71 | +### Solution |
| 72 | + |
| 73 | +Verify that the private key used to sign the delegation corresponds to the delegator address. For |
| 74 | +more information, see the [`signDelegation`](../reference/delegation/index.md#signdelegation) reference. |
| 75 | + |
| 76 | +## Incorrect chain ID or Delegation Manager |
| 77 | + |
| 78 | +The EIP-712 domain separator used for signing the delegation includes the chain ID and the Delegation Manager contract |
| 79 | +address. If the delegation was signed on a different chain or against a different |
| 80 | +Delegation Manager, the recovered address won't match. |
| 81 | + |
| 82 | +### Solution |
| 83 | + |
| 84 | +Verify that the chain ID and Delegation Manager contract address you use when signing match the |
| 85 | +chain and contract where you redeem the delegation. |
0 commit comments