diff --git a/assets/diagram-7702-approach-1.png b/assets/diagram-7702-approach-1.png new file mode 100644 index 00000000..790998a3 Binary files /dev/null and b/assets/diagram-7702-approach-1.png differ diff --git a/assets/diagram-7702-approach-2.png b/assets/diagram-7702-approach-2.png new file mode 100644 index 00000000..d8dee31a Binary files /dev/null and b/assets/diagram-7702-approach-2.png differ diff --git a/assets/diagram-7702-approach-3.png b/assets/diagram-7702-approach-3.png new file mode 100644 index 00000000..3200574e Binary files /dev/null and b/assets/diagram-7702-approach-3.png differ diff --git a/pages/advanced/eip-7702/7702-safe.mdx b/pages/advanced/eip-7702/7702-safe.mdx index 225e6cd2..7844cb03 100644 --- a/pages/advanced/eip-7702/7702-safe.mdx +++ b/pages/advanced/eip-7702/7702-safe.mdx @@ -1,3 +1,5 @@ +import { Callout } from 'nextra/components' + # Safe and EIP-7702 EIP-7702 does not specify how to initialise the storage of the account but only gives a way to set the code of the account. @@ -10,21 +12,10 @@ Existing Safe contracts cannot be used with EIP-7702, because of following reaso ## Possible approaches -### Modified safe singleton - -In this approach, a derived version of Safe Singleton aka `SafeEIP7702` overrides the `setup` function and reverts when called. -Instead, a new function `setupEIP7702` in the contract has a `signature` parameter. The default owner will be set to the address of the EOA account that is delegating to this Singleton contract with a threshold of 1. - -[SafeEIP7702](https://github.com/safe-global/safe-smart-account/blob/feature/eip-7702/contracts/experimental/SafeEIP7702.sol) - -Because of no proxy contract in this approach, the storage slot 0 remains unused. Safe Transaction Service and other services that depend on the value at storage slot 0 will not work with this approach. - - ### Modified safe proxy [SafeEIP7702Proxy](https://github.com/5afe/safe-eip7702/blob/main/safe-eip7702-contracts/contracts/SafeEIP7702Proxy.sol) - This approach uses a derived proxy contract from [Safe Proxy](https://github.com/5afe/safe-eip7702/blob/main/safe-eip7702-contracts/contracts/SafeEIP7702Proxy.sol) with following changes: 1. The constructor of the `SafeEIP7702Proxy` contract has an additional parameter `setupDataHash` which is the hash of the `setup` function call data. Thus, the address of the proxy contract also depends on the `setupDataHash` and not just the `singleton` contract address. Proxy contract uses this hash to verify that the `setup` function parameter values are unchanged during initialised of storage. @@ -36,9 +27,36 @@ Proxy contract uses this hash to verify that the `setup` function parameter valu This approach has a gas overhead as a new proxy contract has to be deployed for each EOA account as the setupDataHash will be possibly unique for each user. But, using this approach users can use the existing Safe Wallet UI with minor modifications and import the EOA account as a Safe account. +![diagram-7702-approach-1](../../../assets/diagram-7702-approach-1.png) + +Follow the instructions here to use this approach to set code in EOA: https://github.com/5afe/safe-eip7702/tree/main/safe-eip7702-contracts#execute-scripts + +### Modified safe singleton + +In this approach, a derived version of Safe Singleton aka `SafeEIP7702` overrides the `setup` function and reverts when called. +Instead, a new function `setupEIP7702` in the contract has a `signature` parameter. The default owner will be set to the address of the EOA account that is delegating to this Singleton contract with a threshold of 1. + +[SafeEIP7702](https://github.com/safe-global/safe-smart-account/blob/feature/eip-7702/contracts/experimental/SafeEIP7702.sol) + +Because of no proxy contract in this approach, the storage slot 0 remains unused. Safe Transaction Service and other services that depend on the value at storage slot 0 will not work with this approach. + +![diagram-7702-approach-2](../../../assets/diagram-7702-approach-2.png) + ### SafeLite [SafeLite](https://github.com/5afe/safe-eip7702/blob/main/safe-eip7702-contracts/contracts/experimental/SafeLite.sol) is a lite version of Safe and compatible with EIP-7702. The contract does not have a proxy and does not need any initialisation. SafeLite supports ERC-4337 and hence can use features such as sponsored transactions, and even batch transactions. SafeLite also supports ERC-1271 for contract-based signatures. SafeLite is not compatible with the existing Safe Wallet UI as it does not use the same storage layout as the existing Safe contracts. It does not have the features of the existing Safe contracts such as Modules, Fallback Handler, Guards. + +![diagram-7702-approach-3](../../../assets/diagram-7702-approach-3.png) + + + All the above approaches are experimental and the contracts are not yet audited. Use them at your own risk. + + +#### Other resources + +- [Demo with SafeEIP7702Proxy](https://github.com/user-attachments/assets/ae77c03a-1c73-47b8-9769-f5e7c1fee095) +- [Code walk through](https://www.youtube.com/watch?v=dx4mk6tKHCo) +- [Slides](https://docs.google.com/presentation/d/12j90QkVx_A-iAZ14mnx6ztsafqqsth3NWZpxp3LV2cQ/edit#slide=id.p) \ No newline at end of file diff --git a/pages/advanced/eip-7702/overview.mdx b/pages/advanced/eip-7702/overview.mdx index e986f303..61c23961 100644 --- a/pages/advanced/eip-7702/overview.mdx +++ b/pages/advanced/eip-7702/overview.mdx @@ -19,11 +19,11 @@ Setting Code for the EOA Once the EOA signs the hash, an authorization list is sent to the EVM node through a new transaction type, the set code transaction, introduced in EIP-7702. -The EVM node then: +The execution client then performs the following checks: - Verifies the signature. - Checks the account's nonce. -- Confirms the chain ID. +- Confirms the chain ID (`0` or the current chain ID). If all checks pass, the execution client sets the EOA's code in the format `(0xef0100 ++ address)`.