EIP-7702 authorization nonce logic #3734
-
I'm working with the new EIP-7702 authorizationList feature. While using the library to sign authorizations via Relevant excerpt from viem's source: authorization.nonce = await getTransactionCount({ address, blockTag: 'pending' });
if (executor === 'self' || executor.address === account.address) {
authorization.nonce += 1;
} This seems to suggest: If the signer is also the one broadcasting (i.e., executor: 'self'), viem adds +1 to the nonce. Otherwise (e.g., a relayer is broadcasting), it uses the current nonce from My questions are: Should the Why does viem increment the nonce by 1 only when the signer is also the broadcaster? Why is the behavior different when another account broadcasts the transaction? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
In the case if Alice is the authorizor and the executor: The transaction will consume a nonce ( |
Beta Was this translation helpful? Give feedback.
In the case if Alice is the authorizor and the executor: The transaction will consume a nonce (
alice:n
), and then, the authorization will check against nonce of Alice (alice:n+1
).In the case if Alice is the authorizer, and Bob is the executor: The transaction will consume a nonce (
bob:n
), and then, the authorization will check against nonce of Alice (alice:n
)