Skip to content
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

feat: stabilize EIP-7702 #3427

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .changeset/clever-mice-laugh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"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`.
- Deprecated EIP-7702 exports in `viem/experimental`.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"typescript": "5.6.2",
"vitest": "^1.0.4"
},
"packageManager": "pnpm@9.1.0",
"packageManager": "pnpm@10.6.1",
"engines": {
"node": "23.x"
},
Expand Down 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
32 changes: 28 additions & 4 deletions 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. [Example](/docs/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](/docs/eip7702/contract-writes#6-optional-use-a-sponsor)
- **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