EXP-0001: Account Delegation with EIP-7702
Table of Contents
Background
There has been much interest in Account Abstraction & Smart Contract Accounts over the past couple of years as a means to enable new use cases on Ethereum Accounts – such as: batch transactions, arbitrary signer types (e.g. WebAuthn, P256, etc), social account recovery, and more.
However, a hurdle to widespread adoption has been the inability for existing (and even new) Externally-owned Accounts (EOAs) to have the same capabilities as Smart Contract Accounts.
EIP-7702 is a proposal included in the next Ethereum hardfork (Pectra), which adds a new Transaction type to allow an EOA to designate a Smart Contract as its “implementation”. This will allow EOAs to function similarly to Smart Contract Accounts, and enable features like:
- Batch Calls: Sending multiple calls in a single transaction.
- Transaction Sponsorship: Defer transaction execution (and payment of gas fees) to a third-party (such as a Sequencer or Wallet Server).
- Arbitrary Signing Keys: Use a variety of key types (e.g. WebAuthn, P256, BLS, etc) to verify actions.
- Session & Scoped Keys: Authorize Signing Keys with a specific lifespan or permissions.
- … and much more.
Overview
In this experiment, we will be exploring the use of EIP-7702 (Set Account Code) and RIP-7212 (P256 Precompile) to inject an Experimental (P256-enabled) Delegation Contract onto an Account (EOA).
The purpose of the Delegation Contract is to enable the Account to authorize WebAuthn Public Key(s) to be used for call delegation.
A third-party (e.g. Sequencer, Wallet Server, etc) can then execute call(s) on behalf of the Account with the WebAuthn Signature that was computed by an authorized WebAuthn signing key.
(It is also possible to eliminate the third-party altogether and have the Account execute the call(s) by itself)
We will demonstrate this with the example below. This example is published on GitHub. We encourage builders to go fork the repository and deploy their own experiment on Odyssey Testnet.
Example
Let’s demonstrate how we can leverage Account Delegation with EIP-7702 to create an Externally-owned Account (EOA) that is controlled by a WebAuthn key (e.g. Passkey). Signatures generated by the WebAuthn key will be verified using the RIP-7212 P256 Precompile.
For this example, we will be using and interacting with the Odyssey Testnet. We will also be utilizing the ExperimentDelegation contract for Account (EOA) delegation.
You can also see the complete example on GitHub.
Initialize an Account
Firstly, we will initialize an Account (EOA). You can either click on “Register” to create a new Account, or “Sign In” to sign into an existing one that you have created previously.
By clicking the “Register” button above, behind the scenes it will:
- Generate an Account (EOA) with a random private key
- Prompt the end-user to create a WebAuthn key (e.g. Passkey)
- Sign an EIP-7702 Authorization to designate the ExperimentDelegation contract onto the Account.
- Send an EIP-7702 Transaction with the Authorization from Step 3, and authorize the WebAuthn public key on the Account.
Note: In this example, we are not retaining or persisting the private key generated in Step 1. It is disposed after signing the EIP-7702 Authorization.
Executing a (Sponsored) Call
Next, let’s demonstrate executing a contract call using our Account (EOA) that is controlled by our WebAuthn key.
Try mint some Experiment ERC20 (EXP) Tokens to your Account:
The mint transaction will be executed by the Sequencer (via the odyssey_sendTransaction
RPC method) and the gas fee will be covered by it.
What is a Sequencer?
The Sequencer is a service that collects transactions from users and broadcasts them to the network. The Sequencer for Odyssey Testnet also supports the feature of sending sponsored transactions via odyssey_sendTransaction
.
In the future, it will be trivial to deploy your own “light” Sequencer (a variant of the dedicated Sequencer) if you wish to use your own Delegation Contract(s) and control how transactions are sponsored (more details soon).
What is odyssey_sendTransaction
?
odyssey_sendTransaction
is an experimental RPC method that sends a Sequencer-sponsored Transaction to the network. It follows the ORC-001 Proposal, and intends to evolve into a future ERC.
The API is intentionally nearly identical to eth_sendTransaction
so developers can easily use it as a drop-in replacement when experimenting with EIP-7702 and Sequencers.
It is important to note that transactions will only be processed by the Sequencer if:
- The transaction is an EIP-7702 transaction that delegates to one of the authorized contract addresses
- The transaction is an EIP-1559 transaction to an EOA that is currently delegated to one of the addresses above
- The
value
is exactly0
odyssey_
Namespace Links: Reference, Implementation
Batch Contract Calls
Our ExperimentDelegation
contract also supports sending multiple calls in a single transaction.
Let’s demonstrate this by sending some EXP tokens to a couple of arbitrary accounts. Press the “Send” button below to send some EXP to these generated accounts.
Upon sending the tokens, we are:
- Prompting the end-user to sign over the calls with their WebAuthn key (e.g. Passkey)
- Invoking the
execute
function on the Account (which proxies to theExperimentDelegation
contract) with the calls and the WebAuthn signature. TheExperimentDelegation
contract uses the RIP-7212 P256 Precompile to verify the WebAuthn signature. - Upon invoking the
execute
function, we are again broadcasting a transaction to the Sequencer.
Conclusion
This is a trivial demonstration to showcase the potential of Account Delegation with EIP-7702, and we can imagine a variety of use cases beyond WebAuthn-P256 Keys, Sponsored Transactions, and Batch Calls such as:
- More Key Types: Signature verification for P256, BLS, or ed25519 keys.
- Session & Scoped Keys: Authorize keys with a specific lifespan or permissions.
- ERC-4337 Compatibility: Designate an existing EOA to a ERC-4337 compatible Smart Contract (for example, Coinbase’s Smart Wallet).
- Multi-signature Execution: Enable a minimum number of signatures to execute call(s).
- Custom Gas Tokens: Use a custom gas token such as USDC for the Account to pay for gas.
- Recovery Mechanisms: Assign multiple entities as trusted recovery agents for the Account.
- … and much more.
Now it is your turn to experiment with Account Delegation & EIP-7702 on Odyssey.