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

WIP: Add tutorial for EIP-7702 #669

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion pages/advanced/eip-7702/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"overview": "Overview",
"7702-safe": "Safe and EIP-7702"
"7702-safe": "Safe and EIP-7702",
"tutorials": "Tutorials"
}
3 changes: 3 additions & 0 deletions pages/advanced/eip-7702/tutorials/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"approach-1": "Safe proxy as delegation designator"
}
49 changes: 49 additions & 0 deletions pages/advanced/eip-7702/tutorials/approach-1.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Callout } from 'nextra/components'

# Approach 1: Delegate to modified Safe Proxy contract

The tutorial below presents an approach to set delegation designator to a modified Safe Proxy contract discussed in [EIP-7702 approaches](../7702-safe#modified-safe-proxy).

### 1. Setup project

```bash
git clone [email protected]:5afe/safe-eip7702.git
```

### 2. Install dependencies

```bash
cd safe-eip7702/safe-eip7702-contracts
pnpm i
```

### 3. Setup RPC and .env file

- Copy `.env.example` to `.env` and update the values
- Set the relayer and EOA private keys in the `.env` file.
- `RELAYER_PRIVATE_KEY`: Used for paying gas fees
- `ACCOUNT_PRIVATE_KEY`: EOA private key whose code will be set

- Update `hardhat.config.ts` has appropriate values for the network.
- Make sure the contracts are deployed on the network using
```bash
npx hardhat deploy --network <network>
```

### 4. Run the script to set the code

```bash
npx hardhat run src/scripts/1_set_code.ts --network <network>
```

### 5. Execute transaction

- The script `2_execute.ts` can be used to execute a transaction using the EOA which is sponsored by the relayer account. The script will send 1 wei to the relayer account from EOA address.
```bash
npx hardhat run src/scripts/2_execute.ts --network <network>
```

- The script `3_batch_execute.ts` can be used to execute batch transaction using the EOA which is sponsored by the relayer account. The script will execute 2 calls which send 1 wei in each call to the relayer account from EOA address.
```bash
npx hardhat run src/scripts/3_batch_execute.ts --network <network>
```
Loading