Skip to content

feat: stabilize EIP-7702 #3427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/clever-mice-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"viem": minor
---

Stabilized EIP-7702.

- Added `prepareAuthorization` and `signAuthorization` Actions to the Wallet Client.
- Added `hashAuthorization`, `recoverAuthorizationAddress`, and `verifyAuthorization` Utilities.
- Renamed `account.experimental_signAuthorization` to `account.signAuthorization`.
5 changes: 5 additions & 0 deletions .changeset/dirty-trees-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": minor
---

**BREAKING (Experimental)**: Removed deprecated `walletActionsEip5792` export. Use `eip5792Actions` instead.
5 changes: 5 additions & 0 deletions .changeset/mighty-maps-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

**BREAKING (Experimental)**: Removed deprecated ERC-6492 exports in `viem/experimental`. These are no longer experimental. Use exports from `viem` instead.
5 changes: 5 additions & 0 deletions .changeset/new-seas-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

**BREAKING (Experimental)**: Removed deprecated `walletActionsErc7715` export. Use `erc7715Actions` instead.
44 changes: 44 additions & 0 deletions .changeset/odd-parents-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
"viem": minor
---

**BREAKING (Experimental)**:

Removed EIP-7702 exports in `viem/experimental`. These are no longer experimental. Use exports from `viem` or `viem/utils` instead.

Note, there is also a behavioral change in the stable EIP-7702 `signAuthorization` function. Previously, it was assumed that the signer of the Authorization was also the executor of the Transaction. This is no longer the case.

If the signer of the Authorization is **NOT** the executor of the Transaction, you no longer need to pass a `sponsor` parameter.

```diff
const eoa = privateKeyToAccount('0x...')
const relay = privateKeyToAccount('0x...')

const authorization = await client.signAuthorization({
account: eoa,
contractAddress: '0x...',
- sponsor: true
})

const transaction = await client.sendTransaction({
account: relay,
authorizationList: [authorization],
})
```

If the signer of the Authorization is **ALSO** the executor of the Transaction, you will now need to pass the `executor` parameter with a value of `'self'`.

```diff
const eoa = privateKeyToAccount('0x...')

const authorization = await client.signAuthorization({
account: eoa,
contractAddress: '0x...',
+ executor: 'self',
})

const transaction = await client.sendTransaction({
account: eoa,
authorizationList: [authorization],
})
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
{
"name": "const viem = require('viem') (cjs)",
"path": "./src/_cjs/index.js",
"limit": "83 kB"
"limit": "84 kB"
},
{
"name": "import { createClient, http } from 'viem'",
Expand Down
1 change: 0 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion site/pages/docs/accounts/local/signTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Signed EIP-7702 Authorization list.
import { privateKeyToAccount } from 'viem/accounts'
const account = privateKeyToAccount('0x...')
// ---cut---
const authorization = await account.experimental_signAuthorization({
const authorization = await account.signAuthorization({
contractAddress: '0x...',
chainId: 1,
nonce: 1,
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/actions/wallet/prepareTransactionRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ const request = await walletClient.prepareTransactionRequest({

:::note
**References**
- [EIP-7702 Overview](/experimental/eip7702)
- [`signAuthorization` Docs](/experimental/eip7702/signAuthorization)
- [EIP-7702 Overview](/docs/eip7702)
- [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
:::

### blobs (optional)
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/actions/wallet/sendTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ const hash = await walletClient.sendTransaction({

:::note
**References**
- [EIP-7702 Overview](/experimental/eip7702)
- [`signAuthorization` Docs](/experimental/eip7702/signAuthorization)
- [EIP-7702 Overview](/docs/eip7702)
- [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
:::

### blobs (optional)
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/actions/wallet/signTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ const signature = await walletClient.signTransaction({

:::note
**References**
- [EIP-7702 Overview](/experimental/eip7702)
- [`signAuthorization` Docs](/experimental/eip7702/signAuthorization)
- [EIP-7702 Overview](/docs/eip7702)
- [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
:::

### blobs (optional)
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/contract/simulateContract.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ const { result } = await publicClient.simulateContract({

:::note
**References**
- [EIP-7702 Overview](/experimental/eip7702)
- [`signAuthorization` Docs](/experimental/eip7702/signAuthorization)
- [EIP-7702 Overview](/docs/eip7702)
- [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
:::

### args (optional)
Expand Down
4 changes: 2 additions & 2 deletions site/pages/docs/contract/writeContract.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ await walletClient.writeContract({

:::note
**References**
- [EIP-7702 Overview](/experimental/eip7702)
- [`signAuthorization` Docs](/experimental/eip7702/signAuthorization)
- [EIP-7702 Overview](/docs/eip7702)
- [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
:::

### args (optional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ description: An Overview of EIP-7702

EIP-7702 is a proposal to add a new Transaction type to allow an EOA to designate a Smart Contract as its "implementation".

The main difference between an EIP-7702 Transaction and other transactions is the inclusion of a **"authorization list"** property, a set of `(chain_id, contract_address, nonce, y_parity, r, s)` tuples that depict what Contract bytecode(s) should be injected onto the Externally Owned Account during execution.
The main difference between an EIP-7702 Transaction and other transactions is the inclusion of a **"authorization list"** property, a set of `(chain_id, contract_address, nonce, y_parity, r, s)` tuples that depict what Contracts should be delegated onto the Externally Owned Account.

:::note
In Viem, you won't need to worry about constructing these Authorization Tuples manually as you can use [`signAuthorization`](/experimental/eip7702/signAuthorization) to generate them and use them in [Transaction APIs](/experimental/eip7702/contract-writes).
In Viem, you won't need to worry about constructing these Authorization Tuples manually as you can use [`signAuthorization`](/docs/eip7702/signAuthorization) to generate them and use them in [Transaction APIs](/docs/eip7702/contract-writes).
:::

Applications of EIP-7702 include:

- **Batching**: allowing multiple operations from the same user in one atomic transaction. One common example is an ERC-20 approval followed by spending that approval, a common workflow in DEXes that requires two transactions today. Advanced use cases of batching occasionally involve dependencies: the output of the first operation is part of the input to the second operation. [Example](/experimental/eip7702/contract-writes#5-invoke-contract-function)
- **Sponsorship**: account X pays for a transaction on behalf of account Y. Account X could be paid in some other ERC-20 for this service, or it could be an application operator including the transactions of its users for free. [Example](/experimental/eip7702/contract-writes#6-optional-use-a-sponsor)
- **Batching**: allowing multiple operations from the same user in one atomic transaction. One common example is an ERC-20 approval followed by spending that approval, a common workflow in DEXes that requires two transactions today. Advanced use cases of batching occasionally involve dependencies: the output of the first operation is part of the input to the second operation.
- **Sponsorship**: account X pays for a transaction on behalf of account Y. Account X could be paid in some other ERC-20 for this service, or it could be an application operator including the transactions of its users for free.
- **Privilege de-escalation**: users can sign sub-keys, and give them specific permissions that are much weaker than global access to the account. For example, you could imagine a permission to spend ERC-20 tokens but not ETH, or to spend up to 1% of total balance per day, or to interact only with a specific application.

## Next Steps

- [Extending Client with EIP-7702](/experimental/eip7702/client)
- [Contract Writes](/experimental/eip7702/contract-writes)
- [Sending Transactions](/experimental/eip7702/sending-transactions)
- [Contract Writes](/docs/eip7702/contract-writes)
- [Sending Transactions](/docs/eip7702/sending-transactions)
Loading
Loading