Skip to content

Commit fc59992

Browse files
add invalid signature troubleshoot page
* add invalid signature troubleshoot page * remove unused imports * improve troubleshoot page * resolve review comments * resolve review comments
1 parent 4a45557 commit fc59992

3 files changed

Lines changed: 89 additions & 3 deletions

File tree

gator-sidebar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ const sidebar = {
215215
collapsed: true,
216216
items: [
217217
'troubleshooting/error-codes',
218+
'troubleshooting/invalid-signature',
218219
'troubleshooting/invalid-delegate',
219220
'troubleshooting/aa21-prefund',
220221
],

smart-accounts-kit/troubleshooting/error-codes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Error codes from the [MetaMask Delegation Framework contracts](https://github.co
1313

1414
| Error code | Error name | Description |
1515
| ---------- | ---------- | ----------- |
16-
| `0xb5863604` | `InvalidDelegate()` | The caller is not the delegate specified in the delegation.<br/><br/>See [Invalid delegate troubleshooting page](./invalid-delegate.md) to learn more. |
17-
| `0xb9f0f171` | `InvalidDelegator()` | The caller is not the delegator specificed in the delegation.<br/><br/>See [Invalid delegator troubleshooting page](./invalid-delegator.md) to learn more. |
16+
| `0xb5863604` | `InvalidDelegate()` | The caller is not the delegate specified in the delegation.<br/><br/>See how to [troubleshoot an invalid delegate](./invalid-delegate.md). |
17+
| `0xb9f0f171` | `InvalidDelegator()` | The caller is not the delegator specificed in the delegation.<br/><br/>See how to [troubleshoot an invalid delegator](./invalid-delegator.md). |
1818
| `0x05baa052` | `CannotUseADisabledDelegation()` | The delegation has been disabled by the delegator. |
1919
| `0xded4370e` | `InvalidAuthority()` | The delegation chain authority validation failed. The authority hash of a child delegation does not match the hash of its parent delegation. |
2020
| `0x1bcaf69f` | `BatchDataLengthMismatch()` | The array lengths do not match in a batch `redeemDelegations` contract call. |
@@ -24,7 +24,7 @@ Error codes from the [MetaMask Delegation Framework contracts](https://github.co
2424
| `0xfce698f7` | `ECDSAInvalidSignatureLength(uint256)` | The ECDSA signature length is incorrect. |
2525
| `0xac241e11` | `EmptySignature()` | The signature is empty. |
2626
| `0xd93c0665` | `EnforcedPause()` | The Delegation Manager contract is paused by the owner. |
27-
| `0x3db6791c` | `InvalidEOASignature()` | EOA signature verification failed. |
27+
| `0x3db6791c` | `InvalidEOASignature()` | EOA signature verification failed.<br/><br/>See how to [troubleshoot an invalid EOA signature](./invalid-signature.md). |
2828
| `0x155ff427` | `InvalidERC1271Signature()` | Smart contract signature (ERC-1271) verification failed. |
2929
| `0x118cdaa7` | `OwnableUnauthorizedAccount(address)` | An unauthorized account attempted an owner only action. |
3030
| `0x1e4fbdf7` | `OwnableInvalidOwner(address)` | Invalid owner address in an ownership transfer. |
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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

Comments
 (0)